Skip to content

Instantly share code, notes, and snippets.

@ArrEssJay
Last active September 20, 2017 02:57
Show Gist options
  • Save ArrEssJay/a960c2b157256c162220e60300529cf0 to your computer and use it in GitHub Desktop.
Save ArrEssJay/a960c2b157256c162220e60300529cf0 to your computer and use it in GitHub Desktop.
Set NVIDIA fan speed under fake X server
# This needs to be called from xinit
# See https://gist.github.com/RobDeBagel/0e126a56b0ee9f23551a98fb258414c
# Set fan speeds appropriately. The curve is tailored to my own environment
# Also set clock speeds
#!/bin/bash
setFanSpeed() {
eval "nvidia-settings -a [gpu:$2]/GPUFanControlState=1 -a [fan:$2]/GPUTargetFanSpeed=$1" > /dev/null
# echo "Updating fans speed to $1 on GPU $2"
}
cleanup() {
eval "nvidia-settings -a [gpu:0]/GPUFanControlState=0"
eval "nvidia-settings -a [gpu:1]/GPUFanControlState=0"
eval "nvidia-settings -a [gpu:2]/GPUFanControlState=0"
eval "nvidia-settings -a [gpu:3]/GPUFanControlState=0"
exit
}
declare -i gpuTemp
# Set cleanup function (clean up and exit when interrupted)
trap cleanup 1 2 3 15 20
checkGpu(){
# echo "Checking GPU $1"
gpuTemp=$(nvidia-settings -q gpucoretemp | grep '^ Attribute' | grep "gpu:$1" | \
head -n 1 | perl -pe 's/^.*?(\d+)\.\s*$/\1/;')
# echo "Current GPU $1 temperature: $gpuTemp"
# Set GPU fan speed
if [ $gpuTemp -ge 80 ]; then
setFanSpeed 100 $1
elif [ $gpuTemp -ge 70 ]; then
setFanSpeed 75 $1
elif [ $gpuTemp -ge 65 ]; then
setFanSpeed 60 $1
elif [ $gpuTemp -ge 60 ]; then
setFanSpeed 45 $1
elif [ $gpuTemp -ge 55 ]; then
setFanSpeed 30 $1
elif [ $gpuTemp -ge 50 ]; then
setFanSpeed 20 $1
else
setFanSpeed 15 $1
fi
}
/usr/bin/nvidia-settings -a '[gpu:0]/GPUGraphicsClockOffset[2]=100'
/usr/bin/nvidia-settings -a '[gpu:0]/GPUMemoryTransferRateOffset[2]=1400'
/usr/bin/nvidia-settings -a '[gpu:1]/GPUGraphicsClockOffset[2]=100'
/usr/bin/nvidia-settings -a '[gpu:1]/GPUMemoryTransferRateOffset[2]=1400'
/usr/bin/nvidia-settings -a '[gpu:2]/GPUGraphicsClockOffset[2]=100'
/usr/bin/nvidia-settings -a '[gpu:2]/GPUMemoryTransferRateOffset[2]=1400'
/usr/bin/nvidia-settings -a '[gpu:3]/GPUGraphicsClockOffset[2]=100'
/usr/bin/nvidia-settings -a '[gpu:3]/GPUMemoryTransferRateOffset[2]=140'
while : # Loop
do
checkGpu 0
checkGpu 1
checkGpu 2
checkGpu 3
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment