我正在尝试训练具有5个集成网络的分类器。我决定用不同的批次来训练它们,所以我想创建多个过程来节省时间。
这是我的算法设计:
import multiprocessing as mp
import tensorflow as tf
# create() function returns 5 optimizer for 5 network, i.e. len(opt_list) = 5
opt_list = create()
def sub_process(sess, opt, feed_batch):
sess.run(opt, feed_dict=feed_batch)
batch_list = []
for i in range(5):
batch = generate_batch(batch_size=100)
batch_list.append(batch)
for i in range(5):
p = mp.Process(target=sub_process, args=(sess, opt_list[i], batch_list[i]))
p.start()
for i in range(5):
p.join()
首先,我构建图形并将每个网络部署在5个不同的设备上(我总共有5个GPU)。
然后,我从数据集中抽取样本(例如,如果要将100张图像馈送到一个网络,则将生成500个样本)
接下来,我使用python3包多处理程序创建5个进程。每个进程在给定参数输入的情况下运行sub_process函数。
但是,当我运行代码时,出现以下错误
2018-08-14 18:13:56.776853: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.776940: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.776978: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.777004: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.830762: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.831239: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.831262: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.831285: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:56.902612: E tensorflow/core/grappler/clusters/utils.cc:82] Failed to get device properties, error code: 3
2018-08-14 18:13:57.654653: E tensorflow/stream_executor/cuda/cuda_driver.cc:1227] failed to enqueue async memcpy from host to device: CUDA_ERROR_NOT_INITIALIZED; GPU dst: 0x1085d87f000; host src: 0x1083783f700; size: 4=0x4
2018-08-14 18:13:57.660200: E tensorflow/stream_executor/cuda/cuda_driver.cc:1227] failed to enqueue async memcpy from host to device: CUDA_ERROR_NOT_INITIALIZED; GPU dst: 0x1085d87f000; host src: 0x1083783f700; size: 4=0x4
2018-08-14 18:13:57.758658: E tensorflow/stream_executor/cuda/cuda_driver.cc:1227] failed to enqueue async memcpy from host to device: CUDA_ERROR_NOT_INITIALIZED; GPU dst: 0x1085d87f000; host src: 0x1083783f700; size: 4=0x4
2018-08-14 18:13:57.808281: E tensorflow/stream_executor/cuda/cuda_driver.cc:1227] failed to enqueue async memcpy from host to device: CUDA_ERROR_NOT_INITIALIZED; GPU dst: 0x1085d87f000; host src: 0x1083783f700; size: 4=0x4
谁能告诉我为什么会出现这样的错误?要获得我想要的代码,应该对我的代码进行哪些更改?
谢谢!