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
148

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

NVIDIA/cuda-python 的其他 Issue

查看 NVIDIA/cuda-python 的全部 Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。