Skip to content

Commit

Permalink
new NVIDIA drivers fix
Browse files Browse the repository at this point in the history
  • Loading branch information
S74nk0 committed Dec 17, 2020
1 parent b33c4f2 commit 6767616
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion device_detection/detect_nvidia_nvml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ void detect_nvidia_nvml::fill_nvidia_device_names(std::vector<std::string>& devi
}

typedef int(*nvml_Init)(void);
typedef int(*nvml_InitWithFlags)(unsigned int flags);
typedef int(*nvml_Shutdown)(void);
typedef nvmlReturn_t(*nvml_DeviceGetCount)(unsigned int* deviceCount);
typedef nvmlReturn_t(*nvml_DeviceGetHandleByIndex_v2)(unsigned int index, nvmlDevice_t* device);
typedef nvmlReturn_t(*nvml_DeviceGetMemoryInfo)(nvmlDevice_t device, nvmlMemory_t* memory);
typedef nvmlReturn_t(*nvml_DeviceGetName)(nvmlDevice_t device, char* name, unsigned int length);

nvml_Init NVMLInit = nullptr;
nvml_InitWithFlags NVMLInitWithFlags = nullptr;
nvml_Shutdown NVMLShutdown = nullptr;
nvml_DeviceGetCount NVMLDeviceGetCount = nullptr;
nvml_DeviceGetHandleByIndex_v2 NVMLDeviceGetHandleByIndex_v2 = nullptr;
Expand All @@ -73,6 +75,7 @@ bool nvml_init() {
if (hmod == NULL) return false;

NVMLInit = (nvml_Init)GetProcAddress(hmod, "nvmlInit_v2");
NVMLInitWithFlags = (nvml_InitWithFlags)GetProcAddress(hmod, "nvmlInitWithFlags");
NVMLShutdown = (nvml_Shutdown)GetProcAddress(hmod, "nvmlShutdown");
NVMLDeviceGetCount = (nvml_DeviceGetCount)GetProcAddress(hmod, "nvmlDeviceGetCount");
NVMLDeviceGetHandleByIndex_v2 = (nvml_DeviceGetHandleByIndex_v2)GetProcAddress(hmod, "nvmlDeviceGetHandleByIndex_v2");
Expand All @@ -81,7 +84,8 @@ bool nvml_init() {

int initStatus = -1;
if (NVMLInit) {
initStatus = NVMLInit();
//initStatus = NVMLInit();
initStatus = NVMLInitWithFlags(0);
}
return NVML_SUCCESS == initStatus;
}
Expand Down

0 comments on commit 6767616

Please sign in to comment.