Skip to main content

get_device_numa_node

Function get_device_numa_node 

Source
pub fn get_device_numa_node(device_id: u32) -> NumaNode
Expand description

Get NUMA node for a GPU device.

For GPU memory, the NUMA affinity depends on which PCIe bus the GPU is attached to. This is queried via nvidia-smi. Falls back to a heuristic (device_id % 2) if nvidia-smi is unavailable.

When CUDA_VISIBLE_DEVICES is set, the process-local device_id is correctly mapped to the physical GPU identifier before querying nvidia-smi, so NUMA attribution is accurate.

§Arguments

  • device_id - CUDA device index (0, 1, 2, …) as seen by the process

§Returns

The NUMA node closest to the specified GPU, or a heuristic fallback.