[BUG]: multi-GPU cuda.core samples take the CUDA device count from NVML and break under CUDA_VISIBLE_DEVICES
I maintainer di solito rispondono entro 1 giorno
@Andy-Jost ci sta già lavorando.
Dal 28/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
Direzione di ricerca
Leggi samples/cuda_core/simpleP2P/simpleP2P.py, simpleMultiGpu e multiGPUGradientAverage, poi confronta il loro uso del conteggio dei dispositivi con Device.get_all_devices() e systemInfo. Aggiorna i tre esempi e le due righe del README descritte nell’issue; il lavoro è completato quando negli esempi funzionano i conteggi delle GPU visibili in un sottoinsieme e systemInfo mantiene il conteggio NVML a livello di sistema. L’issue segnala che multiGPUGradientAverage non è stato verificato perché mancava mpi4py.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is this a duplicate?
- I confirmed there appear to be no duplicate issues for this bug and that I agree to the Code of Conduct
Type of Bug
Runtime Error
Component
cuda.core
Describe the bug
samples/cuda_core/simpleP2P, simpleMultiGpu and multiGPUGradientAverage size their device lists with cuda.core.system.get_num_devices(). That function returns nvml.device_get_count_v2(), which counts every GPU on the system and ignores CUDA_VISIBLE_DEVICES. On an 8-GPU B300 host with two GPUs visible, simpleP2P reports 8 devices and then fails on Device(2):
CUDA-capable device count: 8
ValueError: device_id must be within [0, 2), got 2
The other two samples are affected the same way:
multiGPUGradientAveragemapsrank % num_gpus, so it can pick a device that is not visible.simpleMultiGpuonly usesDevice(0)andDevice(1), so it survives, but its README describessystem.get_num_devices()as the "count of visible CUDA devices", which it is not.
This turns up whenever a job gets a subset of a node's GPUs: shared clusters, schedulers, or CI runners that pin devices. The nightly rows are single-GPU, so they skip these samples.
How to Reproduce
CUDA_VISIBLE_DEVICES=<two of the GPUs> python samples/cuda_core/simpleP2P/simpleP2P.py
Expected behavior
The samples count the CUDA devices the process can use (len(Device.get_all_devices())), so they work when CUDA_VISIBLE_DEVICES selects a subset of the GPUs.
Proposed fix
Count CUDA devices with len(Device.get_all_devices()) in the three samples and fix the two README lines. system.get_num_devices() stays the right call in systemInfo, which reports NVML's view. I have the change ready. With two of the eight GPUs visible:
- Before:
simpleP2Pfails andsimpleMultiGpupasses. - After: both pass.
multiGPUGradientAverage was skipped in both runs because mpi4py was missing, so it is not verified.
The fix was written with Claude Opus 5.5 and reviewed by the contributor.
Environment
GPU: B300 (cc 10.3, x86_64, 8 GPUs, 2 visible) | driver 610.57.04 | CUDA 13.4.2 (local CTK) | Python 3.12 | cuda-python 2da9c65a
- Lingua principale
- Cython
- Stelle
- 3.4k
- Fork
- 341
- Merge medio
- 1g 18h
- PR unite (30g)
- 147
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di NVIDIA/cuda-python
-
CI/CD P1
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA/cuda-python#3273 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: cuda.bindings GL interop tests open EGL device 0 on headless multi-GPU hosts and fail with cudaErrorInvalidDeviceForse già presa @0z5a l’ha presa 2 giorni fa. Apertatriage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NVIDIA/cuda-python#3212 ·
I maintainer di solito rispondono entro 1 giorno
-
lychee should specify which links are failingForse già presa @kkonnerharris l’ha presa 2 giorni fa. Apertatriage
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
NVIDIA/cuda-python#3204 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: cleanup-pr-previews never removes previews of deleted PRsForse già presa @rwgk l’ha presa 22 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
NVIDIA/cuda-python#2952 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookupForse già presa @rwgk l’ha presa 37 giorni fa. Apertatriage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NVIDIA/cuda-python#2646 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno