From df8df1ceaffb117f6180d8aa4424c6a8e0aa1b76 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 12 May 2026 12:09:16 -0400 Subject: [PATCH 1/3] Follow-up to #2065: A couple of additional test fixes --- cuda_bindings/tests/nvml/test_pynvml.py | 2 +- cuda_bindings/tests/test_cuda.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cuda_bindings/tests/nvml/test_pynvml.py b/cuda_bindings/tests/nvml/test_pynvml.py index e94fc331381..28c70892949 100644 --- a/cuda_bindings/tests/nvml/test_pynvml.py +++ b/cuda_bindings/tests/nvml/test_pynvml.py @@ -47,7 +47,7 @@ def test_device_get_attributes(mig_handles): if mig_handles: for handle in mig_handles: - att = nvml.device_get_attributes(handle) + att = nvml.device_get_attributes_v2(handle) assert att is not None else: pytest.skip("No MIG devices found") diff --git a/cuda_bindings/tests/test_cuda.py b/cuda_bindings/tests/test_cuda.py index e12d53d9665..94ddf19eda1 100644 --- a/cuda_bindings/tests/test_cuda.py +++ b/cuda_bindings/tests/test_cuda.py @@ -580,7 +580,11 @@ def test_device_get_name(device): # Undeterministic devices get waived pass else: - assert any(got in result for result in expect) + if any(b"Thor" in result for result in expect): + # Thor devices have a different naming scheme + pass + else: + assert any(got in result for result in expect) # TODO: cuStreamGetCaptureInfo_v2 From e519777cec70bfd7faca6c57fa557b6ab9b4a241 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 12 May 2026 12:25:50 -0400 Subject: [PATCH 2/3] Remove redundant test --- cuda_bindings/tests/test_cuda.py | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/cuda_bindings/tests/test_cuda.py b/cuda_bindings/tests/test_cuda.py index 94ddf19eda1..91fbe93827b 100644 --- a/cuda_bindings/tests/test_cuda.py +++ b/cuda_bindings/tests/test_cuda.py @@ -2,7 +2,6 @@ # SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE import ctypes -import platform import shutil import textwrap @@ -560,33 +559,6 @@ def test_get_error_name_and_string(): assert s == b"CUDA_ERROR_INVALID_DEVICE" -@pytest.mark.skipif(not callableBinary("nvidia-smi"), reason="Binary existence needed") -def test_device_get_name(device): - # TODO: Refactor this test once we have nvml bindings to avoid the use of subprocess - import subprocess - - p = subprocess.check_output( - ["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"], # noqa: S607 - shell=False, - stderr=subprocess.PIPE, - ) - - delimiter = b"\r\n" if platform.system() == "Windows" else b"\n" - expect = p.split(delimiter) - size = 64 - _, got = cuda.cuDeviceGetName(size, device) - got = got.split(b"\x00")[0] - if any(b"Unable to determine the device handle for" in result for result in expect): - # Undeterministic devices get waived - pass - else: - if any(b"Thor" in result for result in expect): - # Thor devices have a different naming scheme - pass - else: - assert any(got in result for result in expect) - - # TODO: cuStreamGetCaptureInfo_v2 @pytest.mark.skipif(driverVersionLessThan(11030), reason="Driver too old for cuStreamGetCaptureInfo_v2") def test_stream_capture(): From a2c1f196fe82d6a132752964f8ea462182fbd062 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 12 May 2026 12:44:32 -0400 Subject: [PATCH 3/3] Remove test that NVML devices == CUDA devices --- cuda_core/tests/system/test_system_system.py | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/cuda_core/tests/system/test_system_system.py b/cuda_core/tests/system/test_system_system.py index aa216200625..729e4b26244 100644 --- a/cuda_core/tests/system/test_system_system.py +++ b/cuda_core/tests/system/test_system_system.py @@ -8,12 +8,11 @@ import pytest try: - from cuda.bindings import driver, runtime + from cuda.bindings import driver except ImportError: from cuda import cuda as driver - from cuda import cudart as runtime -from cuda.core import Device, system +from cuda.core import system from cuda.core._utils.cuda_utils import handle_return from .conftest import skip_if_nvml_unsupported @@ -40,15 +39,6 @@ def test_kernel_mode_driver_version(): assert 0 <= ver_patch[0] <= 99 -def test_devices(): - devices = Device.get_all_devices() - expected_num_devices = handle_return(runtime.cudaGetDeviceCount()) - expected_devices = tuple(Device(device_id) for device_id in range(expected_num_devices)) - assert len(devices) == len(expected_devices), "Number of devices does not match expected value" - for device, expected_device in zip(devices, expected_devices): - assert device.device_id == expected_device.device_id, "Device ID does not match expected value" - - def test_kernel_mode_driver_version_requires_nvml(): if system.CUDA_BINDINGS_NVML_IS_COMPATIBLE: pytest.skip("NVML is available, cannot test the error path")