繁体   English   中英

Tensorflow 多 GPU - NCCL

[英]Tensorflow Multi-GPU - NCCL

我一直想增加我的批量大小以改善我的模型的泛化(它对批量大小非常敏感)。 解决方案是使用多 GPU 以利用更多内存。 我在我的脚本中使用 tensorflow.keras(在 Windows 10 上使用 tensorflow 2.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 的“贡献”部分似乎已被删除。 有谁知道 Windows 上 NCCL 的替换修复是什么,或者替换掉 tf 的“contrib”部分?

问题 21470 的一种解决方案是为 Winx64 构建 nccl。 MyCaffe 在此处提供了相关说明: https : //github.com/MyCaffe/NCCL/blob/master/INSTALL.md

您将需要 VS 2015、2017、CUDA 开发包,并在编译后将生成的 .dll 放在正确的位置。

根据我的经验,一些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())

以便可以建议尝试不同的选项。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM