Last active
February 1, 2025 16:22
-
-
Save Blayung/cabac85f656b88fd882b5dd692f52a0c to your computer and use it in GitHub Desktop.
Nvidia gpu usage python script for i3blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import bs4 | |
import subprocess | |
xmlData = bs4.BeautifulSoup(subprocess.check_output(["nvidia-smi", "-q", "-x"]), "xml") | |
print(f"{xmlData.find('gpu_util').string[:-2]}%, {xmlData.find('memory_util').string[:-2]}%") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment