Compare commits

...

20 Commits
v1.0 ... master

Author SHA1 Message Date
5e78a059a6 Fix in fan error handling 2025-02-21 11:32:02 -08:00
20e2683110 Reuse memory mappings 2025-02-21 11:26:17 -08:00
b7d22ed9ac Reduced number of NVML function calls 2025-02-21 10:59:31 -08:00
46eb773820 Readme update 2025-02-17 04:33:35 -08:00
dc63b57bbe Cleanup for non-overwrite mode 2025-02-17 04:25:10 -08:00
7cd23384f6 Added --i2c command line option 2025-02-16 22:28:16 -08:00
c4e7f7e8b9 Added NVML memory controller load percentage. 2025-02-07 08:23:46 -08:00
442a524243 License 2025-02-03 06:59:12 -08:00
d4e32a78fc Added color support in compact mode. 2025-02-03 06:34:33 -08:00
65aa52ac42 Readme update. 2025-02-03 06:17:35 -08:00
8d4a8f7ee1 Added support for reading VRAM and HotSpot temperatures. 2025-02-03 06:15:26 -08:00
54885e16f0 Added overwrite output mode for things like live monitoring. 2025-02-02 23:40:38 -08:00
13aa5b023e Readme update. 2025-02-02 21:45:55 -08:00
4c5321bc4e Added support for some NVML sensors.
GPU temp sensor and clock reasons.
2025-02-02 21:42:30 -08:00
4cb9ef42a6 Added watch function 2025-02-01 08:22:52 -08:00
34bbcf7883 Reduced number of syscalls 2025-02-01 08:04:41 -08:00
afdddabc0c Only read Nvidia i2c devices 2025-02-01 00:29:48 -08:00
73f7038eaa Readme update 2025-01-31 22:24:47 -08:00
113e296347 Added compact sensor display option 2025-01-31 22:20:13 -08:00
9f29076d52 Formatting change. 2025-01-30 06:20:18 -08:00
13 changed files with 643 additions and 162 deletions

8
LICENSE Normal file
View File

@ -0,0 +1,8 @@
MIT No Attribution
Copyright 2025 admin@long-cat.net
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

29
Makefile Normal file
View File

@ -0,0 +1,29 @@
.PHONY : clean debug
OBJS = evga-icx.o evga-card.o icx3.o
LDLIBS = -li2c
CFLAGS = -MD
ifdef USE_NVML
LDLIBS += -lnvidia-ml
CFLAGS += -DUSE_NVML
OBJS += nvidia-sensors.o
endif
ifdef USE_LIBPCI
LDLIBS += -lpci
CFLAGS += -DUSE_LIBPCI
OBJS += gddr6.o
endif
evga-icx : $(OBJS)
debug : CFLAGS += -g -O0
debug : evga-icx
clean :
rm evga-icx
rm *.o
rm *.d
-include $(OBJS:.o=.d)

View File

@ -3,7 +3,7 @@
This program allows you to read temperature sensors off of supported EVGA 30-series iCX3 video cards, as well as control the fans individually. This program allows you to read temperature sensors off of supported EVGA 30-series iCX3 video cards, as well as control the fans individually.
## Prerequisites ## Prerequisites
A supported EVGA 30-series iCX3 card. I have not done extensive testing but belive this is every model of their: A supported EVGA 30-series card with iCX3. This includes:
* RTX 3060 Ti * RTX 3060 Ti
* RTX 3070 * RTX 3070
* RTX 3070 Ti * RTX 3070 Ti
@ -14,21 +14,34 @@ A supported EVGA 30-series iCX3 card. I have not done extensive testing but bel
The number of fans supported depends, of course, on your particular model. The number of fans supported depends, of course, on your particular model.
You must have the `i2c-dev` kernel module loaded with `modprobe i2c-dev`
Access to the `/dev/i2c` device files, which means either: Access to the `/dev/i2c` device files, which means either:
* Run as root, or * Run as root, or
* Install udev rules to allow user access. If you have the OpenRGB udev rules installed to control the LEDs you already have this set up. * Install udev rules to allow user access. If you have the OpenRGB udev rules installed to control the LEDs you already have this set up.
## Dependencies ## Dependencies
* libi2c-dev * libi2c-dev
* libnvidia-ml-dev (if building with `USE_NVML=1`)
* libpci-dev (if building with `USE_LIBPCI=1`)
## Building ## Building
`make` `make`
## Optional features
### NVML support
Add the make flag `USE_NVML=1` and the it will also display the main GPU temperature ("GPU1") as reported by the NVIDIA driver. It will also display the performance cap/clock reason and memory controller utilization. This requires the NVIDIA management library (NVML) to be installed.
### VRAM and Hotspot temperature
Add the make flag `USE_LIBPCI=1` and you can also read the VRAM and "hotspot" temperatures. These require direct memory access to the PCI device so you must run as root and also enable the kernel parameter `iomem=relaxed`. These sensors are **extremely** undocumented so I can't say anything about their accuracy.
## Usage ## Usage
Note that when controlling fans directly through iCX3 they will fall offline from the Nvidia driver and show as 0 RPM until you return them to automatic mode. Note that when controlling fans directly through iCX3 they will fall offline from the Nvidia driver and show as 0 RPM until you return them to automatic mode.
```text ```text
Available options: Available options:
--i2c N : Only probe I2C bus N instead of all (may help with stuttering or freezing when probing I2C devices)
--gpu N : Control only GPU N instead of all supported cards --gpu N : Control only GPU N instead of all supported cards
--fan SPEED : Set all fans at once to SPEED (see below) --fan SPEED : Set all fans at once to SPEED (see below)
--fanN SPEED : Set fan N (0-3) to SPEED --fanN SPEED : Set fan N (0-3) to SPEED
@ -38,6 +51,10 @@ Available options:
[+/-]N to set that fan to an RPM offset from the GPU-controlled speed [+/-]N to set that fan to an RPM offset from the GPU-controlled speed
--reset : Reset all fans to their default mode --reset : Reset all fans to their default mode
--sensors : Print sensor readings even if setting a fan speed --sensors : Print sensor readings even if setting a fan speed
--compact : Print sensor reading in a compact one-line per card format
--watch N : Keep printing output every N seconds
--overwrite : Overwrite previously displayed info with --watch and --compact instead of continuously logging new lines
--color : Print headers in color in --compact mode for better readability
``` ```
### Examples: ### Examples:
@ -45,19 +62,30 @@ Read sensors:
```text ```text
$ ./evga-icx $ ./evga-icx
#0: EVGA GeForce RTX 3090 FTW3 Ultra v2 (/dev/i2c-3) @ c:00.0 #0: EVGA GeForce RTX 3090 FTW3 Ultra v2 (/dev/i2c-3) @ c:00.0
Fan 0: 1094 RPM (36/0%, Auto) Fan 0: 1751 RPM (58/0%, Auto)
Fan 1: 1164 RPM (38/0%, Auto) Fan 1: 1730 RPM (57/0%, Auto)
Fan 2: 1161 RPM (38/0%, Offset) Fan 2: 1712 RPM (57/0%, Offset)
Ext. fan: 0 RPM (0/0%, Offset) Ext. fan: 0 RPM (0/0%, Offset)
GPU2: 35.8 C GPU1: +65°C
MEM1: 35.3 C GPU2: +57.8°C
MEM2: 35.6 C VRAM: +74°C
MEM3: 35.9 C MEM1: +56.1°C
PWR1: 35.0 C MEM2: +53.5°C
PWR2: 35.6 C MEM3: +55.5°C
PWR3: 36.3 C PWR1: +48.2°C
PWR4: 36.9 C PWR2: +53.2°C
PWR5: 36.3 C PWR3: +59.6°C
PWR4: +58.0°C
PWR5: +51.1°C
HotSpot: +75°C
Mem util: 43%
Clock reasons: Power cap (0x4)
```
Compact one-line mode:
```text
$ ./evga-icx --compact
#0 FAN 59 59 58 0% GPU 66 60 MEM 74 58 55 58 PWR 49 55 61 60 53 HOT 77°C MEM 42% CLK Pwr
``` ```
Set external fan to follow Nvidia driver controlled speed with a -500 RPM offset: Set external fan to follow Nvidia driver controlled speed with a -500 RPM offset:

