Created
May 25, 2021 09:24
-
-
Save woolpeeker/24fc3f1d4bce5114d5e5486a4e53915c to your computer and use it in GitHub Desktop.
GPU_load_statistic
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
""" | |
Usage: | |
python gpu_analysis.py <gpu_load.txt> <gpu_num> | |
""" | |
import sys | |
gpu_num = int(sys.argv[2]) | |
total = 0 | |
utilized = 0 | |
for line in open(sys.argv[1]).readlines(): | |
line = line.rstrip() | |
data = line.split()[2:] | |
assert len(data) == gpu_num | |
data = [1 if int(x)>0 else 0 for x in data] | |
total += len(data) | |
utilized += sum(data) | |
print('utilization: %.3f' % (utilized / total)) |
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
# Usage: | |
# nohup bash gpu_load.sh &> gpu_load.txt & | |
while true; | |
do | |
t=`date --rfc-3339=second`; | |
u=`nvidia-smi | grep % | awk -F'|' '{print $4}' | awk -F'%' '{print $1}'`; | |
u=`echo $u | tr -s "\n" " "` | |
echo "$t $u"; | |
sleep 1; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment