How to get current GPU usage percentage with C++ program?

I have Cuda 11.5 toolkit installed. And I have found samples there named : deviceQuery. This will list out all the necessary information of the device but I am not able to find any api through which I can get current GPU utilization.

Is there any sample to check current GPU utilization at runtime?

Please help me, Thanks in advance.


You might want to look at SM utilization - you can gather that with DCGM, or if you would like to integrate the measurement into your application or develop a standalone tool, you can use CUPTI. Additionally, Nsight Systems and Nsight Compute are good tools to analyze application performance.

If you’d like to take a look at CUPTI samples, those are installed in {cuda install dir}/extras/CUPTI/samples. There are different APIs you may need to use depending on which hardware you have - what device are you trying to run on?

Thank you