NVidia NVML nvmlDeviceGetMemoryInfo() loads and unloads nvapi64.dll immediately

1k views Asked by At

I use some NVIDIA Management Library features to produce metrics in my application.

Every 1 second I call nvmlDeviceGetMemoryInfo() in a thread, and after a few minutes, in the output of Visual Studio, I can read hundreds of :

'MyApp.exe' (Win32): Loaded 'C:\Windows\System32\nvapi64.dll'. 
'MyApp.exe' (Win32): Unloaded 'C:\Windows\System32\nvapi64.dll'
...
'MyApp.exe' (Win32): Loaded 'C:\Windows\System32\nvapi64.dll'. 
'MyApp.exe' (Win32): Unloaded 'C:\Windows\System32\nvapi64.dll'
'MyApp.exe' (Win32): Loaded 'C:\Windows\System32\nvapi64.dll'. 
'MyApp.exe' (Win32): Unloaded 'C:\Windows\System32\nvapi64.dll'
...

Other functions from NVML like nvmlDeviceGetCount(), nvmlDeviceGetHandleByIndex(), nvmlDeviceGetClockInfo() or nvmlDeviceGetUtilizationRates() don't produce this ponctual loading/unloading of the nvapi64.dll.

Is it possible to avoid unloading this dll, to keep it available for my next call to nvmlDeviceGetMemoryInfo() ?

EDIT :

I call this function to retreive gpu memory statistics like that :

nvmlMemory_t memInfo;
if (nvmlDeviceGetMemoryInfo(device, &memInfo) == NVML_SUCCESS) {
    this->gpuMemUsed = memInfo.used;
    this->gpuMemTotal = memInfo.total;
}

I see these output line in Debug and Release, each time I call nvmlDeviceGetMemoryInfo() there is on couple of Loaded nvapi64.dll / Unloaded nvapi64.dll

NVML comes with Cuda V10.2 .

1

There are 1 answers

0
SamT On BEST ANSWER

you can simply call LoadLibraryW(L"nvapi64.dll"); after this dll already will be not unloaded (RbMm)

This did the trick