From 57429c49ed1000271ea7b9f1e9e335c6792a104d Mon Sep 17 00:00:00 2001 From: isVoid <13521008+isVoid@users.noreply.github.com> Date: Fri, 18 Sep 2026 17:42:56 +0000 Subject: [PATCH] tests: enumerate CUDA devices for GPU-only system checks --- cuda_core/tests/system/test_system_device.py | 9 ++++++--- cuda_core/tests/system/test_system_events.py | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cuda_core/tests/system/test_system_device.py b/cuda_core/tests/system/test_system_device.py index 03d92a98a20..b52a0cec6d7 100644 --- a/cuda_core/tests/system/test_system_device.py +++ b/cuda_core/tests/system/test_system_device.py @@ -167,7 +167,8 @@ def test_device_name(): def test_device_pci_info(subtests): - for device in system.Device.get_all_devices(): + for cuda_device in CudaDevice.get_all_devices(): + device = cuda_device.to_system_device() with subtests.test(device_index=device.index): pci_info = device.pci_info assert isinstance(pci_info, _device.PciInfo) @@ -684,7 +685,8 @@ def test_clock_event_reasons(subtests): def test_fan(subtests): - for device in system.Device.get_all_devices(): + for cuda_device in CudaDevice.get_all_devices(): + device = cuda_device.to_system_device() device_index = device.index num_fans = None # The fan APIs are only supported on discrete devices with fans, @@ -734,7 +736,8 @@ def test_fan(subtests): def test_cooler(subtests): - for device in system.Device.get_all_devices(): + for cuda_device in CudaDevice.get_all_devices(): + device = cuda_device.to_system_device() with subtests.test(device_index=device.index): # The cooler APIs are only supported on discrete devices with fans, # but when they are not available `device.num_fans` returns 0. diff --git a/cuda_core/tests/system/test_system_events.py b/cuda_core/tests/system/test_system_events.py index 9d02c470188..e8b218325cc 100644 --- a/cuda_core/tests/system/test_system_events.py +++ b/cuda_core/tests/system/test_system_events.py @@ -10,6 +10,7 @@ import helpers import pytest +from cuda.core import Device as CudaDevice from cuda.core import system from cuda.core.system import typing @@ -54,10 +55,12 @@ def test_pci_bus_id_from_gpu_id(gpu_id, expected): def test_system_event_device_resolves_pci_bus_id(): # Round-trip: pack pci_info with the inverse of _pci_bus_id_from_gpu_id, # then resolve Device through SystemEvent.device. - if system.get_num_devices() == 0: - pytest.skip("No GPUs available") + cuda_devices = list(CudaDevice.get_all_devices()) + if not cuda_devices: + pytest.skip("No CUDA devices available") - for device in system.Device.get_all_devices(): + for cuda_device in cuda_devices: + device = cuda_device.to_system_device() pci = device.pci_info if pci.domain > 0xFFFF: pytest.skip(f"PCI domain {pci.domain:#x} does not fit in a packed gpu_id")