Skip to content

Commit 27f7a62

Browse files
committed
Skip tests without NVML
1 parent 50e63b8 commit 27f7a62

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

cuda_core/cuda/core/experimental/system/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313
"get_process_name",
1414
]
1515

16-
try:
16+
17+
import cuda.bindings
18+
19+
from .system import *
20+
21+
# We need both the existence of cuda.bindings._nvml and a sufficient version
22+
# with the APIs implemented as we need them.
23+
24+
if tuple(int(x) for x in cuda.bindings.__version__.split(".")) >= (13, 1, 1):
1725
from cuda.bindings import _nvml
18-
except ImportError:
19-
# Support the earlier non-NVML implementation of these methods if we
20-
# have cuda.bindings < 13.1.1
2126

22-
from .system import *
23-
else:
2427
from ._nvml_context import initialize
2528
from .device import Device, DeviceArchitecture
26-
from .system import *
2729

2830
initialize()
2931

cuda_core/tests/system/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0

cuda_core/tests/system/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
import cuda.bindings
7+
import pytest
8+
9+
CUDA_BINDINGS_VERSION = tuple(int(x) for x in cuda.bindings.__version__.split("."))
10+
11+
12+
NVML_SUPPORTED = CUDA_BINDINGS_VERSION >= (13, 1, 1)
13+
14+
15+
skip_if_nvml_unsupported = pytest.mark.skipif(
16+
not NVML_SUPPORTED, reason="NVML support requires cuda.bindings version 13.1.1 or later"
17+
)

cuda_core/tests/system/test_nvml_context.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5+
# ruff: noqa: E402
6+
7+
from .conftest import skip_if_nvml_unsupported
8+
9+
pytestmark = skip_if_nvml_unsupported
10+
511
import multiprocessing as mp
612
from platform import uname
713

cuda_core/tests/system/test_system_device.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5+
# ruff: noqa: E402
6+
7+
from .conftest import skip_if_nvml_unsupported
8+
9+
pytestmark = skip_if_nvml_unsupported
10+
511
import os
612
import re
713

cuda_core/tests/system/test_system_system.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5+
# ruff: noqa: E402
6+
7+
from .conftest import skip_if_nvml_unsupported
8+
9+
pytestmark = skip_if_nvml_unsupported
10+
511
import os
612

713
import pytest

0 commit comments

Comments
 (0)