Skip to content

Commit f50b64f

Browse files
authored
Merge branch 'main' into style-guide
2 parents 98a0a64 + f8dddb3 commit f50b64f

5 files changed

Lines changed: 37 additions & 10 deletions

File tree

cuda_core/cuda/core/system/__init__.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,11 @@
2323
from ._system import *
2424

2525
if CUDA_BINDINGS_NVML_IS_COMPATIBLE:
26-
from ._device import Device, DeviceArchitecture
26+
from ._device import *
27+
from ._device import __all__ as _device_all
2728
from .exceptions import *
2829
from .exceptions import __all__ as _exceptions_all
2930

30-
__all__.extend(
31-
[
32-
"get_nvml_version",
33-
"Device",
34-
"DeviceArchitecture",
35-
]
36-
)
37-
31+
__all__.append("get_nvml_version")
32+
__all__.extend(_device_all)
3833
__all__.extend(_exceptions_all)

cuda_core/cuda/core/system/_device.pyx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ cdef class Device:
175175
"""
176176
Representation of a device.
177177

178-
``cuda.core.system.Device`` provides access to various pieces of metadata
178+
:class:`cuda.core.system.Device` provides access to various pieces of metadata
179179
about devices and their topology, as provided by the NVIDIA Management
180180
Library (NVML). To use CUDA with a device, use :class:`cuda.core.Device`.
181181

@@ -312,3 +312,12 @@ cdef class Device:
312312
board serial identifier.
313313
"""
314314
return nvml.device_get_uuid(self._handle)
315+
316+
317+
__all__ = [
318+
"BAR1MemoryInfo",
319+
"Device",
320+
"DeviceArchitecture",
321+
"MemoryInfo",
322+
"PciInfo",
323+
]

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/docs/source/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ CUDA system information and NVIDIA Management Library (NVML)
7979
:template: autosummary/cyclass.rst
8080

8181
system.Device
82+
system.DeviceArchitecture
83+
system.MemoryInfo
84+
system.BAR1MemoryInfo
85+
system.PciInfo
8286

8387

8488
.. module:: cuda.core.utils

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)