2023-11-29 19:00:37 +00:00
|
|
|
#ifndef __APPLE__
|
2024-03-25 15:07:44 +00:00
|
|
|
#ifndef __GPU_INFO_NVML_H__
|
|
|
|
#define __GPU_INFO_NVML_H__
|
2023-11-29 19:00:37 +00:00
|
|
|
#include "gpu_info.h"
|
|
|
|
|
|
|
|
// Just enough typedef's to dlopen/dlsym for memory information
|
|
|
|
typedef enum nvmlReturn_enum {
|
|
|
|
NVML_SUCCESS = 0,
|
|
|
|
// Other values omitted for now...
|
|
|
|
} nvmlReturn_t;
|
|
|
|
typedef void *nvmlDevice_t; // Opaque is sufficient
|
|
|
|
typedef struct nvmlMemory_st {
|
|
|
|
unsigned long long total;
|
|
|
|
unsigned long long free;
|
|
|
|
unsigned long long used;
|
|
|
|
} nvmlMemory_t;
|
|
|
|
|
2024-01-23 00:03:32 +00:00
|
|
|
typedef enum nvmlBrandType_enum
|
|
|
|
{
|
|
|
|
NVML_BRAND_UNKNOWN = 0,
|
|
|
|
} nvmlBrandType_t;
|
|
|
|
|
2024-03-25 15:07:44 +00:00
|
|
|
typedef struct nvml_handle {
|
2023-11-29 19:00:37 +00:00
|
|
|
void *handle;
|
2024-01-23 00:03:32 +00:00
|
|
|
uint16_t verbose;
|
2024-01-24 18:32:00 +00:00
|
|
|
nvmlReturn_t (*nvmlInit_v2)(void);
|
|
|
|
nvmlReturn_t (*nvmlShutdown)(void);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetHandleByIndex)(unsigned int, nvmlDevice_t *);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetMemoryInfo)(nvmlDevice_t, nvmlMemory_t *);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetCount_v2)(unsigned int *);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetCudaComputeCapability)(nvmlDevice_t, int* major, int* minor);
|
2024-01-23 00:03:32 +00:00
|
|
|
nvmlReturn_t (*nvmlSystemGetDriverVersion) (char* version, unsigned int length);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetName) (nvmlDevice_t device, char* name, unsigned int length);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetSerial) (nvmlDevice_t device, char* serial, unsigned int length);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetVbiosVersion) (nvmlDevice_t device, char* version, unsigned int length);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetBoardPartNumber) (nvmlDevice_t device, char* partNumber, unsigned int length);
|
|
|
|
nvmlReturn_t (*nvmlDeviceGetBrand) (nvmlDevice_t device, nvmlBrandType_t* type);
|
2024-03-25 15:07:44 +00:00
|
|
|
} nvml_handle_t;
|
2023-11-29 19:00:37 +00:00
|
|
|
|
2024-03-25 15:07:44 +00:00
|
|
|
typedef struct nvml_init_resp {
|
2023-11-29 19:00:37 +00:00
|
|
|
char *err; // If err is non-null handle is invalid
|
2024-03-25 15:07:44 +00:00
|
|
|
nvml_handle_t ch;
|
|
|
|
} nvml_init_resp_t;
|
2023-11-29 19:00:37 +00:00
|
|
|
|
2024-03-25 15:07:44 +00:00
|
|
|
typedef struct nvml_compute_capability {
|
2024-01-07 05:40:04 +00:00
|
|
|
char *err;
|
|
|
|
int major;
|
|
|
|
int minor;
|
2024-03-25 15:07:44 +00:00
|
|
|
} nvml_compute_capability_t;
|
2024-01-07 05:40:04 +00:00
|
|
|
|
2024-03-25 15:07:44 +00:00
|
|
|
void nvml_init(char *nvml_lib_path, nvml_init_resp_t *resp);
|
|
|
|
void nvml_check_vram(nvml_handle_t ch, mem_info_t *resp);
|
|
|
|
void nvml_compute_capability(nvml_handle_t ch, nvml_compute_capability_t *cc);
|
2024-03-30 22:34:21 +00:00
|
|
|
void nvml_release(nvml_handle_t ch);
|
2023-11-29 19:00:37 +00:00
|
|
|
|
2024-03-25 15:07:44 +00:00
|
|
|
#endif // __GPU_INFO_NVML_H__
|
2023-11-29 19:00:37 +00:00
|
|
|
#endif // __APPLE__
|