The simple version
A big office has two buildings joined by a bridge. If your printer is in the other building, every page walks across the bridge. NUMA is the two buildings; keeping GPUs, NICs and drives on the same side keeps traffic off the bridge.
NUMA and PCIe
On a two-socket server, each CPU has its own memory and its own PCIe root ports. A device on socket 0 reaching memory or a device on socket 1 must cross the inter-socket link (UPI, Infinity Fabric, …). PCIe switches inside the server can connect GPUs, NICs and drives under the same switch so peer-to-peer traffic never touches a CPU.
Reading nvidia-smi topo -m
| Code | Meaning (from the nvidia-smi legend) | Good for P2P? |
|---|---|---|
| NV# | A bonded set of # NVLinks | Best (GPU↔GPU) |
| PIX | At most a single PCIe bridge | Best PCIe case |
| PXB | Multiple PCIe bridges, not via the host bridge | Good |
| PHB | Through a PCIe host bridge (typically the CPU) | Fair |
| NODE | Between PCIe host bridges within one NUMA node | Fair |
| SYS | Across the SMP interconnect between NUMA nodes | Worst |
The matrix also shows each GPU's CPU and NUMA affinity. NVMe drives aren't in the default matrix; find their node in sysfs.
Finding and fixing placement
$ cat /sys/class/nvme/nvme0/device/numa_node
$ cat /sys/class/infiniband/mlx5_8/device/numa_node
$ lstopo # hwloc: draw the whole topology
$ numactl --hardware
$ numactl --cpunodebind=1 --membind=1 python serve.py # keep a process on node 1
Put a GPU's data on a drive (and use a NIC) on the same NUMA node, and pin its loader processes to that node's CPUs and memory.
Tools
nvidia-smi topo -mGPU/NIC connectivity matrix with CPU and NUMA affinity.
cat /sys/class/nvme/nvmeX/device/numa_nodeWhich NUMA node a drive hangs off.
lstopo / numactl --hardwareWhole-system topology and NUMA layout.
numactl --cpunodebind=N --membind=NRun a process on one NUMA node.
Quiz
Lab
Lab 5.2 · The far-socket GPU
An inference worker pinned to GPU 4 loads its model with GPUDirect Storage from /scratch at about 3.6 GiB/s, while the same load on GPU 0 does about 6.5 GiB/s.
Try it now in the simulator (opens with the command ready; press Enter):
$ nvidia-smi topo -m$ cat /sys/class/nvme/nvme0/device/numa_node$ cat /sys/class/nvme/nvme2/device/numa_node