diff --git a/scripts/gpu.sh b/scripts/gpu.sh index 81bc22d..31e2e04 100755 --- a/scripts/gpu.sh +++ b/scripts/gpu.sh @@ -2,13 +2,17 @@ print_gpu_usage() { 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 - if [ -z "$GpuUsage" ]; then - echo "$gpuUsage%" - else + gpuUsage=("${gpuUsage[@]/%/%}") + + function join_by { local IFS="$1"; shift; echo "$*"; } + gpuUsage=`join_by " " ${gpuUsage[@]}` + if [ -z "$gpuUsage" ]; then echo "-" + else + echo "$gpuUsage" fi }