This document provides an overview of how to enable GPUDirect-TCPXO for
optimizing communication in multi-node workloads, such as ML training, by using
NCCL tests to measure NCCL collective
performance between two nodes of an A3 Mega a3-megagpu-8g Slurm cluster.
Before you begin
You must have an A3 Mega Slurm cluster that you created by using
Cluster Toolkit version v1.51.1 or later. To create the cluster, see Deploy
an A3 Mega Slurm cluster for ML
training. A3 Mega
Slurm clusters that are created by using Cluster Toolkit version 1.39.0 or
later have automatic integration of topology-aware scheduling.
Network components
The following components are used to optimize the network performance for
your a3-megagpu-8g Slurm cluster.
- GPUDirect-TCPXO
- GPUDirect-TCPXO is a custom, remote direct memory access (RDMA)
networking stack that increases the network performance of your VMs by
allowing data packet payloads to transfer directly from GPU memory to the
network interface without having to go through the CPU and system memory.
a3-megagpu-8gVMs can use GPUDirect-TCPXO combined with Google Virtual NIC (gVNIC) to deliver higher throughput between VMs in a cluster when compared to the A2 accelerator-optimized machine types on Google Cloud. - The Receive Data Path Manager
To achieve optimal application performance, an additional service called the Receive Data Path Manager (RxDM) runs alongside the applications that use GPUDirect-TCPXO.
Additionally, you must install a NCCL net plugin into the execution environment of the workload. A PyTorch Docker image distributes both the RxDM and the plugin.
- The cluster deployment blueprint
The
examples/machine-learning/a3-megagpu-8g/a3mega-slurm-blueprint.yamlblueprint includes a Slurm prolog and epilog script that runs before and after every job running on more than onea3-megagpu-8gcompute node.The prolog performs the following actions:
- Checks that the
import-helperkernel module is loaded. - Installs the NCCL net plugin into
/var/lib/tcpxo/lib64/of the host. - Runs the RxDM service, which is a long-lived service that runs alongside the
job. Starting the RxDM can take 10-20 seconds, which blocks the start of the
job until the RxDM service is initialized. While the RxDM is starting up,
you won't see the slurm job
output/errorlogs.
The epilog performs the following actions:
- Stops the RxDM service.
- Prunes any stopped containers and frees up disk space.
For more information about prolog and epilog actions, see the Slurm documentation.
- Checks that the
- Use GPUDirect-TCPXO with single-node Slurm jobs
By default, Slurm only launches the RxDM container for multi-node jobs on A3 instances. RxDM is not required for single-node training performance. However, if your job script enables the GPUDirect-TCPXO NCCL plugin, the plugin attempts to connect to RxDM and fails with a timeout error. To resolve this issue, you can choose from the following options:
Modify job scripts for single-node jobs: For jobs that run on a single node, disable the GPUDirect-TCPXO plugin to prevent the timeout. In your job script, set the
NCCL_NET_PLUGINenvironment variable tononeto disable the plugin. We recommend that you set environment variables at the beginning of your job script. For example, add the following line at the start of your script:export NCCL_NET_PLUGIN=noneWith this setting, NCCL falls back to a different network plugin that doesn't require RxDM. For an example of how to define environment variables, see the
run-nccl-tests.shscript.Enable RxDM for all jobs: If you frequently switch between single-node and multi-node jobs and prefer a consistent configuration, modify the Slurm prolog script on your controller node. This script, located at
/opt/apps/adm/slurm/scripts/rxdm, contains the logic for launching RxDM. Update this script to configure it to start the RxDM container for all jobs, regardless of the node count. This configuration makes the use of the GPUDirect-TCPXO plugin transparent to your job scripts.
Connect to the A3 Mega Slurm cluster
To turn on optimized NCCL communication tuning on your cluster, you must sign in to the Slurm login node. To sign in, you can use either Google Cloud console or Google Cloud CLI.
Console
Go to the Compute Engine > VM instances page.
Locate the login node. The node has a name similar to
a3mega-login-001.From the Connect column of the login node, click SSH.
gcloud
To connect to the login node, use the
gcloud compute ssh command.
gcloud compute ssh $(gcloud compute instances list --filter "name ~ login" --format "value(name)") \ --tunnel-through-iap \ --zone ZONE
Create an enroot container
From the login node on your cluster, import a Pytorch image from the NVIDIA container registry.
To import the PyTorch image, use the Slurm srun command from the login node:
srun -N 1 enroot import docker://nvcr.io#nvidia/pytorch:24.04-py3
This runs on one of your a3-megagpu-8g nodes that has more CPU and memory than
the login node, which enroot can use to more quickly import the container.
When the import completes, you should have a file named
nvidia+pytorch+24.04-py3.sqsh in the directory where you ran the command.
Build NCCL test
Next, build the NCCL-test binaries by running the following command from the same directory as the previous step:
CONTAINER_IMAGE=./nvidia+pytorch+24.04-py3.sqsh
git clone https://github.com/NVIDIA/nccl-tests.git
srun --partition a3mega \
--ntasks-per-node=1 \
--gpus-per-node=8 \
--container-mounts="$PWD:/nccl" \
--container-image=${CONTAINER_IMAGE} \
bash -c "
cd /nccl/nccl-tests/ &&
MPI=1 CC=mpicc CXX=mpicxx make -j
"
This creates a directory named nccl-tests. The preceding command uses
--container-mounts to mount your current working directory $PWD into the
/nccl directory inside the container. After the srun command finishes,
verify that the nccl-tests/build folder contains several binaries, including
all_gather_perf.
Run a NCCL test
As part of the cluster deployment process, Slurm prolog and epilog scripts are
installed that automatically install a custom libnccl-net.so library and start
a sidecar process to enable GPUDirect-TCPXO optimized communication.
To run any job on an A3 Mega cluster, you must set several environment variables to turn on high-performance networking with GPUDirect-TCPXO. Because you use enroot containers in this procedure to launch workloads, you must set these variables in the container environment instead of the host environment.
To run the NCCL test, complete the following steps.
Use a text editor to create a file named
run-nccl-tests.shand add the following content to the file.Submit the script.
sbatch run-nccl-tests.sh
This results in a
slurm-XX.outfile that contains the results of the ncclall_gather_perfbenchmark.The output is similar to the following:
# # 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) 268435456 4194304 float none -1 XXXXX XXX.XX XXX.XX N/A XXXXXX XXX.XX XXX.XX N/A 536870912 8388608 float none -1 XXXXX XXX.XX XXX.XX N/A XXXXXX XXX.XX XXX.XX N/A 1073741824 16777216 float none -1 XXXXX XXX.XX XXX.XX N/A XXXXXX XXX.XX XXX.XX N/A 2147483648 33554432 float none -1 XXXXX XXX.XX XXX.XX N/A XXXXXX XXX.XX XXX.XX N/A 4294967296 67108864 float none -1 XXXXX XXX.XX XXX.XX N/A XXXXXX XXX.XX XXX.XX N/A 8589934592 134217728 float none -1 XXXXX XXX.XX XXX.XX N/A XXXXXX XXX.XX XXX.XX N/A # Out of bounds values : 0 OK # Avg bus bandwidth : XXX.XX #