add multi gpu support, closes #1

This commit is contained in:
daniel
2020-08-02 12:37:13 +02:00
parent 1d48d195c5
commit 6aa2a76a90

View File

@@ -2,13 +2,17 @@
print_gpu_usage() { print_gpu_usage() {
function getGPUUsage() { function getGPUUsage() {
gpuUsage=$(nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}') gpuUsage=($(nvidia-smi -q -d UTILIZATION | grep Gpu | awk '{print $3}'))
} }
getGPUUsage getGPUUsage
if [ -z "$GpuUsage" ]; then gpuUsage=("${gpuUsage[@]/%/%}")
echo "$gpuUsage%"
else function join_by { local IFS="$1"; shift; echo "$*"; }
gpuUsage=`join_by " " ${gpuUsage[@]}`
if [ -z "$gpuUsage" ]; then
echo "-" echo "-"
else
echo "$gpuUsage"
fi fi
} }