View File

@ -8,17 +8,19 @@
/* Search all i2c device files for ones are on a PCI device of a supported GPU, /* Search all i2c device files for ones are on a PCI device of a supported GPU,
and respond with the correct iCX3 version information */ and respond with the correct iCX3 version information */
int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus) int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus, int i2c_bus)
{ {
char i2c_devices_path[NAME_MAX]; char i2c_devices_path[NAME_MAX];
char device_path[NAME_MAX]; char device_path[NAME_MAX];
char dev_file[NAME_MAX]; char dev_file[NAME_MAX];
char *pci_addr;
FILE *test_fd; FILE *test_fd;
DIR *dir; DIR *dir;
struct dirent *ent; struct dirent *ent;
int num_gpus = 0; int num_gpus = 0;
int current_i2c_bus = -1;
unsigned short pci_vendor, pci_device, pci_subsystem_vendor, pci_subsystem_device = 0; unsigned short pci_vendor, pci_device, pci_subsystem_vendor, pci_subsystem_device = 0;
/* Start looking for I2C adapters in /sys/bus/i2c/devices/ */ /* Start looking for I2C adapters in /sys/bus/i2c/devices/ */
@ -36,9 +38,22 @@ int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus)
if(strncmp(ent->d_name, "i2c-", 4) != 0) if(strncmp(ent->d_name, "i2c-", 4) != 0)
continue; continue;
/* Only probe the specific device given (if provided) */
if (i2c_bus >= 0) {
sscanf(ent->d_name, "i2c-%i", &current_i2c_bus);
if (current_i2c_bus != i2c_bus)
continue;
}
strcpy(device_path, i2c_devices_path); strcpy(device_path, i2c_devices_path);
strcat(device_path, ent->d_name); strcat(device_path, ent->d_name);
/* Only check Nvidia devices */
pci_addr = read_nvidia_pci_address(device_path);
if (pci_addr == NULL)
continue;
/* Read the PCI info for the underlying device */ /* Read the PCI info for the underlying device */
pci_vendor = read_pci_id(device_path, "/device/vendor"); pci_vendor = read_pci_id(device_path, "/device/vendor");
pci_device = read_pci_id(device_path, "/device/device"); pci_device = read_pci_id(device_path, "/device/device");
@ -56,10 +71,12 @@ int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus)
/* Matched all PCI IDs, check for good firmware read */ /* Matched all PCI IDs, check for good firmware read */
strcpy(dev_file, "/dev/"); strcpy(dev_file, "/dev/");
strcat(dev_file, ent->d_name); strcat(dev_file, ent->d_name);
if (check_for_icx3(dev_file)) { infos[num_gpus].i2c_dev_path = dev_file;
if (icx3_init(&infos[num_gpus]) > 0) {
/* Write our card info into the provided struct array */ /* Write our card info into the provided struct array */
infos[num_gpus].card_name = evga_pci_ids[i].card_name; infos[num_gpus].card_name = evga_pci_ids[i].card_name;
infos[num_gpus].pci_id = read_nvidia_pci_address(device_path); infos[num_gpus].pci_id = pci_addr;
infos[num_gpus].pci_device_id = pci_device;
infos[num_gpus].i2c_dev_path = calloc(strlen(dev_file) + 1, sizeof(char)); infos[num_gpus].i2c_dev_path = calloc(strlen(dev_file) + 1, sizeof(char));
strcpy(infos[num_gpus].i2c_dev_path, dev_file); strcpy(infos[num_gpus].i2c_dev_path, dev_file);
num_gpus++; num_gpus++;
@ -111,12 +128,18 @@ char *read_nvidia_pci_address(char *device_path)
FILE *fp = fopen(file_path, "r"); FILE *fp = fopen(file_path, "r");
if (fp == NULL) if (fp == NULL) {
free(ret);
return NULL; return NULL;
}
fscanf(fp, "NVIDIA i2c adapter %*u at %16s", ret); fscanf(fp, "NVIDIA i2c adapter %*u at %16s", ret);
fclose(fp); fclose(fp);
if (strlen(ret) == 0) {
free(ret);
return NULL;
}
return ret; return ret;
} }

