Skip to content

Commit 1a1dd19

Browse files
committed
Defer CUDA 12 NVML test maintenance to CI integration
Signed-off-by: Ralf W. Grosse-Kunstleve <rgrossekunst@nvidia.com>
1 parent 7b21246 commit 1a1dd19

4 files changed

Lines changed: 24 additions & 36 deletions

File tree

‎cuda_bindings_12/tests/nvml/test_cuda.py‎

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
import pytest
5-
64
import cuda.bindings.driver as cuda
75
from cuda.bindings import nvml
86

@@ -17,15 +15,10 @@ def get_nvml_device_names():
1715
for idx in range(num_devices):
1816
handle = nvml.device_get_handle_by_index_v2(idx)
1917
name = nvml.device_get_name(handle)
20-
try:
21-
info = nvml.device_get_pci_info_v3(handle)
22-
except nvml.NotSupportedError:
23-
bus_id = -1
24-
else:
25-
bus_id = info.bus
26-
assert isinstance(bus_id, int)
18+
info = nvml.device_get_pci_info_v3(handle)
19+
assert isinstance(info.bus, int)
2720
assert isinstance(name, str)
28-
result.append({"name": name, "id": bus_id})
21+
result.append({"name": name, "id": info.bus})
2922

3023
return result
3124

@@ -61,15 +54,4 @@ def test_cuda_device_order():
6154
cuda_devices = get_cuda_device_names()
6255
nvml_devices = get_nvml_device_names()
6356

64-
for kind in ("Orin", "Thor"):
65-
if any(kind in device["name"] for device in nvml_devices):
66-
pytest.skip(f"Skipping test on {kind}, which has non-standard device naming")
67-
68-
def compare(cuda_device, nvml_device):
69-
return cuda_device["name"] == nvml_device["name"] and (
70-
nvml_device["id"] == -1 or cuda_device["id"] == nvml_device["id"]
71-
)
72-
73-
assert len(cuda_devices) <= len(nvml_devices)
74-
for cuda_device in cuda_devices:
75-
assert any(compare(cuda_device, nvml_device) for nvml_device in nvml_devices)
57+
assert cuda_devices == nvml_devices, "CUDA and NVML device lists do not match"

‎cuda_bindings_12/tests/nvml/test_init.py‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66

77
import pytest
88

9-
from cuda.bindings import driver, nvml
10-
11-
12-
def _driver_version_at_least_13_4():
13-
(status,) = driver.cuInit(0)
14-
assert status == driver.CUresult.CUDA_SUCCESS
15-
status, version = driver.cuDriverGetVersion()
16-
assert status == driver.CUresult.CUDA_SUCCESS
17-
return version >= 13040
9+
from cuda.bindings import nvml
1810

1911

2012
def assert_nvml_is_initialized():
@@ -44,14 +36,10 @@ def test_devices_are_the_same_architecture(all_devices):
4436

4537

4638
@pytest.mark.skipif(sys.platform == "win32", reason="Test not supported on Windows")
47-
@pytest.mark.thread_unsafe(reason="nvml init affects other threads")
4839
def test_init_ref_count():
4940
"""
5041
Verifies that we can call NVML shutdown and init(2) multiple times, and that ref counting works
5142
"""
52-
if _driver_version_at_least_13_4():
53-
pytest.skip("Init behavior changed in CUDA 13.4")
54-
5543
with pytest.raises(nvml.UninitializedError):
5644
nvml.shutdown()
5745

‎cuda_bindings_12/tests/nvml/test_pynvml.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# A set of tests ported from https://github.com/gpuopenanalytics/pynvml/blob/11.5.3/pynvml/tests/test_nvml.py
55

66
import os
7+
import time
8+
79
import pytest
810

911
from cuda.bindings import nvml
@@ -145,6 +147,22 @@ def test_device_get_power_usage(ngpus, handles):
145147
assert power_mwatts >= 0.0
146148

147149

150+
def test_device_get_total_energy_consumption(ngpus, handles):
151+
for i in range(ngpus):
152+
with unsupported_before(handles[i], nvml.DeviceArch.VOLTA):
153+
energy_mjoules1 = nvml.device_get_total_energy_consumption(handles[i])
154+
155+
for j in range(10): # idle for 150 ms
156+
time.sleep(0.015) # and check for increase every 15 ms
157+
with unsupported_before(handles[i], nvml.DeviceArch.VOLTA):
158+
energy_mjoules2 = nvml.device_get_total_energy_consumption(handles[i])
159+
assert energy_mjoules2 >= energy_mjoules1
160+
if energy_mjoules2 > energy_mjoules1:
161+
break
162+
else:
163+
raise AssertionError("energy did not increase across 150 ms interval")
164+
165+
148166
# [Skipping] pynvml.nvmlDeviceGetGpuOperationMode
149167
# [Skipping] pynvml.nvmlDeviceGetCurrentGpuOperationMode
150168
# [Skipping] pynvml.nvmlDeviceGetPendingGpuOperationMode

‎cuda_bindings_12/tests/nvml/util.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ def supports_ecc(device):
4343

4444
def supports_nvlink(device):
4545
fields = nvml.FieldValue(1)
46-
fields[0].field_id = nvml.FieldId.DEV_NVLINK_GET_STATE
46+
fields[0].field_id = nvml.FI.DEV_NVLINK_GET_STATE
4747
return nvml.device_get_field_values(device, fields)[0].nvml_return == nvml.Return.SUCCESS

0 commit comments

Comments
 (0)