gpu_info_nvml.h 2 KB
Newer Older
1
#ifndef __APPLE__
2
3
#ifndef __GPU_INFO_NVML_H__
#define __GPU_INFO_NVML_H__
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#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;

18
19
20
21
22
typedef enum nvmlBrandType_enum
{
    NVML_BRAND_UNKNOWN          = 0,
} nvmlBrandType_t;

23
typedef struct nvml_handle {
24
  void *handle;
25
  uint16_t verbose;
26
27
28
29
30
31
  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);
32
33
34
35
36
37
  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);
38
} nvml_handle_t;
39

40
typedef struct nvml_init_resp {
41
  char *err;  // If err is non-null handle is invalid
42
43
  nvml_handle_t ch;
} nvml_init_resp_t;
44

45
typedef struct nvml_compute_capability {
46
47
48
  char *err;
  int major;
  int minor;
49
} nvml_compute_capability_t;
50

51
52
53
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);
54

55
#endif  // __GPU_INFO_NVML_H__
56
#endif  // __APPLE__