77// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceStructs.html
88#define NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE 32
99#define NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE 16
10+ #define NVML_DEVICE_UUID_V2_BUFFER_SIZE 96
1011
1112typedef enum { NVML_SUCCESS = 0 } nvmlReturn_t ;
1213typedef struct nvmlDevice_t * nvmlDevice_t ;
@@ -55,6 +56,19 @@ typedef struct {
5556// https://github.com/NVIDIA/nvidia-settings/issues/78#issuecomment-1012837988
5657enum { nvmlMemory_v2 = (unsigned int )(sizeof (nvmlMemory_v2_t ) | (2 << 24U )) };
5758
59+
60+ // https://docs.nvidia.com/deploy/nvml-api/structnvmlMemory__t.html#structnvmlMemory__t
61+ // Memory allocation information for a device (v1)
62+ typedef struct
63+ {
64+ // Total physical device memory (in bytes)
65+ unsigned long long total ;
66+ // Unallocated device memory (in bytes)
67+ unsigned long long free ;
68+ // Sum of Reserved and Allocated device memory (in bytes)
69+ unsigned long long used ;
70+ } nvmlMemory_t ;
71+
5872// https://docs.nvidia.com/deploy/nvml-api/group__nvmlDeviceEnumvs.html#group__nvmlDeviceEnumvs_1g805c0647be9996589fc5e3f6ff680c64
5973// Clock types
6074typedef enum {
@@ -94,6 +108,16 @@ typedef enum {
94108 NVML_BRAND_COUNT ,
95109} nvmlBrandType_t ;
96110
111+ // https://docs.nvidia.com/deploy/nvml-api/structnvmlUtilization__t.html#structnvmlUtilization__t
112+ // Utilization information for a device.
113+ typedef struct
114+ {
115+ // Percent of time over the past second during which one or more kernels was executing on the GPU
116+ unsigned int gpu ;
117+ // Percent of time over the past second during which global (device) memory was being read or written
118+ unsigned int memory ;
119+ } nvmlUtilization_t ;
120+
97121// https://docs.nvidia.com/deploy/nvml-api/group__nvmlInitializationAndCleanup.html#group__nvmlInitializationAndCleanup
98122// Initialize NVML, but don't initialize any GPUs yet
99123nvmlReturn_t nvmlInit_v2 (void );
@@ -113,9 +137,15 @@ extern nvmlReturn_t nvmlDeviceGetPciInfo_v3(nvmlDevice_t device, nvmlPciInfo_t*
113137extern nvmlReturn_t nvmlDeviceGetTemperature (nvmlDevice_t device , nvmlTemperatureSensors_t sensorType , unsigned int * temp );
114138// Retrieves the amount of used, free, reserved and total memory available on the device, in bytes. The reserved amount is supported on version 2 only
115139extern nvmlReturn_t nvmlDeviceGetMemoryInfo_v2 (nvmlDevice_t device , nvmlMemory_v2_t * memory );
140+ // Retrieves the amount of used, free, total memory available on the device, in bytes.
141+ extern nvmlReturn_t nvmlDeviceGetMemoryInfo (nvmlDevice_t device , nvmlMemory_t * memory );
116142// Gets the device's core count
117143extern nvmlReturn_t nvmlDeviceGetNumGpuCores (nvmlDevice_t device , unsigned int * numCores );
118144// Retrieves the maximum clock speeds for the device
119145extern nvmlReturn_t nvmlDeviceGetMaxClockInfo (nvmlDevice_t device , nvmlClockType_t type , unsigned int * clock );
120146// Retrieves the brand of this device
121147extern nvmlReturn_t nvmlDeviceGetBrand (nvmlDevice_t device , nvmlBrandType_t * type );
148+ // Retrieves the current utilization rates for the device
149+ extern nvmlReturn_t nvmlDeviceGetUtilizationRates (nvmlDevice_t device , nvmlUtilization_t * utilization );
150+ // Retrieves the globally unique immutable UUID associated with this device, as a 5 part hexadecimal string, that augments the immutable, board serial identifier.
151+ extern nvmlReturn_t nvmlDeviceGetUUID (nvmlDevice_t device , char * uuid , unsigned int length );
0 commit comments