Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭 适合新手
#3,215 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@Andy-Jost 已经在做这个了。

开始于 2026年10月28日。

  • #3220 来自 @mangeshraut712 —— 已关闭,未合并
  • #3277 来自 @0z5a —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

阅读 samples/cuda_core/simpleP2P/simpleP2P.py、simpleMultiGpu 和 multiGPUGradientAverage,然后将它们使用的设备数量与 Device.get_all_devices() 和 systemInfo 进行比较。更新 issue 中描述的三个示例和 README 的两行;当示例中的子集可见 GPU 数量正常工作,且 systemInfo 保留 NVML 的系统范围数量时,任务即告完成。issue 报告称,由于缺少 mpi4py,multiGPUGradientAverage 未经验证。

由索引模型根据 Issue 内容生成。

描述

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
主要语言
Cython
星标
3.4k
派生
341
平均合并
1 天 18 小时
30 天内合并 PR
147

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/cuda-python 的其他 Issue

查看 NVIDIA/cuda-python 的全部 Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。