2023-11-29 19:00:37 +00:00
|
|
|
#ifndef __APPLE__
|
|
|
|
#ifndef __GPU_INFO_CUDA_H__
|
|
|
|
#define __GPU_INFO_CUDA_H__
|
|
|
|
#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;
|
|
|
|
|
2023-11-29 19:00:37 +00:00
|
|
|
typedef struct cuda_handle {
|
|
|
|
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);
|
2023-11-29 19:00:37 +00:00
|
|
|
} cuda_handle_t;
|
|
|
|
|
|
|
|
typedef struct cuda_init_resp {
|
|
|
|
char *err; // If err is non-null handle is invalid
|
|
|
|
cuda_handle_t ch;
|
|
|
|
} cuda_init_resp_t;
|
|
|
|
|
2024-01-07 05:40:04 +00:00
|
|
|
typedef struct cuda_compute_capability {
|
|
|
|
char *err;
|
|
|
|
int major;
|
|
|
|
int minor;
|
|
|
|
} cuda_compute_capability_t;
|
|
|
|
|
2024-01-10 22:39:51 +00:00
|
|
|
void cuda_init(char *cuda_lib_path, cuda_init_resp_t *resp);
|
2023-11-29 19:00:37 +00:00
|
|
|
void cuda_check_vram(cuda_handle_t ch, mem_info_t *resp);
|
2024-01-07 05:40:04 +00:00
|
|
|
void cuda_compute_capability(cuda_handle_t ch, cuda_compute_capability_t *cc);
|
2023-11-29 19:00:37 +00:00
|
|
|
|
|
|
|
#endif // __GPU_INFO_CUDA_H__
|
|
|
|
#endif // __APPLE__
|