Created
August 4, 2017 05:03
-
-
Save yiwenlu66/b32d6c70bb7448b7b7939b59b8d5bb09 to your computer and use it in GitHub Desktop.
A simple script to run a command as soon as a GPU is idle.
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
import subprocess | |
import time | |
import re | |
import sys | |
while True: | |
out = subprocess.check_output('nvidia-smi') | |
usage = int(re.search(b'\d*MiB /', out).group(0).split(b'M')[0]) | |
if usage < 1000: | |
subprocess.Popen(sys.argv[1:]) | |
break | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment