﻿# Join rank-local GPU ordinals to the selected NIC

Resolve each worker CUDA ordinal to a stable GPU identity before evaluating the NIC path selected by its NCCL communicator.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/nccl-gpu-nic-affinity-path/
Language: en

## Every worker reports the first GPU

Several training processes each report that they use their first visible CUDA device. An administrator joins all of those records to the first physical GPU in the host inventory, then concludes that their selected NICs are local. The join is invalid when process visibility differs. A process-local ordinal is an index within that process's enumeration, not an unqualified physical identity shared by all workers.

## Resolve enumeration inside the worker

The [CUDA environment reference](https://docs.nvidia.com/cuda/cuda-programming-guide/05-appendices/environment-variables.html) documents that visibility controls both which devices appear and their enumeration order. Preserve the effective visibility setting and resolve the selected ordinal to a stable GPU identity and PCI address from the worker's actual context. Do not reconstruct that mapping from an administrator's differently filtered shell. A changed device order or container allocation can change the physical meaning of an unchanged local ordinal without changing the application's configured number.

## Join to the communicator's network choice

Use the [NCCL logging contract](https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/troubleshooting/logging.html) to obtain network assignment evidence for the intended rank and communicator. Connect the selected HCA and port to their physical identity and topology location. The result should have a traceable chain from rank to local CUDA ordinal, physical GPU, selected NIC and port. A list of nearby GPUs and a separate list of active NICs does not establish that the library selected the desired pair for this worker.

## Verify what topology the process sees

The [NCCL GPU troubleshooting guide](https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/troubleshooting/gpu_troubleshooting.html) explains reliance on sysfs for GPU and network-card topology discovery and warns about virtualized or incomplete topology views. Compare the worker-visible representation with the approved host arrangement. A favorable host-level tree cannot certify a container whose view exposes another relationship. Keep namespace, mounts, driver and virtualization context with the evidence, without changing isolation or disabling platform protections merely to make a topology label look shorter.

## Acceptance uses the mapped pair

In an isolated equivalent, verify useful communication for the selected pair and compare any justified placement alternative while holding payloads, ranks and accepted work constant. Preserve direction because send and receive paths can differ. If locality changes but performance does not, record that result rather than inventing a topology benefit. Acceptance establishes correct identity mapping and a qualified communication path; it does not require every process to choose the same NIC or assume that nearest always wins under concurrent traffic.

## Keep capability separate from selection

Physical proximity is not proof of direct-access capability, memory registration or actual transfer rate. The [shared PCIe investigation](/journal/gpu-shared-pcie-root-contention/) addresses concurrent resource pressure after identity is established, while [directed GPU capability checks](/journal/gpu-peer-access-matrix/) illustrate why capability and observed transfer are different findings. Save the complete join with a configuration generation so later device replacement cannot silently relabel history. This prevents a local ordinal from becoming a misleading fleet-wide hardware identity and keeps affinity claims tied to the worker that actually ran.
