Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cuda_bindings/cuda/bindings/_test_helpers/arch_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@


from contextlib import contextmanager
from functools import cache

import pytest

from cuda.bindings import nvml


@cache
def hardware_supports_nvml():
"""
Tries to call the simplest NVML API possible to see if just the basics
works. If not we are probably on one of the platforms where NVML is not
supported at all (e.g. Jetson Orin).
"""
nvml.init_v2()
try:
nvml.system_get_driver_branch()
except (nvml.NotSupportedError, nvml.UnknownError):
return False
else:
return True
finally:
nvml.shutdown()


@contextmanager
def unsupported_before(device: int, expected_device_arch: nvml.DeviceArch | str | None):
device_arch = nvml.device_get_architecture(device)
Expand Down
10 changes: 9 additions & 1 deletion cuda_bindings/tests/nvml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE


import pytest

from cuda.bindings._test_helpers.arch_check import hardware_supports_nvml

if not hardware_supports_nvml():
pytest.skip("NVML not supported on this platform", allow_module_level=True)
Loading