Created
July 26, 2017 22:40
-
-
Save Findarato/1f4c7e1737519fd13efce6b5c3edc10b to your computer and use it in GitHub Desktop.
log nvidia-smi to a file so it can be parsed
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/bash | |
SHELL=/bin/bash | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
mkdir -p /opt/nvidia | |
UTC_DATE=$(date +'%Y/%m/%d %H:%M:%S.000' -u) | |
for INDEX in {0..10} | |
do | |
COMMAND="nvidia-smi -i $INDEX --query-gpu=name,pci.bus_id,driver_version,pstate,temperature.gpu,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used,fan.speed,power.draw,clocks.current.sm,clocks.current.memory,clocks.current.graphics,index --format=noheader,csv" | |
OUTPUT=$($COMMAND) | |
if [ "$OUTPUT" != "No devices were found" ]; then | |
echo $UTC_DATE, $OUTPUT >> /opt/nvidia/nvidia_log.csv | |
else | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment