Skip to content

Commit a173702

Browse files
committed
0 stat for power metric with [N/A] and N/A
1 parent 2539ca2 commit a173702

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

monitor_gpu.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ update_stats() {
253253
# Get current stats
254254
local timestamp=$(date '+%m-%d %H:%M:%S')
255255
# For testing, replace the nvidia-smi command with:
256-
# local gpu_stats="44, 0, 3, N/A"
256+
# local gpu_stats="44, 0, 3, [N/A]"
257257
local gpu_stats=$(nvidia-smi --query-gpu=temperature.gpu,utilization.gpu,memory.used,power.draw \
258258
--format=csv,noheader,nounits 2>/dev/null)
259259

@@ -265,10 +265,10 @@ update_stats() {
265265
local temp=$(echo "$gpu_stats" | cut -d',' -f1 | tr -d ' ')
266266
local util=$(echo "$gpu_stats" | cut -d',' -f2 | tr -d ' ')
267267
local mem=$(echo "$gpu_stats" | cut -d',' -f3 | tr -d ' ')
268-
local power=$(echo "$gpu_stats" | cut -d',' -f4 | tr -d ' ')
268+
local power=$(echo "$gpu_stats" | cut -d',' -f4 | tr -d ' []') # Remove both [ and ]
269269

270-
# Handle N/A power value
271-
if [[ "$power" == "N/A" || -z "$power" ]]; then
270+
# Handle N/A power value - now handles both N/A and [N/A]
271+
if [[ "$power" == "N/A" || -z "$power" || "$power" == "[N/A]" ]]; then
272272
power="0" # Using 0 as default for N/A power values
273273
fi
274274

0 commit comments

Comments
 (0)