nccl

NCCL 多卡通信与测试

补充说明

NCCL 是 NVIDIA 的多 GPU 通信库,负责 AllReduce、Broadcast、AllGather 等集合通信。分布式训练性能问题经常出在 NCCL 拓扑、网卡选择或 P2P 访问上。

常用示例

编译并运行 nccl-tests:

git clone https://github.com/NVIDIA/nccl-tests.git
cd nccl-tests
make MPI=1 MPI_HOME=/usr/lib/x86_64-linux-gnu/openmpi

单机多卡 AllReduce:

./build/all_reduce_perf -b 8 -e 8G -f 2 -g 8

多机测试:

mpirun -np 16 -hostfile hosts \
  ./build/all_reduce_perf -b 8 -e 8G -f 2 -g 8

指定网卡:

export NCCL_SOCKET_IFNAME=eth0
export NCCL_IB_HCA=mlx5_0

开启调试日志:

export NCCL_DEBUG=INFO
export NCCL_DEBUG_SUBSYS=ALL

易错点与排错