View File

@ -1,3 +1,6 @@
#ifndef EVGA_CARD_H
#define EVGA_CARD_H
#define NVIDIA_VEN 0x10DE #define NVIDIA_VEN 0x10DE
#define NVIDIA_RTX3060_DEV 0x2503 #define NVIDIA_RTX3060_DEV 0x2503
@ -81,9 +84,16 @@
#define EVGA_RTX3090TI_FTW3_ULTRA_GAMING_SUB_DEV 0x4985 #define EVGA_RTX3090TI_FTW3_ULTRA_GAMING_SUB_DEV 0x4985
struct card_info { struct card_info {
char *card_name; char *card_name; /* The 'nice' name of the card */
char *pci_id; char *pci_id; /* PCI bus address in domain:bus:device.function format. May be shortened (e.g. c:00.0) */
char *i2c_dev_path; unsigned short pci_device_id; /* The device ID of the card, i.e. corresponds to the NVIDIA model number */
char *i2c_dev_path; /* Path to the i2c device file */
int i2c_fd; /* File descriptor for the i2c device file, for re-use */
int product_id; /* EVGA internal product ID, as reported by the iCX3 controller */
unsigned int bar0; /* Address of the card's PCI base address register */
void *nvml_device; /* Pointer to nvmlDevice_t for use in NVML calls */
void *vram_addr; /* Memory mapping for GDDR6 temps */
void *hotspot_addr; /* Memory mapping for hotspot temperature */
}; };
struct gpu_pci_info { struct gpu_pci_info {
@ -155,6 +165,8 @@ static struct gpu_pci_info evga_pci_ids[] =
{"EVGA GeForce RTX 3090 Ti FTW3 Ultra Gaming" , NVIDIA_VEN, NVIDIA_RTX3090TI_DEV, EVGA_SUB_VEN, EVGA_RTX3090TI_FTW3_ULTRA_GAMING_SUB_DEV } {"EVGA GeForce RTX 3090 Ti FTW3 Ultra Gaming" , NVIDIA_VEN, NVIDIA_RTX3090TI_DEV, EVGA_SUB_VEN, EVGA_RTX3090TI_FTW3_ULTRA_GAMING_SUB_DEV }
}; };
int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus); int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus, int i2c_bus);
unsigned short read_pci_id(char *device_path, char *field); unsigned short read_pci_id(char *device_path, char *field);
char *read_nvidia_pci_address(char *device_path); char *read_nvidia_pci_address(char *device_path);
#endif

View File

