Graphics card idle power usage in unraid server


scorcho99

Recommended Posts

On 3/2/2021 at 3:41 PM, b0n3v said:

I edited the script provided by @mdsloop, now he working smooth, with cron run every 2 min.

 

VMnametocheck="Windows 10 Gaming"
stateofvm=$(virsh list --all | grep "$VMnametocheck" | awk 'NF{ print $NF }')
if [[ "$stateofvm" == "running"  ||  "$stateofvm" == "idle"  ||  "$stateofvm" == "paused" ]]; then
	echo "The $VMnametocheck VM is in $stateofvm state"
else
	echo "The $VMnametocheck VM is Shutted down! And now Nvidia GPU will go to power save state P8"
	nvidia-smi -pm 1
fi

 

 

Thanks for this work !

I discover just today my graphics cards used 18W all the time even with my Windows VM shutdown. Your script work perfectly in my case !

 

Have a great day.

Link to comment
  • 11 months later...
On 1/2/2023 at 10:24 AM, MeisterPilaf said:

Old Topic but maybe someone is interested in my Code:

 

# Get the number of GPUs
num_gpus=$(nvidia-smi --query-gpu=count --format=csv,noheader | awk 'NR==1 {sum+=$1} END {print sum}')

echo "Found $num_gpus GPUs."

# Iterate over the GPUs
for ((i=0; i< $num_gpus; i++)); do
  # Check if there are any processes running on GPU $i
  if nvidia-smi -i $i --query-compute-apps=pid --format=csv,noheader | grep -q '^[0-9]'; then
    echo "There are processes running on GPU $i."
  else
    echo "There are no processes running on GPU $i. Setting GPU $i to power save mode."
    nvidia-smi -i $i -pm 1
  fi
done

 

It first checks how many GPUS are installed and then if there are running processes. If not, Power save mode will be activated.

 

This worked for me on my Tesla P4. It was stuck at 1% being used by nothing, and kept idling at 24W, 800MHz GPU, 2000MHz Mem. This fixed it!

Link to comment
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.