Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの 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 件 担当者 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に記載された3つのサンプルとREADMEの2行を更新してください。サンプルでサブセット内の可視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時間
マージ済み PR(30日)
147

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/cuda-python のほかの issue

NVIDIA/cuda-python の issue をすべて見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。