Use GPU memory proportionally

I am looking for a reliable way to determine the current GPU memory usage, preferably in C ++ / C. I found many ways to get use, for example, the following methods:

  • Direct drawing
  • Dxdiag
  • Wmi
  • Dxgi
  • D3d9

These methods are not accurate enough (most of them are one hundred megabytes). I tried nvapi.h , but I did not see anything that I could use for a memory request. I thought that only the methods listed above were the only parameters, but then I came across a tool called GPU-Z , which gives me accurate readings in memory to the nearest megabyte, even when OpenCL almost completely loads my 580GTX. I can verify that I am at the peak of memory usage by allocating a few more megabytes before OpenCL returns the return code of Object_Allocation fail .

Looking at import from GPU-Z, I see nothing interesting except:

kernel32.dll: LoadLibraryA, GetProcAddress, VirtualAlloc, VirtualFree

My guess is LoadLibraryA should be used to load a dll to request GPU memory and sensors. If this DLL exists, where does it live? I am looking for a solution for AMD and NVidia, if possible (using different APIs is ok).

+7
source share
3 answers

cudaMemGetInfo (documented here ) requires nothing but the cuda API to get free memory and full memory on the current device.

And as Eric noted, NVML has similar functionality.

+9
source

Check the nvmlDeviceGetMemoryInfo function in the NVIDIA management library https://developer.nvidia.com/nvidia-management-library-nvml :

"Gets the amount of used, free and shared memory available on the device, in bytes."

I don't know if AMD has anything equivalent.

+1
source

D3DKMTQueryStatistics is what you need.

A similar question is asked here: How to request GPU usage in DirectX?

+1
source

All Articles