Skip to content

Use the CUDA driver for cuda.core device enumeration - #2674

Open
rwgk wants to merge 2 commits into
NVIDIA:mainfrom
rwgk:use_cuda_driver_for_device_enumeration
Open

Use the CUDA driver for cuda.core device enumeration#2674
rwgk wants to merge 2 commits into
NVIDIA:mainfrom
rwgk:use_cuda_driver_for_device_enumeration

Conversation

@rwgk

@rwgk rwgk commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make cuda.core.Device.get_all_devices() enumerate devices through the CUDA driver rather than the NVML system-device list.
  • Use Device.get_all_devices() wherever examples or tests need CUDA-visible devices or a CUDA device count.
  • Convert CUDA devices to cuda.core.system.Device only when querying NVML-backed properties; tests of the raw system API continue to enumerate the complete NVML device list intentionally.

Root cause

CUDA and NVML do not necessarily enumerate the same set of devices. On N1X, NVML reports both the RTX GPU and the NPU, while CUDA exposes only the RTX GPU. Using the NVML count for CUDA device construction therefore makes a system with one CUDA device appear to have two: Device(1) then raises ValueError, and CUDA-oriented process queries against the NPU raise NotSupportedError.

cuda.core.Device represents CUDA-visible compute devices, whereas cuda.core.system.Device represents devices exposed through NVML. This change keeps enumeration within the appropriate domain and uses the existing UUID-based conversion when a CUDA device needs an NVML-backed property.

History

This is a current-main successor to #2533, which was closed after overlapping changes landed on the 13.4.x release line through #2437. The core implementation is therefore already present in 13.4.x and in the ongoing main-to-13.4.x integration under #2641; this PR brings the complete, coherent change to current main.

It preserves the original implementation and commit authorship, resolves the small overlaps with code added since #2533, updates one newer multi-GPU test to follow the same enumeration contract, and regenerates the Device stub.

isVoid and others added 2 commits August 19, 2026 20:54
Update the newer foreign-context test to use the CUDA-visible device count and regenerate the Device stub after applying the original public PR NVIDIA#2533 change.
@rwgk rwgk added this to the cuda.bindings 13.4.0 & 12.9.8 milestone Aug 20, 2026
@rwgk rwgk self-assigned this Aug 20, 2026
@rwgk rwgk added P0 High priority - Must do! cuda.core Everything related to the cuda.core module labels Aug 20, 2026
@rwgk
rwgk requested a review from isVoid August 20, 2026 04:36
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module P0 High priority - Must do!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants