[BUG]: multi-GPU cuda.core samples take the CUDA device count from NVML and break under CUDA_VISIBLE_DEVICES
Mantenedores costumam responder em até 1 dia
@Andy-Jost já está trabalhando nisso.
Desde 28/10/2026.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- python
Direção de pesquisa
Leia samples/cuda_core/simpleP2P/simpleP2P.py, simpleMultiGpu e multiGPUGradientAverage e, em seguida, compare o uso da contagem de dispositivos com Device.get_all_devices() e systemInfo. Atualize os três exemplos e as duas linhas do README descritas na issue; o trabalho estará concluído quando as contagens de GPUs visíveis em um subconjunto funcionarem nos exemplos e systemInfo mantiver a contagem de todo o sistema do NVML. A issue informa que multiGPUGradientAverage não foi verificado porque mpi4py estava ausente.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Cython
- Estrelas
- 3.4k
- Forks
- 341
- Merge médio
- 1d 18h
- PRs com merge (30d)
- 148
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de NVIDIA/cuda-python
-
CI/CD P1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
NVIDIA/cuda-python#3273 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[BUG]: cuda.bindings GL interop tests open EGL device 0 on headless multi-GPU hosts and fail with cudaErrorInvalidDeviceTalvez já em andamento @0z5a assumiu há 1 dia. Abertatriage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
NVIDIA/cuda-python#3212 ·
Mantenedores costumam responder em até 1 dia
-
lychee should specify which links are failingTalvez já em andamento @kkonnerharris assumiu há 2 dias. Abertatriage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
NVIDIA/cuda-python#3204 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[BUG]: cleanup-pr-previews never removes previews of deleted PRsTalvez já em andamento @rwgk assumiu há 22 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
NVIDIA/cuda-python#2952 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
[DOC]: cuda.core 1.1.1 note misstates program cache permissionsTalvez já em andamento @leofang assumiu há 36 dias. Abertadocumentation P1
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
NVIDIA/cuda-python#2717 · 1 responsável ·
Mantenedores costumam responder em até 1 dia