How to measure GPU usage per process in Windows using python?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to measure GPU usage per process in Windows using python?



I would like to measure the GPU usage per process as done in Windows taskmgr.exe, but I have encountered several problems when attempting to use the pyNVML library. As a result, I have a few questions.



First, is it currently possible to measure the exact GPU usage per process in Windows using Python? I have already tried the nvidia-smi query, but this doesn't seem to show memory used and utilization percent for each process.


nvidia-smi



Second, if it is possible to measure GPU usage in this way using Python, I would like to measure and show it in a similar fashion as done in the Windows taskmgr.exe of Windows 10.



Here is my code so far:


nvmlInit()
deviceCount = nvmlDeviceGetCount()
#print(deviceCount)
for device_id in range(deviceCount):
hd = nvmlDeviceGetHandleByIndex(device_id)
#print(handle)

cps = nvmlDeviceGetGraphicsRunningProcesses(hd)

for ps in cps :
pp = ps.pid
#print(pp)
try :
name = str(nvmlSystemGetProcessName(ps.pid))
n = name.split("\")
#print(n[len(n)-1][:-1])
process_name = n[len(n)-1][:-1]
if process_name == 'chrome.exe':
print(process_name, pp, ps.usedGpuMemory)
except:
pass



and my result:


chrome.exe 16688 None



nvidia-smi



As you can see, this does not reveal the GPU memory usage per process, but I need the information shown in taskmgr's GPU section. (I have no need of visualization.)



taskmgr



My computer specs are Windows 10 pro, GTX 950, i5-6600



If this is impossible in Python at the moment, do you have any other recommendations to automatically collect GPU usage per process.



Thank you.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS