[BUG]: multi-GPU cuda.core samples take the CUDA device count from NVML and break under CUDA_VISIBLE_DEVICES
メンテナーはふだん 1 日以内に返信
@Andy-Jost がすでに取り組んでいます。
2026年10月28日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
samples/cuda_core/simpleP2P/simpleP2P.py、simpleMultiGpu、multiGPUGradientAverageを読み、デバイス数の使用方法をDevice.get_all_devices()およびsystemInfoと比較してください。issueに記載された3つのサンプルとREADMEの2行を更新してください。サンプルでサブセット内の可視GPU数が機能し、systemInfoがNVMLのシステム全体の数を保持すれば完了です。issueによると、mpi4pyが不足していたためmultiGPUGradientAverageは検証されていません。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Cython
- スター
- 3.4k
- フォーク
- 341
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 147
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/cuda-python のほかの issue
-
CI/CD P1
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/cuda-python#3273 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]: cuda.bindings GL interop tests open EGL device 0 on headless multi-GPU hosts and fail with cudaErrorInvalidDevice対応中かも @0z5a が 1 日前に担当しました。 オープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/cuda-python#3212 ·
メンテナーはふだん 1 日以内に返信
-
lychee should specify which links are failing対応中かも @kkonnerharris が 2 日前に担当しました。 オープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
NVIDIA/cuda-python#3204 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]: cleanup-pr-previews never removes previews of deleted PRs対応中かも @rwgk が 22 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
NVIDIA/cuda-python#2952 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[BUG]: LocatedHeaderDir is mutable, so callers can poison the cached header-directory lookup対応中かも @rwgk が 36 日前に担当しました。 オープンtriage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NVIDIA/cuda-python#2646 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信