docker容器下安装nccl失败,报错:Failed to init nccl communicator for group,init nccl communicator for group nccl_world_group

相关内容参考:

https://www.cnblogs.com/devilmaycry812839668/p/15022320.html

=================================================================

docker 容器内安装 nccl  后,测试是否安装成功:

使用  NVIDIA公司官方提供的测试工具: nccl-tests

国内下载地址:

https://gitee.com/devilmaycry812839668/nccl-tests

下载后,进行编译: make

If CUDA is not installed in /usr/local/cuda, you may specify CUDA_HOME.

Similarly, if NCCL is not installed in /usr, you may specify NCCL_HOME.

默认,cuda的安装位置:/usr/local/cuda

默认,nccl的安装位置:/usr

如果cuda和nccl的安装位置不是默认的,而是手动选择其他地方的,那么需要在make的时候配置路径:

$ make CUDA_HOME=/path/to/cuda NCCL_HOME=/path/to/nccl
CUDA_HOME 为 cuda的安装路径。
NCCL_HOME 为 nccl的安装路径。

make 编译后进行简单的例子进行测试nccl是否安装成功。

Quick examples

Run on 8 GPUs (-g 8), scanning from 8 Bytes to 128MBytes :

$ ./build/all_reduce_perf -b 8 -e 128M -f 2 -g 8

Run with MPI on 40 processes (potentially on multiple nodes) with 4 GPUs each :

$ mpirun -np 40 ./build/all_reduce_perf -b 8 -e 128M -f 2 -g 4

 (该例子假设系统中已经安装了 openmpi)

这里我们需要修改的示例代码的地方为  -g  ,  如果你有一个显卡,那么就是-g 1  , 如果有四个显卡就是 -g 4

需要注意的是如果有显卡内存不够用(被其他进程调用已经占满),那么需要设置环境变量: export CUDA_VISIBLE_DEVICES="0,1,2,3"

CUDA_VISIBLE_DEVICES 变量用来指定可以用来进行测试的显卡,同时修改-g 后的数值。

假设 1 号显卡已经没有显存,那么设置  export CUDA_VISIBLE_DEVICES="0,2,3"

运行:

./build/all_reduce_perf -b 8 -e 128M -f 2 -g 3
mpirun -np 40 ./build/all_reduce_perf -b 8 -e 128M -f 2 -g 3

===========================================================

在容器中安装  nccl 后使用  nccl-tests  测试后报错:

Failed to init nccl communicator for group

 

init nccl communicator for group nccl_world_group

78244:78465 [0] NCCL INFO Call to connect returned Connection timed out, retrying                                                                                                                                                                                            
78244:78466 [1] NCCL INFO Call to connect returned Connection timed out, retrying                                                                                                                                                                                            
78244:78465 [0] NCCL INFO Call to connect returned Connection timed out, retrying                                                                                                                                                                                            
78244:78466 [1] NCCL INFO Call to connect returned Connection timed out, retrying 

很大的可能就是建立容器的时候没有设置允许共享内存:  --ipc=host

解决方案:

重新建立容器,在建立时加入设置:   --ipc=host

形式如:   sudo docker run -it --ipc=host   **************************(其他参数这里不表)

本博客是博主个人学习时的一些记录,不保证是为原创,个别文章加入了转载的源地址还有个别文章是汇总网上多份资料所成,在这之中也必有疏漏未加标注者,如有侵权请与博主联系。
原文地址:https://www.cnblogs.com/devilmaycry812839668/p/15023221.html