@ -5,13 +5,27 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef USE_NVML
#include "nvidia-sensors.h"
#endif
#ifdef USE_LIBPCI
#include "gddr6.h"
#endif
#include "icx3.h" #include "icx3.h"
#include "evga-card.h" #include "evga-card.h"
#define MAX_GPUS 16 #define MAX_GPUS 16
#define HEADER_COLOR_START "\x1b[36m"
#define HEADER_COLOR_END "\x1b[39m"
char *header_start = "";
char *header_end = "";
static const char helpstring[] = "Available options:\n" static const char helpstring[] = "Available options:\n"
"--gpu N : Control only GPU N instead of all supported cards\n" "--i2c N : Only probe I2C bus N instead of all (may help with stuttering or freezing when probing I2C devices)\n"
"--gpu N : Control only GPU N instead of all supported cards\n"
"--fan SPEED : Set all fans at once to SPEED (see below)\n" "--fan SPEED : Set all fans at once to SPEED (see below)\n"
"--fanN SPEED : Set fan N (0-3) to SPEED\n" "--fanN SPEED : Set fan N (0-3) to SPEED\n"
" SPEED may be one of the following:\n" " SPEED may be one of the following:\n"
@ -19,21 +33,37 @@ static const char helpstring[] = "Available options:\n"
" N to set the fan to that manual % speed\n" " N to set the fan to that manual % speed\n"
" [+/-]N to set that fan to an RPM offset from the GPU-controlled speed\n" " [+/-]N to set that fan to an RPM offset from the GPU-controlled speed\n"
"--reset : Reset all fans to their default mode\n" "--reset : Reset all fans to their default mode\n"
"--sensors : Print sensor readings even if setting a fan speed \n"; "--sensors : Print sensor readings even if setting a fan speed \n"
"--compact : Print sensor reading in a compact one-line per card format\n"
"--watch N : Keep printing output every N seconds\n"
"--overwrite : Overwrite previously displayed info with --watch and --compact instead of continuously logging\n"
"--color : Print headers in color in --compact mode for better readability\n";
void print_gpu_info(int gpu_num, struct card_info gpus[]); void print_gpu_info(int gpu_num, struct card_info gpus[], int compact);
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
struct card_info gpus[MAX_GPUS]; struct card_info gpus[MAX_GPUS];
int gpu_count; int gpu_count;
int print_info = 0; int print_info = 0;
int compact = 0;
int gpu_num = -1; /* Card to control */ int gpu_num = -1; /* Card to control */
int i2c_bus = -1;
int overwrite = 0;
unsigned int watch = 0;
char *fan_speed[ICX3_MAX_FANS] = {NULL}; char *fan_speed[ICX3_MAX_FANS] = {NULL};
/* Input parsing */ /* Input parsing */
for (int i = 1; i < argc; i++){ for (int i = 1; i < argc; i++){
if (strcmp(argv[i], "--gpu") == 0) { if (strcmp(argv[i], "--i2c") == 0) {
i++;
if (i < argc) {
i2c_bus = atoi(argv[i]);
} else {
printf(helpstring);
return -1;
}
} else if (strcmp(argv[i], "--gpu") == 0) {
i++; i++;
if (i < argc) { if (i < argc) {
gpu_num = atoi(argv[i]); gpu_num = atoi(argv[i]);
@ -65,6 +95,21 @@ int main (int argc, char **argv)
fan_speed[j] = "auto"; fan_speed[j] = "auto";
} else if (strcmp(argv[i], "--sensors") == 0) { } else if (strcmp(argv[i], "--sensors") == 0) {
print_info = 1; print_info = 1;
} else if (strcmp(argv[i], "--compact") == 0) {
compact = 1;
} else if (strcmp(argv[i], "--watch") == 0) {
i++;
if (i < argc) {
watch = atoi(argv[i]);
} else {
printf(helpstring);
return -1;
}
} else if (strcmp(argv[i], "--overwrite") == 0) {
overwrite = 1;
} else if (strcmp(argv[i], "--color") == 0) {
header_start = HEADER_COLOR_START;
header_end = HEADER_COLOR_END;
} else { } else {
printf(helpstring); printf(helpstring);
return 0; return 0;
@ -80,8 +125,12 @@ int main (int argc, char **argv)
} }
} }
gpu_count = find_evga_gpu_i2cs(gpus, MAX_GPUS); /* Don't use overwrite mode unless set to compact (we can't tell how many lines the output will be per GPU) */
if (overwrite && !compact)
overwrite = 0;
gpu_count = find_evga_gpu_i2cs(gpus, MAX_GPUS, i2c_bus);
if (gpu_count == -1) { if (gpu_count == -1) {
printf("Error scanning I2C devices\n"); printf("Error scanning I2C devices\n");
return -1; return -1;
@ -101,35 +150,133 @@ int main (int argc, char **argv)
for (int i = 0; i < gpu_count; i++){ for (int i = 0; i < gpu_count; i++){
for (int j = 0; j < ICX3_MAX_FANS; j++) { for (int j = 0; j < ICX3_MAX_FANS; j++) {
if (fan_speed[j] != NULL) if (fan_speed[j] != NULL)
set_fan(j, fan_speed[j], gpus[i].i2c_dev_path); set_fan(j, fan_speed[j], &gpus[i]);
/* printf("gpu %d fan %d : %s\n", i, j, fan_speed[j]); */
} }
} }
} else if (gpu_num <= gpu_count - 1) { } else if (gpu_num <= gpu_count - 1) {
for (int j = 0; j < ICX3_MAX_FANS; j++) { for (int j = 0; j < ICX3_MAX_FANS; j++) {
if (fan_speed[j] != NULL) if (fan_speed[j] != NULL)
set_fan(gpu_num, fan_speed[j], gpus[gpu_num].i2c_dev_path); set_fan(gpu_num, fan_speed[j], &gpus[gpu_num]);
/* printf("gpu %d fan %d : %s\n", gpu_num, j, fan_speed[j]);*/
} }
} }
/* NVML init */
#ifdef USE_NVML
init_nvml();
for (int i = 0; i < gpu_count; i++)
get_nvml_handle(&gpus[i]);
#endif
/* PCI init for VRAM/hotspot temps */
#ifdef USE_LIBPCI
for (int i = 0; i < gpu_count; i++)
init_gddr6(&gpus[i]);
#endif
/* print sensor info */ /* print sensor info */
if (print_info) { if (print_info) {
if (gpu_num == -1) { do {
for (int i = 0; i < gpu_count; i++){ if (overwrite)
print_gpu_info(i, gpus); printf("\x1b[K"); /* Clear current console line */
}
} else if (gpu_num <= gpu_count - 1) { if (gpu_num == -1) {
print_gpu_info(gpu_num, gpus); /* No GPU specified on command line, loop over all supported GPUs */
for (int i = 0; i < gpu_count; i++){
if (i > 0)
printf("\n");
print_gpu_info(i, &gpus[i], compact);
}
} else if (gpu_num <= gpu_count - 1) {
print_gpu_info(gpu_num, &gpus[gpu_num], compact);
}
if (!overwrite)
printf("\n"); /* Print line break at the end for continuous output */
if (overwrite && compact) {
printf("\x1b[1G"); /* Move cursor back to column 1 */
if (gpu_count > 1)
printf("\x1b[%dA", gpu_count-1); /* Move cursor back up to the top of gpu list */
}
fflush(stdout);
sleep(watch);
} while (watch > 0);
}
#ifdef USE_NVML
nvmlShutdown();
#endif
}
void print_gpu_info(int gpu_num, struct card_info *gpu, int compact) {
if (compact) {
/* One line per GPU */
printf("%s#%d FAN%s", header_start, gpu_num, header_end);
print_icx3_fans_oneline(gpu);
printf("%s GPU%s", header_start, header_end);
#ifdef USE_NVML
printf(" %3d", get_nvml_temp(gpu));
#endif
float icx_temp_sensors[ICX3_NUM_TEMP_SENSORS] = {};
get_temp_sensors(icx_temp_sensors, gpu);
for (int i = 0; i < ICX3_NUM_TEMP_SENSORS; i++) {
if (i > 0 && strncmp(icx3_temp_sensor_names[i], icx3_temp_sensor_names[i-1], 3))
printf("%s %.3s%s", header_start, icx3_temp_sensor_names[i], header_end);
#ifdef USE_LIBPCI
if (strncmp(icx3_temp_sensor_names[i], "MEM1", 4) == 0)
printf(" %3.0f", get_vram_temp(gpu)); /* Print the VRAM temp before the rest of the memory sensors */
#endif
printf(" %3.0f", icx_temp_sensors[i]);
} }
#ifdef USE_LIBPCI
printf("%s HOT%s %3.0f", header_start, header_end, get_hotspot_temp(gpu));
#endif
printf("°C ");
#ifdef USE_NVML
printf("%s MEM %s", header_start, header_end);
printf("%3d%%", get_nvml_mem_util(gpu));
printf("%s CLK %s", header_start, header_end);
print_nvml_clock_reason(1, gpu);
#endif
} else {
/* One line per GPU sensor */
printf("#%d: %s (%s) @ %s\n", gpu_num, gpu->card_name, gpu->i2c_dev_path, gpu->pci_id);
print_icx3_fans(gpu);
#ifdef USE_NVML
printf("GPU1: %+d°C\n", get_nvml_temp(gpu));
#endif
float icx_temp_sensors[ICX3_NUM_TEMP_SENSORS] = {};
get_temp_sensors(icx_temp_sensors, gpu);
for (int i = 0; i < ICX3_NUM_TEMP_SENSORS; i++) {
#ifdef USE_LIBPCI
if (strncmp(icx3_temp_sensor_names[i], "MEM1", 4) == 0)
printf("VRAM: +%.0f°C\n", get_vram_temp(gpu)); /* Print the VRAM temp before the rest of the memory sensors */
#endif
printf("%s: %+.1f°C\n",
icx3_temp_sensor_names[i],
icx_temp_sensors[i]);
}
#ifdef USE_LIBPCI
printf("HotSpot: +%.0f°C\n", get_hotspot_temp(gpu));
#endif
#ifdef USE_NVML
printf("Mem util: %d%%\n", get_nvml_mem_util(gpu));
printf("Clock reasons: ");
print_nvml_clock_reason(0, gpu);
printf("\n");
#endif
} }
} }
void print_gpu_info(int gpu_num, struct card_info gpus[]) {
printf("#%d: %s (%s) @ %s\n", gpu_num, gpus[gpu_num].card_name, gpus[gpu_num].i2c_dev_path, gpus[gpu_num].pci_id);
print_icx3_fans(gpus[gpu_num].i2c_dev_path);
print_icx3_temps(gpus[gpu_num].i2c_dev_path);
printf("\n");
}

