Created
February 7, 2015 01:04
-
-
Save szagoruyko/d67f4f32fb363018b189 to your computer and use it in GitHub Desktop.
Nicer nvidia-smi output for GeForce cards
This file contains 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
#!/usr/bin/env python | |
import subprocess | |
import re | |
class bcolors: | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
process = subprocess.Popen(["nvidia-smi"], stdout=subprocess.PIPE) | |
result = process.communicate()[0] | |
spl = result.splitlines() | |
for line in spl: | |
if line.startswith(' '): | |
break | |
if line.find('GeForce') == -1: | |
line = re.sub('(\d+)C', bcolors.OKGREEN + r'\1C' + bcolors.ENDC, line) | |
line = re.sub('(\d+)MiB', bcolors.OKBLUE + r'\1MiB' + bcolors.ENDC, line) | |
print line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment