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

标签 c++ windows dll nvml

我使用一些 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.dll
NVML 随 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/

相关文章:

python - OpenCV-Python导入错误: DLL load failed: The specified module could not be found

c++ - 如何隐藏 C++ 静态库中的符号?

c# - 将 .NET 配置为在 Windows 7 上使用 3.5,在 Windows 8 上使用 4.5

C++:改变指针字符串的值

java - 所有PC的固定绝对路径

python - 407 需要代理验证

c++ - 面向对象编程 c++ dll Code::Blocks

windows - 如果它的导出没有改变,我是否需要针对 dll 进行重建?

c++ - 使用 CUDA 和 Maya API 时命名空间发生冲突

c++ - C++ 指针指向数组 : invalid type argument of unary * (have 'int), 的错误需要左值作为赋值的左操作数