Skip to content

Instantly share code, notes, and snippets.

@cvramanan
Created December 11, 2023 10:34
Show Gist options
  • Select an option

  • Save cvramanan/8fa21e55f5415a9a0eccc92b4febbe4e to your computer and use it in GitHub Desktop.

Select an option

Save cvramanan/8fa21e55f5415a9a0eccc92b4febbe4e to your computer and use it in GitHub Desktop.
import subprocess
import time
cmd = [ 'nvidia-smi', '--query-gpu=utilization.gpu,utilization.memory', '--format=csv' ]
while True:
time.sleep(1)
output = subprocess.Popen( cmd, stdout=subprocess.PIPE ).communicate()[0]
print(output.decode('utf-8').strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment