我想使用MirroredStrategy在同一台机器上使用多个GPU。我试过其中一个例子:example.py
结果是: ValueError: Op类型未在RAID上运行的二进制文件中注册“NcclAllReduce”。确保Op和内核已在此进程中运行的二进制文件中注册。同时构建NodeDef 'NcclAllReduce‘
我正在使用Windows,因此Nccl不可用。是否有可能强迫TensorFlow不使用这个库?
发布于 2019-07-26 22:12:47
Windows上有一些针对NCCL的二进制文件,但是处理起来可能会很烦人。
作为另一种选择,Tensorflow在MirroredStrategy中为您提供了其他三个与Windows兼容的选项。它们是分层复制,减少到第一个GPU,并减少到CPU。您最可能寻找的是分层复制,但您可以测试它们中的每一个,以确定什么才能给您最好的结果。
如果您使用的是高于2.0的tensorflow版本,您将使用tf.contrib.distribute:
# Hierarchical Copy
cross_tower_ops = tf.contrib.distribute.AllReduceCrossTowerOps(
'hierarchical_copy', num_packs=number_of_gpus))
strategy = tf.contrib.distribute.MirroredStrategy(cross_tower_ops=cross_tower_ops)
# Reduce to First GPU
cross_tower_ops = tf.contrib.distribute. ReductionToOneDeviceCrossTowerOps()
strategy = tf.contrib.distribute.MirroredStrategy(cross_tower_ops=cross_tower_ops)
# Reduce to CPU
cross_tower_ops = tf.contrib.distribute. ReductionToOneDeviceCrossTowerOps(
reduce_to_device="/device:CPU:0")
strategy = tf.contrib.distribute.MirroredStrategy(cross_tower_ops=cross_tower_ops)在2.0之后,您只需要使用tf.distribute!下面是一个用2个GPU建立Xception模型的示例:
strategy = tf.distribute.MirroredStrategy(devices=["/gpu:0", "/gpu:1"],
cross_device_ops=tf.distribute.HierarchicalCopyAllReduce())
with strategy.scope():
parallel_model = Xception(weights=None,
input_shape=(299, 299, 3),
classes=number_of_classes)
parallel_model.compile(loss='categorical_crossentropy', optimizer='rmsprop')https://stackoverflow.com/questions/50701512
复制相似问题