Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#3,215 0 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@Andy-Jost já está trabalhando nisso.

Desde 28/10/2026.

  • #3220 de @mangeshraut712 — aberto
  • #3277 de @0z5a — aberto

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

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
Linguagem predominante
Cython
Estrelas
3.4k
Forks
341
Merge médio
1d 18h
PRs com merge (30d)
148

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de NVIDIA/cuda-python

Todas as issues de NVIDIA/cuda-python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.