104
gddr6.c Normal file
View File

@ -0,0 +1,104 @@
#include <string.h>
#include <stdio.h>
#include <pci/pci.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#define PG_SZ sysconf(_SC_PAGE_SIZE)
#include "gddr6.h"
void init_gddr6(struct card_info *card)
{
/* Parse the address of the card to get the PCI info */
char pci_address[] = "00000000:00:00.0";
int len = strlen(card->pci_id);
strcpy(&pci_address[sizeof(pci_address) - len - 1], card->pci_id);
int domain = 0;
int bus = 0;
int dev = 0;
int func = 0;
sscanf(pci_address, "%x:%x:%x.%x", &domain, &bus, &dev, &func);
struct pci_access *pacc = NULL;
struct pci_dev *pci_dev = NULL;
pacc = pci_alloc();
pci_init(pacc);
pci_dev = pci_get_dev(pacc, domain, bus, dev, func);
pci_fill_info(pci_dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_CLASS);
card->bar0 = (pci_dev->base_addr[0] & 0xFFFFFFFF);
pci_cleanup(pacc);
/* Open our memory mappings */
card->vram_addr = NULL;
card->hotspot_addr = NULL;
int fd;
if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1)
{
printf("Can't read memory for VRAM and Hotspot temperatures. If you are root, enable kernel parameter iomem=relaxed\n");
return;
}
unsigned int phys_addr, base_offset;
void *map_base;
for (int i = 0; i < sizeof(device_offset_info) / sizeof(struct device_offset); i++) {
if (card->pci_device_id == device_offset_info[i].device_id){
/* Map for VRAM */
phys_addr = (card->bar0 + device_offset_info[i].vram_offset);
base_offset = phys_addr & ~(PG_SZ-1);
map_base = mmap(0, PG_SZ, PROT_READ, MAP_SHARED, fd, base_offset);
if(map_base == (void *) -1)
printf("Can't map memory for VRAM temperature. If you are root, enable kernel parameter iomem=relaxed\n");
else
card->vram_addr = (void *) map_base + (phys_addr - base_offset);
/* Map for hotspot */
phys_addr = (card->bar0 + device_offset_info[i].hotspot_offset);
base_offset = phys_addr & ~(PG_SZ-1);
map_base = mmap(0, PG_SZ, PROT_READ, MAP_SHARED, fd, base_offset);
if(map_base == (void *) -1)
printf("Can't map memory for Hotspot temperature. If you are root, enable kernel parameter iomem=relaxed\n");
else
card->hotspot_addr = (void *) map_base + (phys_addr - base_offset);
}
}
close(fd);
}
float get_vram_temp(struct card_info *card)
{
float temp = 0.0;
if(card->vram_addr == NULL)
return 0.0;
int read_result = *((unsigned int *) card->vram_addr);
temp = ((read_result & 0x00000fff) / 0x20);
return temp;
}
float get_hotspot_temp(struct card_info *card)
{
float temp = 0.0;
if(card->hotspot_addr == NULL)
return 0.0;
int read_result = *((unsigned int *) card->hotspot_addr);
temp = (read_result >> 8) & 0xff;
return temp;
}

26
gddr6.h Normal file
View File

@ -0,0 +1,26 @@
#include "evga-card.h"
struct device_offset {
unsigned short device_id;
int vram_offset;
int hotspot_offset;
};
static struct device_offset device_offset_info[] =
{
{.device_id = NVIDIA_RTX3090TI_DEV, .vram_offset = 0x0000E2A8, .hotspot_offset = 0x0002046c}, /* RTX 3090 Ti */
{.device_id = NVIDIA_RTX3090_DEV, .vram_offset = 0x0000E2A8, .hotspot_offset = 0x0002046c}, /* RTX 3090 */
{.device_id = NVIDIA_RTX3080TI_DEV, .vram_offset = 0x0000E2A8, .hotspot_offset = 0x0002046c}, /* RTX 3080 Ti */
{.device_id = NVIDIA_RTX3080_12G_LHR_DEV, .vram_offset = 0x0000E2A8, .hotspot_offset = 0x0002046c}, /* RTX 3080 12G LHR */
{.device_id = NVIDIA_RTX3080_LHR_DEV, .vram_offset = 0x0000E2A8, .hotspot_offset = 0x0002046c}, /* RTX 3080 LHR */
{.device_id = NVIDIA_RTX3080_DEV, .vram_offset = 0x0000E2A8, .hotspot_offset = 0x0002046c}, /* RTX 3080 */
{.device_id = NVIDIA_RTX3080_DEV, .vram_offset = 0x0000E2A8, .hotspot_offset = 0x0002046c}, /* RTX 3080 */
{.device_id = NVIDIA_RTX3070TI_GA102_DEV, .vram_offset = 0x0000EE50, .hotspot_offset = 0x0002046c}, /* RTX 3070 Ti GA102 TODO:check */
{.device_id = NVIDIA_RTX3070TI_DEV, .vram_offset = 0x0000EE50, .hotspot_offset = 0x0002046c}, /* RTX 3070 Ti TODO:check */
{.device_id = NVIDIA_RTX3070_LHR_DEV, .vram_offset = 0x0000EE50, .hotspot_offset = 0x0002046c}, /* RTX 3070 */
{.device_id = NVIDIA_RTX3070_DEV, .vram_offset = 0x0000EE50, .hotspot_offset = 0x0002046c}, /* RTX 3070 LHR */
};
void init_gddr6(struct card_info *card);
float get_vram_temp(struct card_info *card);
float get_hotspot_temp(struct card_info *card);

