Skip to content

Commit 1e0ae86

Browse files
mdboomCopilot
andauthored
Skip NVML tests if the hardware doesn't support NVML (#1585) (#1749)
* Skip NVML tests if the hardware doesn't support NVML * Also skip converting between Device types * Fix test_to_system_device test * Update cuda_bindings/cuda/bindings/_test_helpers/arch_check.py * Fix test * Simplify check * Fix import when cuda_bindings is incompatible * Fix logic * Move over a single test from #1583 * Fix check --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 25e95e9 commit 1e0ae86

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

cuda_bindings/cuda/bindings/_test_helpers/arch_check.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,31 @@
33

44

55
from contextlib import contextmanager
6+
from functools import cache
67

78
import pytest
89

910
from cuda.bindings import nvml
1011

1112

13+
@cache
14+
def hardware_supports_nvml():
15+
"""
16+
Tries to call the simplest NVML API possible to see if just the basics
17+
works. If not we are probably on one of the platforms where NVML is not
18+
supported at all (e.g. Jetson Orin).
19+
"""
20+
nvml.init_v2()
21+
try:
22+
nvml.system_get_driver_branch()
23+
except (nvml.NotSupportedError, nvml.UnknownError):
24+
return False
25+
else:
26+
return True
27+
finally:
28+
nvml.shutdown()
29+
30+
1231
@contextmanager
1332
def unsupported_before(device: int, expected_device_arch: nvml.DeviceArch | str | None):
1433
device_arch = nvml.device_get_architecture(device)
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+
5+
import pytest
6+
7+
from cuda.bindings._test_helpers.arch_check import hardware_supports_nvml
8+
9+
if not hardware_supports_nvml():
10+
pytest.skip("NVML not supported on this platform", allow_module_level=True)

0 commit comments

Comments
 (0)