C++ NVidia NVML nvmlDeviceGetMemoryInfo()立即加载和卸载nvapi64.dll
我使用一些NVIDIA管理库功能在我的应用程序中生成度量 每1秒我在线程中调用nvmlDeviceGetMemoryInfo(),几分钟后,在Visual Studio的输出中,我可以读取数百个:C++ NVidia NVML nvmlDeviceGetMemoryInfo()立即加载和卸载nvapi64.dll,c++,windows,dll,nvml,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)
'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()时,加载的nvapi64.dll/卸载的nvapi64.dll上都有一对输出行
NVML随Cuda V10.2提供
您只需调用LoadLibraryW(L“nvapi64.dll”);在此dll之后,将不会卸载(RbMm)
这就成功了它会有什么回报?是调试还是发布?NV版本是什么?另外,您是否看到,对于一个函数调用,另一个.dll被加载/卸载了好几次?我已经用必需的信息编辑了这个问题,您只需调用
LoadLibraryW(L“nvapi64.dll”)代码>此dll之后将不会被卸载。我记得几年前某些NVidia驱动程序也有类似问题。在内部,有一些COM对象创建,导致加载英伟达驱动程序,在COM对象被破坏后,DLL立即卸载,这是非常浪费的。在使用ATI图形卡的机器之前,增加dll引用计数将一直有效。。。