177
icx3.c
View File

@ -9,99 +9,68 @@
#include "icx3.h" #include "icx3.h"
/* Check an I2C device file for an ICX3 controller, returns the product id, or ICX3_PRODUCT_NONE on bad read. */ int icx3_init(struct card_info *card)
enum icx3_product_id check_for_icx3(char *i2c_dev_path)
{ {
char data[I2C_SMBUS_BLOCK_MAX] = {}; char data[I2C_SMBUS_BLOCK_MAX] = {};
int fd, read_result; int read_result;
struct icx3_info *temp_info; struct icx3_info *temp_info;
fd = open_i2c_dev(i2c_dev_path); int fd = open(card->i2c_dev_path, O_RDONLY);
if (fd == -1) if (fd == -1)
return ICX3_PRODUCT_NONE; return -1;
if (ioctl(fd, I2C_SLAVE, ICX3_I2C_ADDR) < 0) {
close(fd);
return -1;
}
read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_READINFORMATION, ICX3_READINFORMATION_SIZE, data); read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_READINFORMATION, ICX3_READINFORMATION_SIZE, data);
close(fd);
if (read_result == ICX3_READINFORMATION_SIZE) { if (read_result == ICX3_READINFORMATION_SIZE) {
temp_info = (struct icx3_info*)&data; temp_info = (struct icx3_info*)&data;
if (temp_info->slave_address == ICX3_I2C_ADDR) if (temp_info->slave_address == ICX3_I2C_ADDR) {
return temp_info->product_id; card->product_id = temp_info->product_id;
card->i2c_fd = fd;
return fd;
} else {
close(fd);
return -1;
}
} }
return ICX3_PRODUCT_NONE; return -1;
} }
void print_icx3_fans(char *i2c_dev_path) void print_icx3_fans(struct card_info *card)
{ {
char data[I2C_SMBUS_BLOCK_MAX] = {}; struct icx3_fan_control fans[ICX3_MAX_FANS];
int fd, read_result; get_fan_status(fans, card);
struct icx3_fan_control *fan_status; for (int i=0; i < ICX3_MAX_FANS; i++) {
/* First thing is to check for the product ID to figure out how many fans we have */
char fans_avail[ICX3_MAX_FANS] = {0};
get_available_fans(i2c_dev_path, fans_avail);
fd = open_i2c_dev(i2c_dev_path);
if (fd == -1)
return;
for (int i=0; i < ICX3_MAX_FANS; i++) {
if (!fans_avail[i])
continue;
read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_FANCONTROL + i, ICX3_FANCONTROL_SIZE, data);
if (read_result != ICX3_FANCONTROL_SIZE) {
close(fd);
return;
}
fan_status = (struct icx3_fan_control*) &data;
printf("%s: %d RPM (%d/%d%%, %s)\n", printf("%s: %d RPM (%d/%d%%, %s)\n",
icx3_fan_names[i], icx3_fan_names[i],
fan_status->rpm_status, fans[i].rpm_status,
fan_status->duty_status, fans[i].duty_status,
fan_status->duty, fans[i].duty,
icx3_fan_mode_names[fan_status->fanmode] icx3_fan_mode_names[fans[i].fanmode]
); );
} }
close(fd);
} }
void print_icx3_temps(char *i2c_dev_path) void print_icx3_fans_oneline(struct card_info *card)
{ {
char data[I2C_SMBUS_BLOCK_MAX] = {}; struct icx3_fan_control fans[ICX3_MAX_FANS];
int fd, read_result; get_fan_status(fans, card);
struct icx3_temp_sensors *temp_sensors;
fd = open_i2c_dev(i2c_dev_path); for (int i=0; i < ICX3_MAX_FANS; i++) {
if (fd == -1) printf(" %3d", fans[i].duty_status);
return;
read_result = i2c_smbus_read_i2c_block_data(fd, ICX3_REG_TEMPSENSOR, ICX3_TEMPSENSOR_SIZE, data);
if (read_result != ICX3_TEMPSENSOR_SIZE) {
close(fd);
return;
}
temp_sensors = (struct icx3_temp_sensors*) &data;
float cur_temp;
short cur_data;
for (int i=0; i<ICX3_NUM_TEMP_SENSORS; i++) {
/* endian swap */
cur_data = (short)(temp_sensors->data[2*i+1] << 8) | (short)(temp_sensors->data[2*i]);
/* temp is reported in tenths of deg C */
cur_temp = (float)cur_data/10;
printf("%s: %.1f C\n",
icx3_temp_sensor_names[i],
cur_temp);
} }
printf("%%");
} }
void get_available_fans(char *i2c_dev_path, char *fans_avail) void get_available_fans(char *fans_avail, struct card_info *card)
{ {
int product_id = check_for_icx3(i2c_dev_path); int product_id = card->product_id;
/* From ICX3TotalFanCtrl.cs */ /* From ICX3TotalFanCtrl.cs */
switch(product_id) { switch(product_id) {
@ -155,54 +124,77 @@ void get_available_fans(char *i2c_dev_path, char *fans_avail)
} }
} }
int open_i2c_dev(char *i2c_dev_path) void get_fan_status(struct icx3_fan_control *fans, struct card_info *card)
{ {
int fd = open(i2c_dev_path, O_RDONLY); char data[I2C_SMBUS_BLOCK_MAX] = {};
int read_result;
/* Error silently here because we should have already checked we can read the i2c in check_for_icx3() */ char fans_avail[ICX3_MAX_FANS] = {0};
if (fd == -1) get_available_fans(fans_avail, card);
return -1;
for (int i=0; i < ICX3_MAX_FANS; i++) {
if (ioctl(fd, I2C_SLAVE, ICX3_I2C_ADDR) < 0) { if (!fans_avail[i]) {
close(fd); continue;
return -1; }
read_result = i2c_smbus_read_i2c_block_data(card->i2c_fd, ICX3_REG_FANCONTROL + i, ICX3_FANCONTROL_SIZE, data);
if (read_result != ICX3_FANCONTROL_SIZE) {
return;
}
memcpy(&fans[i], &data, sizeof(struct icx3_fan_control));
} }
return fd;
} }
void enable_write(int enable, char *i2c_dev_path) void get_temp_sensors(float *temps, struct card_info *card)
{ {
int fd = open_i2c_dev(i2c_dev_path); char data[I2C_SMBUS_BLOCK_MAX] = {};
if (fd == -1) int read_result;
struct icx3_temp_sensors *temp_sensors;
read_result = i2c_smbus_read_i2c_block_data(card->i2c_fd, ICX3_REG_TEMPSENSOR, ICX3_TEMPSENSOR_SIZE, data);
if (read_result != ICX3_TEMPSENSOR_SIZE)
return; return;
temp_sensors = (struct icx3_temp_sensors*) &data;
float cur_temp;
short cur_data;
for (int i=0; i<ICX3_NUM_TEMP_SENSORS; i++) {
/* endian swap */
cur_data = (short)(temp_sensors->data[2*i+1] << 8) | (short)(temp_sensors->data[2*i]);
/* temp is reported in tenths of deg C */
temps[i] = (float)cur_data/10;
}
}
void enable_write(int enable, struct card_info *card)
{
unsigned char *data; unsigned char *data;
if (enable) if (enable)
data = icx3_write_enable; data = icx3_write_enable;
else else
data = icx3_write_disable; data = icx3_write_disable;
/* Enable or disable write */ /* Enable or disable write */
i2c_smbus_write_i2c_block_data(fd, ICX3_REG_ENABLEWRITE, ICX3_ENABLEWRITE_SIZE, data); i2c_smbus_write_i2c_block_data(card->i2c_fd, ICX3_REG_ENABLEWRITE, ICX3_ENABLEWRITE_SIZE, data);
/* Read back the result to verify */ /* Read back the result to verify */
unsigned char read_result[ICX3_ENABLEWRITE_SIZE]; unsigned char read_result[ICX3_ENABLEWRITE_SIZE];
int write_ok = 0; int write_ok = 0;
i2c_smbus_read_i2c_block_data(fd, ICX3_REG_ENABLEWRITE, ICX3_ENABLEWRITE_SIZE, read_result); i2c_smbus_read_i2c_block_data(card->i2c_fd, ICX3_REG_ENABLEWRITE, ICX3_ENABLEWRITE_SIZE, read_result);
if (enable) if (enable)
write_ok = (read_result[1] == 0xFC); write_ok = (read_result[1] == 0xFC);
else else
write_ok = (read_result[1] == 0xFE); write_ok = (read_result[1] == 0xFE);
if (!write_ok) if (!write_ok)
printf("Unable to enable/disable write on %s\n", i2c_dev_path); printf("Unable to enable/disable write on %s\n", card->i2c_dev_path);
} }
/* Sets a given fan on the GPU according to a string setting /* Sets a given fan on the GPU according to a string setting
'auto' resets the fan to default (fans 1-2 go to GPU control, 3-4 to +0 RPM offset from GPU control) 'auto' resets the fan to default (fans 1-2 go to GPU control, 3-4 to +0 RPM offset from GPU control)
A number without a sign (e.g. 50) manually sets the fan to a given % duty cycle A number without a sign (e.g. 50) manually sets the fan to a given % duty cycle
A number with a sign (e.g. +500) sets the fan to run at an RPM offset from GPU control */ A number with a sign (e.g. +500) sets the fan to run at an RPM offset from GPU control */
void set_fan(int fan, char *setting, char *i2c_dev_path) void set_fan(int fan, char *setting, struct card_info *card)
{ {
char fans_avail[ICX3_MAX_FANS] = {0}; char fans_avail[ICX3_MAX_FANS] = {0};
@ -213,15 +205,11 @@ void set_fan(int fan, char *setting, char *i2c_dev_path)
int write_result; int write_result;
/* Check to make sure we're setting a valid fan */ /* Check to make sure we're setting a valid fan */
get_available_fans(i2c_dev_path, fans_avail); get_available_fans(fans_avail, card);
if (fans_avail[fan] == 0) { if (fans_avail[fan] == 0) {
printf("Fan %d does not exist on this card \n", fan); printf("Fan %d does not exist on this card \n", fan);
return; return;
} }
int fp = open_i2c_dev(i2c_dev_path);
if (fp == -1)
return;
fan_control.length = ICX3_FANCONTROL_SIZE - 1; fan_control.length = ICX3_FANCONTROL_SIZE - 1;
if (strcmp(setting, "auto") == 0) { if (strcmp(setting, "auto") == 0) {
@ -240,16 +228,15 @@ void set_fan(int fan, char *setting, char *i2c_dev_path)
fan_control.duty = atoi(setting); fan_control.duty = atoi(setting);
} }
enable_write(1, i2c_dev_path); enable_write(1, card);
i2c_smbus_write_i2c_block_data(fp, reg, ICX3_FANCONTROL_SIZE, (char *)&fan_control); i2c_smbus_write_i2c_block_data(card->i2c_fd, reg, ICX3_FANCONTROL_SIZE, (char *)&fan_control);
/* Read back data and verify we set the fan properly */ /* Read back data and verify we set the fan properly */
i2c_smbus_read_i2c_block_data(fp, reg, ICX3_FANCONTROL_SIZE, (char *)&fan_readback); i2c_smbus_read_i2c_block_data(card->i2c_fd, reg, ICX3_FANCONTROL_SIZE, (char *)&fan_readback);
if (fan_readback.fanmode != fan_control.fanmode || if (fan_readback.fanmode != fan_control.fanmode ||
fan_readback.rpm_offset != fan_control.rpm_offset || fan_readback.rpm_offset != fan_control.rpm_offset ||
fan_readback.duty != fan_control.duty) fan_readback.duty != fan_control.duty)
printf("Error setting fan %d on %s\n", fan, i2c_dev_path); printf("Error setting fan %d on %s\n", fan, card->i2c_dev_path);
close(fp);
} }

