Skip to content

Instantly share code, notes, and snippets.

@rkfg
Created May 28, 2021 08:57
Show Gist options
  • Save rkfg/9d28e6317b64ba66e0b6d3b75aca8342 to your computer and use it in GitHub Desktop.
Save rkfg/9d28e6317b64ba66e0b6d3b75aca8342 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Make sure to enable nvidia-xconfig --cool-bits=4
# nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan-0]/GPUTargetFanSpeed=5"
#[ $( pgrep -c FanCurveScript ) -lt 2 ] || exit 1 # already running
newfanspeed="0"
while true
do
gputemp=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits)
case "${gputemp}" in
0[0-9])
newfanspeed="0"
;;
1[0-9])
newfanspeed="0"
;;
2[0-9])
newfanspeed="0"
;;
3[0-9])
newfanspeed="0"
;;
4[0-4])
newfanspeed="0"
;;
4[5-9])
;;
5[0-4])
newfanspeed="20"
;;
5[5-6])
;;
5[7-9])
newfanspeed="40"
;;
6[0-1]) ;;
6[2-5])
newfanspeed="50"
;;
6[6-9])
;;
7[0-5])
newfanspeed="65"
;;
7[6-9])
newfanspeed="80"
;;
*)
newfanspeed="100"
;;
esac
nvidia-settings -a "[fan-0]/GPUTargetFanSpeed=${newfanspeed}" 2>&1 | grep -q ERROR
if [ $? -eq 0 ]
then
nvidia-settings -a ":0/GPUPowerMizerMode=1" >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Set powermizer mode"
else
echo "Error setting powermizer mode"
fi
nvidia-settings -a ":0/GPUFanControlState=1" >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Enabled fan control"
else
echo "Error enabling fan control"
fi
fi
sleep 10s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment