@@ -33,10 +33,12 @@ include "_field_values.pxi"
3333include " _inforom.pxi"
3434include " _memory.pxi"
3535include " _mig.pxi"
36+ include " _nvlink.pxi"
3637include " _pci_info.pxi"
3738include " _performance.pxi"
3839include " _repair_status.pxi"
3940include " _temperature.pxi"
41+ include " _utilization.pxi"
4042
4143
4244cdef class Device:
@@ -702,6 +704,20 @@ cdef class Device:
702704 """
703705 return MemoryInfo(nvml.device_get_memory_info_v2(self._handle))
704706
707+ ##########################################################################
708+ # NVLINK
709+ # See external class definitions in _nvlink.pxi
710+
711+ def get_nvlink(self, link: int) -> NvlinkInfo:
712+ """
713+ Get :obj:`~ NvlinkInfo` about this device.
714+
715+ For devices with NVLink support.
716+ """
717+ if link < 0 or link >= NvlinkInfo.max_links:
718+ raise ValueError(f"Link index {link} is out of range [0, {NvlinkInfo.max_links})")
719+ return NvlinkInfo(self, link)
720+
705721 ##########################################################################
706722 # PCI INFO
707723 # See external class definitions in _pci_info.pxi
@@ -798,6 +814,31 @@ cdef class Device:
798814 device._handle = handle
799815 yield device
800816
817+ #######################################################################
818+ # UTILIZATION
819+
820+ @property
821+ def utilization(self) -> Utilization:
822+ """
823+ Retrieves the current :obj:`~ Utilization` rates for the device' s major
824+ subsystems.
825+
826+ For Fermi™ or newer fully supported devices.
827+
828+ Note: During driver initialization when ECC is enabled one can see high
829+ GPU and Memory Utilization readings. This is caused by ECC Memory
830+ Scrubbing mechanism that is performed during driver initialization.
831+
832+ Note: On MIG- enabled GPUs, querying device utilization rates is not
833+ currently supported.
834+
835+ Returns
836+ -------
837+ Utilization
838+ An object containing the current utilization rates for the device.
839+ """
840+ return Utilization(nvml.device_get_utilization_rates(self._handle))
841+
801842
802843def get_topology_common_ancestor(device1: Device, device2: Device) -> GpuTopologyLevel:
803844 """
@@ -872,10 +913,12 @@ __all__ = [
872913 "GpuP2PStatus",
873914 "GpuTopologyLevel",
874915 "InforomObject",
916+ "NvlinkVersion",
875917 "PcieUtilCounter",
876918 "Pstates",
877919 "TemperatureSensors",
878920 "TemperatureThresholds",
879921 "ThermalController",
880922 "ThermalTarget",
923+ "Utilization",
881924]
0 commit comments