我创建了 3 个虚拟 GPU(有 1 个 GPU)并尝试加速图像的矢量化。但是,使用下面提供的代码并从文档(这里)中手动放置我得到了奇怪的结果:在所有 GPU 上的训练比在单个 GPU 上慢两倍。还要在具有 3 个物理 GPU 的机器上检查此代码(并删除虚拟设备初始化) - 工作方式相同。
环境:Python 3.6、Ubuntu 18.04.3、tensorflow-gpu 1.14.0。
代码(此示例创建 3 个虚拟设备,您可以在具有一个 GPU 的 PC 上对其进行测试):
import os
import time
import numpy as np
import tensorflow as tf
start = time.time()
def load_graph(frozen_graph_filename):
# We load the protobuf file from the disk and parse it to retrieve the
# unserialized graph_def
with tf.gfile.GFile(frozen_graph_filename, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
# Then, we import the graph_def …Run Code Online (Sandbox Code Playgroud) 我正在尝试对误差条图的标记进行着色,而不对误差条线进行着色。
这是一个 MWE:
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 2, 3, 4]
dx = 0.1
dy = 0.1
plt.errorbar(x, y, xerr = dx, yerr = dy, marker = '.',
linestyle = ' ', color = 'black', capsize = 2,
elinewidth = 0.5, capthick = 0.4, alpha = 0.8)
plt.savefig('MWE.pdf')
plt.show()
Run Code Online (Sandbox Code Playgroud)
另外,如何在不改变倾覆的情况下摆脱标记边缘?如果我把markeredgewidth = 0在capsize被复位。
更新代码:
import matplotlib.pyplot as plt
import matplotlib
x = [1, 2, 3, 4]
y = …Run Code Online (Sandbox Code Playgroud) 我想使用多个 GPU 对图像运行矢量化(现在我的脚本只使用一个 GPU)。我有一个图像、图表和会话列表。脚本的输出是保存的向量。我的机器有 3 个 NVIDIA GPU。环境:Ubuntu、python 3.7、Tensorflow 2.0(支持 GPU)。这是我的代码示例(初始化会话):
def load_graph(frozen_graph_filename):
# We load the protobuf file from the disk and parse it to retrieve the
# unserialized graph_def
with tf.io.gfile.GFile(frozen_graph_filename, "rb") as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())
# Then, we import the graph_def into a new Graph and returns it
with tf.Graph().as_default() as graph:
# The name var will prefix every op/nodes in your graph
# Since we load everything in a new graph, this is not …Run Code Online (Sandbox Code Playgroud)