23
icx3.h
View File

@ -1,3 +1,8 @@
#ifndef ICX3_H
#define ICX3_H
#include "evga-card.h"
#define ICX3_I2C_ADDR 0x2D #define ICX3_I2C_ADDR 0x2D
#define ICX3_REG_FANCONTROL 80 #define ICX3_REG_FANCONTROL 80
@ -111,10 +116,14 @@ static char *icx3_temp_sensor_names[] = {
"PWR5", "PWR5",
}; };
enum icx3_product_id check_for_icx3(char *i2c_dev_path); int icx3_init(struct card_info *card);
void print_icx3_fans(char *i2c_dev_path); void print_icx3_fans(struct card_info *card);
void print_icx3_temps(char *i2c_dev_path); void print_icx3_fans_oneline(struct card_info *card);
void get_available_fans(char *i2c_dev_path, char *fans_avail); void print_icx3_temps_oneline(struct card_info *card);
int open_i2c_dev(char *i2c_dev_path); void get_available_fans(char *fans_avail, struct card_info *card);
void enable_write(int enable, char *i2c_dev_path); void get_fan_status(struct icx3_fan_control *fans, struct card_info *card);
void set_fan(int fan, char *setting, char *i2c_dev_path); void get_temp_sensors(float *temps, struct card_info *card);
void enable_write(int enable, struct card_info *card);
void set_fan(int fan, char *setting, struct card_info *card);
#endif

