Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG]: multi-GPU cuda.core samples take the CUDA device count from NVML and break under CUDA_VISIBLE_DEVICES

Aperta Adatta ai principianti
#3,215 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Andy-Jost ci sta già lavorando.

Dal 28/10/2026.

  • #3220 di @mangeshraut712 — chiusa senza merge
  • #3277 di @0z5a — aperta

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

bug cuda.core P2
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:

  • multiGPUGradientAverage maps rank % num_gpus, so it can pick a device that is not visible.
  • simpleMultiGpu only uses Device(0) and Device(1), so it survives, but its README describes system.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: simpleP2P fails and simpleMultiGpu passes.
  • 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/cuda-python

Tutte le issue di NVIDIA/cuda-python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.