fixed nvidia-smi output breaking check
This commit is contained in:
parent
2037c0815f
commit
7e30ea04db
1 changed files with 11 additions and 4 deletions
15
functions
15
functions
|
|
@ -1586,13 +1586,20 @@ get_power_info() {
|
|||
get_nvidia_power() {
|
||||
if command -v nvidia-smi >/dev/null 2>&1; then
|
||||
# Get power usage for all NVIDIA GPUs
|
||||
local gpu_count=$(nvidia-smi --query-gpu=count --format=csv,noheader,nounits)
|
||||
local gpu_count=$(nvidia-smi --query-gpu=count --format=csv,noheader,nounits | head -n 1)
|
||||
local total_gpu_power=0
|
||||
|
||||
for ((i=0; i<gpu_count; i++)); do
|
||||
# Validate that gpu_count is a number
|
||||
if ! [[ "$gpu_count" =~ ^[0-9]+$ ]]; then
|
||||
# If not a number, default to 1
|
||||
gpu_count=1
|
||||
fi
|
||||
|
||||
# Iterate from 0 to (count-1), not from 0 to count
|
||||
for ((i=0; i<$gpu_count; i++)); do
|
||||
# Get power draw and power limit for this GPU
|
||||
local power_draw=$(nvidia-smi --query-gpu=power.draw --format=csv,noheader,nounits -i $i)
|
||||
local power_limit=$(nvidia-smi --query-gpu=power.limit --format=csv,noheader,nounits -i $i)
|
||||
local power_draw=$(nvidia-smi --query-gpu=power.draw --format=csv,noheader,nounits -i $i )
|
||||
local power_limit=$(nvidia-smi --query-gpu=power.limit --format=csv,noheader,nounits -i $i )
|
||||
local gpu_name=$(nvidia-smi --query-gpu=name --format=csv,noheader -i $i | cut -c -20)
|
||||
|
||||
# Check if the value is valid (not N/A or empty)
|
||||
|
|
|
|||
Loading…
Reference in a new issue