View File

@ -1,16 +0,0 @@
.PHONY : clean debug
OBJS = evga-icx.o evga-card.o icx3.o
LDLIBS = -li2c
CFLAGS = -MD
evga-icx : $(OBJS)
debug : CFLAGS += -g -O0
debug : evga-icx
clean :
rm evga-icx $(OBJS)
rm *.d
-include $(OBJS:.o=.d)

95
nvidia-sensors.c Normal file
View File

@ -0,0 +1,95 @@
#include <stdio.h>
#include "nvidia-sensors.h"
void init_nvml()
{
nvmlReturn_t result;
result = nvmlInit_v2();
if (result != NVML_SUCCESS)
printf("Could not init NVML: %s\n", nvmlErrorString(result));
}
void get_nvml_handle(struct card_info *card)
{
nvmlReturn_t result;
result = nvmlDeviceGetHandleByPciBusId_v2(card->pci_id, card->nvml_device);
if (result != NVML_SUCCESS) {
printf("Failed to get NVML device handle for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
card->nvml_device = NULL;
}
}
void print_nvml_clock_reason(int compact, struct card_info *card)
{
unsigned long long reasons = get_nvml_clock_reasons(card);
int single_reason = 1;
for (int i = 0; i < (sizeof(clock_reason_names) / sizeof(struct clock_reason)); i++) {
if (reasons & clock_reason_names[i].mask) {
if (!single_reason) {
if (compact)
printf(",");
else
printf(", ");
}
single_reason = 0;
if (compact)
printf("%s", clock_reason_names[i].short_name);
else
printf("%s", clock_reason_names[i].long_name);
}
}
if (single_reason)
printf("None");
if (!compact)
printf(" (0x%llx)", reasons);
}
unsigned int get_nvml_temp(struct card_info *card)
{
if (card->nvml_device == NULL)
return 0;
unsigned int temp;
nvmlReturn_t result = nvmlDeviceGetTemperature(*(nvmlDevice_t*)(card->nvml_device), NVML_TEMPERATURE_GPU, &temp);
if (result != NVML_SUCCESS) {
printf("Failed to get temperature for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
return 0;
}
return temp;
}
unsigned long long get_nvml_clock_reasons(struct card_info *card)
{
if (card->nvml_device == NULL)
return 0;
unsigned long long reasons;
nvmlReturn_t result = nvmlDeviceGetCurrentClocksEventReasons(*(nvmlDevice_t*)(card->nvml_device), &reasons) ;
if (result != NVML_SUCCESS) {
printf("Failed to get clock reasons for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
return 0;
}
return reasons;
}
unsigned int get_nvml_mem_util(struct card_info *card)
{
if (card->nvml_device == NULL)
return 0;
nvmlUtilization_t util;
nvmlReturn_t result = nvmlDeviceGetUtilizationRates(*(nvmlDevice_t*)(card->nvml_device), &util);
if (result != NVML_SUCCESS) {
printf("Failed to get clock reasons for card at %s: %s\n", card->pci_id, nvmlErrorString(result));
return 0;
}
return util.memory;
}

29
nvidia-sensors.h Normal file
View File

@ -0,0 +1,29 @@
#include <nvml.h>
#include "evga-card.h"
struct clock_reason {
unsigned long long mask;
char *short_name;
char *long_name;
};
static struct clock_reason clock_reason_names[] =
{
{nvmlClocksEventReasonGpuIdle, "Idle", "GPU idle"},
{nvmlClocksEventReasonApplicationsClocksSetting, "AppClk", "Application clocks"},
{nvmlClocksEventReasonSwPowerCap, "Pwr", "Power cap"},
{nvmlClocksThrottleReasonHwSlowdown, "HWSlow", "Hardware slowdown"},
{nvmlClocksEventReasonSyncBoost, "Sync", "Sync boost"},
{nvmlClocksEventReasonSwThermalSlowdown, "SWTherm", "Software thermal"},
{nvmlClocksThrottleReasonHwThermalSlowdown, "HWTherm", "Hardware thermal"},
{nvmlClocksThrottleReasonHwPowerBrakeSlowdown, "HWPower", "Hardware power brake"},
{nvmlClocksEventReasonDisplayClockSetting, "DispClk", "Display clock"}
};
void init_nvml();
void get_nvml_handle(struct card_info *card);
void print_nvml_clock_reason(int compact, struct card_info *card);
unsigned int get_nvml_temp(struct card_info *card);
unsigned long long get_nvml_clock_reasons(struct card_info *card);
unsigned int get_nvml_mem_util(struct card_info *card);