我使用一些 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。是否可以避免卸载此 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.dllNVML 随 Cuda V10.2 一起提供。
最佳答案
you can simply call LoadLibraryW(L"nvapi64.dll"); after this dll already will be not unloaded (RbMm)
这成功了
关于c++ - NVidia NVML nvmlDeviceGetMemoryInfo() 立即加载和卸载 nvapi64.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64462814/