Skip to content

Commit f8dddb3

Browse files
mdboomCopilot
andauthored
cuda.core.system: Add system-level APIs (#1440)
* Add the one missing system-level API (system_get_driver_branch) * Update cuda_core/cuda/core/system/_system.pyx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update cuda_core/tests/system/test_system_system.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0c9d301 commit f8dddb3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

cuda_core/cuda/core/system/_system.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ def get_nvml_version() -> tuple[int, ...]:
8282
return tuple(int(v) for v in nvml.system_get_nvml_version().split("."))
8383

8484

85+
def get_driver_branch() -> str:
86+
"""
87+
Retrieves the driver branch of the NVIDIA driver installed on the system.
88+
"""
89+
if not CUDA_BINDINGS_NVML_IS_COMPATIBLE:
90+
raise RuntimeError("NVML library is not available")
91+
initialize()
92+
return nvml.system_get_driver_branch()
93+
94+
8595
def get_num_devices() -> int:
8696
"""
8797
Return the number of devices in the system.
@@ -112,6 +122,7 @@ def get_process_name(pid: int) -> str:
112122

113123

114124
__all__ = [
125+
"get_driver_branch",
115126
"get_driver_version",
116127
"get_driver_version_full",
117128
"get_nvml_version",

cuda_core/tests/system/test_system_system.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,11 @@ def test_device_count():
9595
device_count = system.get_num_devices()
9696
assert isinstance(device_count, int)
9797
assert device_count >= 0
98+
99+
100+
@skip_if_nvml_unsupported
101+
def test_get_driver_branch():
102+
driver_branch = system.get_driver_branch()
103+
assert isinstance(driver_branch, str)
104+
assert len(driver_branch) > 0
105+
assert driver_branch[0] == "r"

0 commit comments

Comments
 (0)