Advertisement
Guest User

adaptive fan speed management for NVIDIA GPUs on Linux

a guest
Jul 28th, 2017
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.47 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. #----------------------------------------------------------------------
  4. # Description: adaptive fan speed management for NVIDIA GPUs on Linux
  5. # Author:  Artem S. Tashkinov
  6. # Created at: Fri Jul 10 07:47:43 GMT 2015
  7. # Computer: localhost.localdomain
  8. # System: Linux 4.1.0-ic on i686
  9. #
  10. # Copyright (c) 2015 Artem S. Tashkinov  All rights reserved.
  11. #
  12. # WARNING: I'm not liable for any damage to your GPU if you decide to
  13. #          use this script
  14. #
  15. #----------------------------------------------------------------------
  16.  
  17. polltime=2 # in seconds
  18.  
  19. range[0]="0 39"
  20. dtemp[0]=35
  21. range[1]="40 59"
  22. dtemp[1]=45
  23. range[2]="60 79"
  24. dtemp[2]=55
  25. range[3]="80 200"
  26. dtemp[3]=80
  27.  
  28. trap ctrl_c INT
  29.  
  30. ctrl_c() {
  31.     echo
  32.     echo -n "Resetting GPU fan management: "
  33.     nvidia-settings -a [gpu:0]/GPUFanControlState=0 &>/dev/null && echo "OK" || echo "Failed!"
  34.     exit 0
  35. }
  36.  
  37. result=`nvidia-settings -a [gpu:0]/GPUFanControlState=1 | grep "value 1"`
  38. test -z "$result" && echo "Fan speed management is not supported on this GPU. Exiting" && exit 1
  39.  
  40. while :; do
  41.     temp=`nvidia-settings -q GPUCoreTemp -t | head -1`
  42.  
  43.     i=0
  44.     while [ "x${range[i]}" != "x" ]; do
  45.         read lo hi <<<$(echo ${range[$i]})
  46.  
  47.         if [ $temp -ge $lo -a $temp -le $hi ]; then
  48.             echo "GPU Temperature: ${temp}. Setting GPU fan speed to ${dtemp[$i]}%"
  49.             nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=${dtemp[$i]}" &> /dev/null
  50.         fi
  51.  
  52.         i=$((i+1))
  53.     done
  54.  
  55.     sleep $polltime
  56. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement