Skip to content

Instantly share code, notes, and snippets.

@sandeepkumar-skb
Created September 12, 2021 03:42
Show Gist options
  • Save sandeepkumar-skb/a6f71f7c8c6f1f28c20a7a44c9ea2202 to your computer and use it in GitHub Desktop.
Save sandeepkumar-skb/a6f71f7c8c6f1f28c20a7a44c9ea2202 to your computer and use it in GitHub Desktop.
from pynvml import *
nvmlInit()
deviceCount = nvmlDeviceGetCount()
# assume its 1 for now
handle = nvmlDeviceGetHandleByIndex(0)
util = nvmlDeviceGetUtilizationRates(handle)
print("GPU Util: ", util.gpu)
print("GPU Mem Util: ", util.memory)
nvmlShutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment