本页面介绍了如何使用 Debian 软件包 (.deb) 或 Red Hat 软件包管理器 (.rpm) 安装 NCCL/gIB。安装完成后,您可以在 A3 Ultra、A4 和 A4X 虚拟机 (VM) 实例上运行 NCCL 测试(以下示例适用于 2 节点测试)。
如需在 A3 Mega 和 A3 High 上运行 NCCL 测试,请参阅创建启用了 GPUDirect 的 A3 Mega 或 A3 High 实例。
如果您使用 Cluster Director、Cluster Toolkit 或 GKE 等调度器,则无需按照本页面中的步骤操作。请改为参阅以下内容:
- 在采用默认配置的 GKE 集群上运行 NCCL
- 在采用 A4X 的自定义 GKE 集群上运行 NCCL
- 在采用 A4 或 A3 Ultra 的自定义 GKE 集群上运行 NCCL
- 在 Slurm 集群上运行 NCCL 测试
- 在 Cluster Director 中对 Slurm 集群运行 NCCL 测试
安装 nccl-gib
根据工作负载的运行位置,您可以在 guest 虚拟机或容器映像中安装 NCCL/gIB。
nccl-gib 软件包与未修改的 NVidia NCCL 库 (libnccl2.so) 和标头捆绑在一起。所有 NCCL/gIB 内容都安装到 /usr/local/gib 目录中。某些依赖项也会通过分发的代码库进行提取。
Debian 12+/Ubuntu 20.04+(.deb 软件包)
# If you're not using an image from Google, trust the Google Cloud signing key curl http://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/cloud.google.gpg # Add gpudirect-gib-apt repo echo 'deb https://packages.cloud.google.com/apt gpudirect-gib-apt main' | sudo tee /etc/apt/sources.list.d/nccl-gib.list sudo apt update sudo apt install nccl-gib
RockyLinux/CentOS/RHEL 9+(.rpm 软件包)
# Add gpudirect-gib-rpm repo sudo tee -a /etc/yum.repos.d/nccl-gib.repo << EOL [gpudirect-gib-rpm] name=NCCL/gIB baseurl=https://packages.cloud.google.com/yum/repos/gpudirect-gib-rpm enabled=1 repo_gpgcheck=0 gpgcheck=0 sudo dnf makecache sudo dnf install nccl-gib
如果您使用的是标准操作系统映像,还必须安装最新的 NVIDIA DOCA-OFED 驱动程序。如果您使用的是 Google 的 A* 优化映像(例如 Container OS 或客机加速器 Ubuntu/RockyLinux OS 映像),则无需安装此驱动程序。
为避免虚拟机运行不同版本的 nccl-gib 软件包,我们建议您在运行 NCCL 工作负载之前更新 nccl-gib,或停用无人值守升级。
使用 NCCL/gIB
如需在工作负载中启用 NCCL/gIB,请确保满足以下条件:
/usr/local/gib/scripts/set_nccl_env.sh来源于您的运行时环境。源文件包含 NCCL/gIB 所需的所有环境变量,Google 希望在未来的 NCCL/gIB 版本中更新这些变量。/usr/local/gib/lib64目录位于LD_LIBRARY_PATH中。
如需验证 NCCL/gIB 是否已启用,请检查是否存在以下 NCCL INFO 级日志条目:
# A sample log entry from NCCL core
vm-0:606:642 [6] NCCL INFO Using network gIB
# A sample log entry from the gIB network plugin
vm-0:606:642 [6] NCCL INFO NET/gIB : Initializing gIB v1.0.5
运行 NCCL 测试
如需了解如何在调度环境中运行 NCCL 测试,请参阅以下内容:
- 在采用默认配置的 GKE 集群上运行 NCCL
- 在采用 A4X 的自定义 GKE 集群上运行 NCCL
- 在采用 A4 或 A3 Ultra 的自定义 GKE 集群上运行 NCCL
- 在 Slurm 集群上运行 NCCL 测试
- 在 Cluster Director 中对 Slurm 集群运行 NCCL 测试
我们还发布了一个诊断容器映像,其中包含所有内容,网址为 http://us-docker.pkg.dev/gce-ai-infra/gpudirect-gib/nccl-plugin-gib-diagnostic:latest。
如需在非调度环境中运行 NCCL 测试,请执行以下操作:
- 安装 cuda-12.8(或更高版本)和 openmpi
- 在虚拟机之间设置非交互式 SSH 登录
- 构建启用了 MPI 的 nccl-tests。构建 nccl-tests 时,设置了
NCCL_HOME=/usr/local/gib
如需运行随 NCCL/gIB 软件包提供的脚本,请执行以下操作:
# The script assumes binaries at /opt/nccl-tests/build/
$ /usr/local/gib/scripts/run_nccl_tests.sh -d /opt/nccl-tests/build/ -p 22 -t all_gather -m 0x0 -b 4K -e 16G a4-vm-1 a4-vm-2
在两台 A4 虚拟机上的输出示例:
NCCL version 2.25.1+cuda12.8
#
# out-of-place in-place
# size count type redop root time algbw busbw #wrong time algbw busbw #wrong
# (B) (elements) (us) (GB/s) (GB/s) (us) (GB/s) (GB/s)
4096 64 float none -1 59.97 0.07 0.06 0 57.49 0.07 0.07 0
8192 128 float none -1 58.17 0.14 0.13 0 58.36 0.14 0.13 0
16384 256 float none -1 59.07 0.28 0.26 0 59.03 0.28 0.26 0
32768 512 float none -1 60.93 0.54 0.50 0 60.79 0.54 0.51 0
65536 1024 float none -1 61.93 1.06 0.99 0 62.17 1.05 0.99 0
131072 2048 float none -1 64.62 2.03 1.90 0 64.48 2.03 1.91 0
262144 4096 float none -1 66.50 3.94 3.70 0 67.05 3.91 3.67 0
524288 8192 float none -1 69.37 7.56 7.09 0 67.83 7.73 7.25 0
1048576 16384 float none -1 117.2 8.95 8.39 0 113.7 9.22 8.64 0
2097152 32768 float none -1 118.8 17.65 16.55 0 118.1 17.75 16.64 0
4194304 65536 float none -1 122.2 34.32 32.17 0 122.6 34.22 32.08 0
8388608 131072 float none -1 132.2 63.44 59.48 0 130.7 64.20 60.18 0
16777216 262144 float none -1 139.2 120.49 112.96 0 139.7 120.07 112.56 0
33554432 524288 float none -1 152.0 220.81 207.01 0 152.1 220.59 206.81 0
67108864 1048576 float none -1 227.6 294.87 276.44 0 225.9 297.08 278.51 0
134217728 2097152 float none -1 431.7 310.87 291.44 0 438.0 306.41 287.26 0
268435456 4194304 float none -1 728.6 368.44 345.41 0 735.9 364.79 341.99 0
536870912 8388608 float none -1 1404.2 382.33 358.44 0 1418.4 378.51 354.85 0
1073741824 16777216 float none -1 2795.8 384.06 360.05 0 2768.9 387.79 363.55 0
2147483648 33554432 float none -1 5440.1 394.75 370.08 0 5418.7 396.31 371.54 0
4294967296 67108864 float none -1 10754 399.40 374.43 0 10746 399.67 374.69 0
8589934592 134217728 float none -1 21434 400.77 375.72 0 21421 401.01 375.95 0
17179869184 268435456 float none -1 42679 402.53 377.38 0 42792 401.48 376.38 0
后续步骤
- 收集并了解 NCCL 日志以进行问题排查,了解测试输出并排查问题。
- 监控 Compute Engine 实例和 Slurm 集群。
- 了解如何排查性能缓慢问题。