gpu_info_cuda.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef __APPLE__
  2. #ifndef __GPU_INFO_CUDA_H__
  3. #define __GPU_INFO_CUDA_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 cuda_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. } cuda_handle_t;
  36. typedef struct cuda_init_resp {
  37. char *err; // If err is non-null handle is invalid
  38. cuda_handle_t ch;
  39. } cuda_init_resp_t;
  40. typedef struct cuda_compute_capability {
  41. char *err;
  42. int major;
  43. int minor;
  44. } cuda_compute_capability_t;
  45. void cuda_init(char *cuda_lib_path, cuda_init_resp_t *resp);
  46. void cuda_check_vram(cuda_handle_t ch, mem_info_t *resp);
  47. void cuda_compute_capability(cuda_handle_t ch, cuda_compute_capability_t *cc);
  48. #endif // __GPU_INFO_CUDA_H__
  49. #endif // __APPLE__