kiki Posted February 1, 2023 Share Posted February 1, 2023 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. Quote Link to comment
stry8993 Posted January 9 Share Posted January 9 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! Quote Link to comment
methanoid Posted March 16 Share Posted March 16 What about AMD GPUs.. do they have this problem?? Quote Link to comment
Recommended Posts
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.