Skip to content

Commit 0645cce

Browse files
committed
Merge remote-tracking branch 'origin/main' into wheel-size-reduction
2 parents 02966e4 + 9e33c7d commit 0645cce

3 files changed

Lines changed: 42 additions & 3 deletions

File tree

cuda_bindings/cuda/bindings/_internal/utils.pyx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
#
33
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
44

@@ -8,6 +8,28 @@ from libcpp.utility cimport move
88
from cython.operator cimport dereference as deref
99

1010

11+
cdef extern from *:
12+
"""
13+
#if defined(__clang__)
14+
#define _COMPILER_VERSION ("Clang " __clang_version__)
15+
#elif defined(__GNUC__) || defined(__GNUG__)
16+
#define _COMPILER_VERSION ("GCC " __VERSION__)
17+
#elif defined(_MSC_VER)
18+
#define _COMPILER_VERSION ("MSVC " Py_STRINGIFY(_MSC_VER))
19+
#else
20+
#define _COMPILER_VERSION ("Unknown Compiler")
21+
#endif
22+
"""
23+
cdef char *_COMPILER_VERSION
24+
25+
26+
cpdef str get_c_compiler():
27+
"""
28+
Returns a string describing the C compiler used to build cuda.bindings
29+
"""
30+
return _COMPILER_VERSION.decode()
31+
32+
1133
cdef bint is_nested_sequence(data):
1234
if not cpython.PySequence_Check(data):
1335
return False

cuda_bindings/tests/nvml/test_cuda.py

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

4+
import os
5+
46
import cuda.bindings.driver as cuda
57
from cuda.bindings import nvml
68

@@ -54,4 +56,12 @@ def test_cuda_device_order():
5456
cuda_devices = get_cuda_device_names()
5557
nvml_devices = get_nvml_device_names()
5658

57-
assert cuda_devices == nvml_devices, "CUDA and NVML device lists do not match"
59+
if "CUDA_VISIBLE_DEVICES" not in os.environ:
60+
# If that environment variable isn't set, the device lists should match exactly
61+
assert cuda_devices == nvml_devices, "CUDA and NVML device lists do not match"
62+
else:
63+
# If the environment variable is set, there may possibly be fewer CUDA devices,
64+
# and each of them should still be found in NVML devices.
65+
assert len(cuda_devices) <= len(nvml_devices)
66+
for cuda_device in cuda_devices:
67+
assert cuda_device in nvml_devices, f"CUDA device {cuda_device} not found in NVML device list"

cuda_bindings/tests/test_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
33

44
import importlib
@@ -9,6 +9,7 @@
99

1010
import pytest
1111
from cuda.bindings import driver, runtime
12+
from cuda.bindings._internal.utils import get_c_compiler
1213
from cuda.bindings.utils import get_cuda_native_handle, get_minimal_required_cuda_ver_from_ptx_ver, get_ptx_ver
1314

1415
have_cufile = importlib.util.find_spec("cuda.bindings.cufile") is not None
@@ -110,3 +111,9 @@ def test_cyclical_imports(module):
110111
subprocess.check_call( # noqa: S603
111112
[sys.executable, Path(__file__).parent / "utils" / "check_cyclical_import.py", f"cuda.bindings.{module}"],
112113
)
114+
115+
116+
def test_get_c_compiler():
117+
c_compiler = get_c_compiler()
118+
prefix = ("GCC", "Clang", "MSVC", "Unknown")
119+
assert sum(c_compiler.startswith(p) for p in prefix) == 1

0 commit comments

Comments
 (0)