Skip to main content
AI on Kubernetes · GPU/NPULesson 7 of 20

Moving Data Between GPUs

Distributed training stops to exchange gradients at every step, so the network between GPUs sets the pace. Follow the data from one GPU to another, first inside a node and then across nodes, and see how Kubernetes hands an RDMA NIC to a Pod.

Pathall-reduce across 4 GPUs
NCCL transport—
CPU copies—
GPU node AGPU node BGPU 0rank 0GPU 1rank 1GPU 0rank 2GPU 1rank 3NVSwitchNVLink fabricNVSwitchNVLink fabricPCIe switchGPU + NICPCIe switchGPU + NICCPU + kernelhost memory · TCPCPU + kernelhost memory · TCPNIC 0RDMANIC 1RDMANIC 0RDMANIC 1RDMARail 0 switchIB or RoCE leafRail 1 switchIB or RoCE leafPod networkprimary CNI · eth0Network Operatordrivers · pluginsgradientsgradients
RequestWatchAppears in a later step

What you will learn

  • NVLink and NVSwitch versus PCIe inside one node
  • RDMA over InfiniBand or RoCE v2 skips the CPU and kernel
  • GPUDirect RDMA and rail-optimized topology
  • Why RoCE needs lossless Ethernet with PFC and ECN
  • RDMA NICs in Pods with Multus, device plugins or DRA
  • Spotting an NCCL fallback to TCP sockets

Symptoms and causes​

SymptomLikely causeCheck
NCCL log shows NET/SocketNo RDMA device in the Pod, or NCCL_IB_DISABLE=1ibv_devinfo inside the Pod, resource requests, Multus annotation
RDMA device present, NCCL still fails to register memoryMemory cannot be pinnedIPC_LOCK capability, ulimit -l in the container
NET/IB but no GDRDMAGPUDirect RDMA not enabled, or GPU and NIC far apartnvidia-peermem or DMA-BUF support, nvidia-smi topo -m
RoCE works at low load, collapses at scalePFC or ECN not set the same on all hopsPause and ECN counters on NICs and switches
RoCE connections fail or hangWrong GID index or RoCE versionNCCL_IB_GID_INDEX, GID table of the device
Intra-node all-reduce slowNo NVLink path, traffic crosses socketsnvidia-smi topo -m, nvidia-smi nvlink --status
One slow node drags the whole jobBad cable, link down to lower speed, or a degraded portibstat or ethtool link speed, per-node all_reduce_perf

Try it yourself​

nvidia-smi topo -m # NV# = NVLink, PIX/PXB = same PCIe switch, SYS = across CPU sockets
ibv_devinfo # RDMA devices, state PORT_ACTIVE, link_layer InfiniBand or Ethernet
kubectl get network-attachment-definitions -A # secondary networks Multus can attach
kubectl get node gpu-node-1 -o jsonpath='{.status.allocatable}' # GPU and RDMA resources
kubectl exec trainer-0 -- ip -br addr # eth0 from the primary CNI, net1 from Multus

# RDMA bandwidth between two Pods (perftest), using GPU memory on both ends
kubectl exec trainer-0 -- ib_write_bw -d mlx5_0 --use_cuda=0 -a # server
kubectl exec trainer-1 -- ib_write_bw -d mlx5_0 --use_cuda=0 -a 10.10.0.11 # client, server net1 IP

# NCCL all-reduce across 2 nodes x 8 GPUs (nccl-tests built with MPI=1)
mpirun -np 16 -N 8 -x NCCL_DEBUG=INFO -x NCCL_DEBUG_SUBSYS=INIT,NET \
./build/all_reduce_perf -b 8 -e 8G -f 2 -g 1 2>&1 | grep -E 'NET/|busbw|GDRDMA'

Check yourself

  1. A training job runs without errors but each step is many times slower than expected. NCCL_DEBUG=INFO shows NET/Socket. What does that tell you?
  2. What does GPUDirect RDMA remove compared with plain RDMA?
  3. Why does a RoCE v2 fabric need PFC and ECN, while InfiniBand does not need them?

Further reading: NCCL environment variables · GPUDirect RDMA · NVIDIA Network Operator · nccl-tests · Multus CNI · Training One Model on Many GPUs · Requesting GPUs by Criteria (DRA) · Monitoring GPUs on Kubernetes