NVidia NVML nvmlDeviceGetMemoryInfo() 立即加载和卸载 nvapi64.dll

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

我使用一些 NVIDIA 管理库功能在我的应用程序中生成指标。

我每 1 秒在一个线程中调用 nvmlDeviceGetMemoryInfo(),几分钟后,在 Visual Studio 的输出中,我可以读取数百个 :

'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'
...

NVML 中的其他函数,如 nvmlDeviceGetCount()、nvmlDeviceGetHandleByIndex()、nvmlDeviceGetClockInfo() 或 nvmlDeviceGetUtilizationRates() 不会产生 nvapi64.dll 的准时 loading/unloading。

是否可以避免卸载此 dll,以使其在我下次调用 nvmlDeviceGetMemoryInfo() 时可用?

编辑:

我这样调用这个函数来检索 gpu 内存统计信息:

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

我在 Debug 和 Release 中看到这些输出行,每次我调用 nvmlDeviceGetMemoryInfo() 时都会有 Loaded nvapi64.dll / Unloaded nvapi64.dll

NVML 随 Cuda V10.2 一起提供。

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

成功了