I'm trying to get info about how much GPU % is currently used. I'm running script below and get result.
import os
get_total_gpu = 'C:\Windows\System32\DriverStore\FileRepository\\nvmdi.inf_amd64_36ae6ddd01b54f49\\nvidia-smi ' \
'--query-gpu=memory.total--format=csv'
val=os.system(get_total_gpu )
print(val)
memory.total [MiB]
4096 MiB
1
Process finished with exit code 0
However, the result is in weird format and I cannot get the value from it (4096 MiB. I have GTX 1650). I ran type(val) and it gives me class int. How can this be an integer? This more looks like a formatted string. Please explain me what's happening here and how can I get the number.
Thanks in advance!
systemis the exit code of the process, not it's captured standard or error outputget_total_gpustring. The1in the third line is from yourprint(val)- please read the docs on the things you are using, don't make weird assumption. As @Homer512 pointed out, you should use a different method to get the return value of your command string and then you'll have to parse it.