gpu_info_nvml.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef __APPLE__
  2. #ifndef __GPU_INFO_NVML_H__
  3. #define __GPU_INFO_NVML_H__
  4. #include "gpu_info.h"
  5. // Just enough typedef's to dlopen/dlsym for memory information
  6. typedef enum nvmlReturn_enum {
  7. NVML_SUCCESS = 0,
  8. // Other values omitted for now...
  9. } nvmlReturn_t;
  10. typedef void *nvmlDevice_t; // Opaque is sufficient
  11. typedef struct nvmlMemory_st {
  12. unsigned long long total;
  13. unsigned long long free;
  14. unsigned long long used;
  15. } nvmlMemory_t;
  16. typedef enum nvmlBrandType_enum
  17. {
  18. NVML_BRAND_UNKNOWN = 0,
  19. } nvmlBrandType_t;
  20. typedef struct nvml_handle {
  21. void *handle;
  22. uint16_t verbose;
  23. nvmlReturn_t (*nvmlInit_v2)(void);
  24. nvmlReturn_t (*nvmlShutdown)(void);
  25. nvmlReturn_t (*nvmlDeviceGetHandleByIndex)(unsigned int, nvmlDevice_t *);
  26. nvmlReturn_t (*nvmlDeviceGetMemoryInfo)(nvmlDevice_t, nvmlMemory_t *);
  27. nvmlReturn_t (*nvmlDeviceGetCount_v2)(unsigned int *);
  28. nvmlReturn_t (*nvmlDeviceGetCudaComputeCapability)(nvmlDevice_t, int* major, int* minor);
  29. nvmlReturn_t (*nvmlSystemGetDriverVersion) (char* version, unsigned int length);
  30. nvmlReturn_t (*nvmlDeviceGetName) (nvmlDevice_t device, char* name, unsigned int length);
  31. nvmlReturn_t (*nvmlDeviceGetSerial) (nvmlDevice_t device, char* serial, unsigned int length);
  32. nvmlReturn_t (*nvmlDeviceGetVbiosVersion) (nvmlDevice_t device, char* version, unsigned int length);
  33. nvmlReturn_t (*nvmlDeviceGetBoardPartNumber) (nvmlDevice_t device, char* partNumber, unsigned int length);
  34. nvmlReturn_t (*nvmlDeviceGetBrand) (nvmlDevice_t device, nvmlBrandType_t* type);
  35. } nvml_handle_t;
  36. typedef struct nvml_init_resp {
  37. char *err; // If err is non-null handle is invalid
  38. nvml_handle_t ch;
  39. } nvml_init_resp_t;
  40. typedef struct nvml_compute_capability {
  41. char *err;
  42. int major;
  43. int minor;
  44. } nvml_compute_capability_t;
  45. void nvml_init(char *nvml_lib_path, nvml_init_resp_t *resp);
  46. void nvml_check_vram(nvml_handle_t ch, mem_info_t *resp);
  47. void nvml_compute_capability(nvml_handle_t ch, nvml_compute_capability_t *cc);
  48. void nvml_release(nvml_handle_t ch);
  49. #endif // __GPU_INFO_NVML_H__
  50. #endif // __APPLE__