我一直想增加我的批处理大小,以提高我的模型的通用性(它对批处理大小非常敏感)。这个问题的解决方案是使用多个GPU,以利用更多的内存。我在我的脚本中使用tensorflow.keras (在Windows10上使用TensorFlow2.1),并按照说明为我的模型配置镜像策略。问题是,我的训练脚本在没有镜像策略代码的情况下运行得很好,但是使用镜像策略时,我得到了一个关于NCCL的错误。这看起来与以下问题完全相同:
https://github.com/tensorflow/tensorflow/issues/21470
不幸的是,该链接中讨论的解决方案:
cross_tower_ops = tf.contrib.distribute.AllReduceCrossDeviceOps(
'hierarchical_copy', num_packs=num_gpus))
strategy = tf.contrib.distribute.MirroredStrategy(cross_tower_ops=cross_tower_ops)不适用于tf 2.1,因为tf的“contrib”部分似乎已被删除。有谁知道Windows上NCCL的替代修复是什么,或者tf的“contrib”部分已经消失了吗?
发布于 2020-08-18 10:30:53
版本21470中的一个解决方案是为Winx64构建nccl。MyCaffe在此处提供了相关说明:https://github.com/MyCaffe/NCCL/blob/master/INSTALL.md
你将需要VS 2015,2017,CUDA开发包,并在编译后将生成的.dlls放在正确的位置。
发布于 2021-08-24 13:12:36
根据我的经验,一些cross_device_ops不能工作并产生错误。
此选项适用于NVIDIA DGX-1架构,在其他架构上可能表现不佳:
strategy = tf.distribute.MirroredStrategy(
cross_device_ops=tf.distribute.HierarchicalCopyAllReduce())应该行得通:
strategy = tf.distribute.MirroredStrategy(
cross_device_ops=tf.distribute.ReductionToOneDevice())不适用于我的配置:
strategy = tf.distribute.MirroredStrategy(
cross_device_ops=tf.distribute.NcclAllReduce())因此,可以建议它尝试不同的选项。
https://stackoverflow.com/questions/60973491
复制相似问题