@@ -32,6 +32,7 @@ include "_fan.pxi"
3232include " _field_values.pxi"
3333include " _inforom.pxi"
3434include " _memory.pxi"
35+ include " _mig.pxi"
3536include " _pci_info.pxi"
3637include " _performance.pxi"
3738include " _repair_status.pxi"
@@ -132,12 +133,19 @@ cdef class Device:
132133 board serial identifier.
133134
134135 In the upstream NVML C++ API , the UUID includes a ``gpu-`` or ``mig-``
135- prefix. That is not included in ``cuda.core.system``.
136+ prefix. If you a `uuid` without that prefix (for example , to interact
137+ with CUDA ), use the `uuid_without_prefix` property.
136138 """
137- # NVML UUIDs have a `GPU-` or `MIG-` prefix. We remove that here.
139+ return nvml.device_get_uuid(self. _handle )
138140
139- # TODO: If the user cares about the prefix , we will expose that in the
140- # future using the MIG-related APIs in NVML.
141+ @property
142+ def uuid_without_prefix(self ) -> str:
143+ """
144+ Retrieves the globally unique immutable UUID associated with this
145+ device , as a 5 part hexadecimal string , that augments the immutable ,
146+ board serial identifier.
147+ """
148+ # NVML UUIDs have a `GPU-` or `MIG-` prefix. We remove that here.
141149 return nvml.device_get_uuid(self._handle )[4:]
142150
143151 @property
@@ -265,7 +273,7 @@ cdef class Device:
265273 # search all the devices for one with a matching UUID.
266274
267275 for cuda_device in CudaDevice.get_all_devices():
268- if cuda_device.uuid == self .uuid :
276+ if cuda_device.uuid == self .uuid_without_prefix :
269277 return cuda_device
270278
271279 raise RuntimeError (" No corresponding CUDA device found for this NVML device." )
@@ -280,6 +288,8 @@ cdef class Device:
280288 int
281289 The number of available devices.
282290 """
291+ initialize()
292+
283293 return nvml.device_get_count_v2()
284294
285295 @classmethod
@@ -292,6 +302,8 @@ cdef class Device:
292302 Iterator of Device
293303 An iterator over available devices.
294304 """
305+ initialize()
306+
295307 for device_id in range(nvml.device_get_count_v2()):
296308 yield cls (index = device_id)
297309
@@ -317,6 +329,18 @@ cdef class Device:
317329 """
318330 return AddressingMode(nvml.device_get_addressing_mode(self._handle ).value )
319331
332+ #########################################################################
333+ # MIG (MULTI-INSTANCE GPU ) DEVICES
334+
335+ @property
336+ def mig(self ) -> MigInfo:
337+ """
338+ Accessor for MIG (Multi-Instance GPU ) information.
339+
340+ For Ampere™ or newer fully supported devices.
341+ """
342+ return MigInfo(self )
343+
320344 #########################################################################
321345 # AFFINITY
322346
@@ -853,6 +877,7 @@ __all__ = [
853877 "InforomInfo",
854878 "InforomObject",
855879 "MemoryInfo",
880+ "MigInfo",
856881 "PcieUtilCounter",
857882 "PciInfo",
858883 "Pstates",
0 commit comments