Last active
April 27, 2024 10:07
-
-
Save korvinko/ad729a6901603156b1852a3123101658 to your computer and use it in GitHub Desktop.
Nvidia fan curve control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Enable fan control | |
nvidia-settings -a "[gpu:0]/GPUFanControlState=1" | |
while true; do | |
# Get the current GPU temperature | |
temp=$(nvidia-settings -q gpucoretemp -t) | |
# Define fan speed based on temperature ranges | |
if [ "$temp" -lt 50 ]; then | |
# 30% fan speed if temp is below 50 degrees | |
speed=30 | |
elif [ "$temp" -lt 55 ]; then | |
# 40% fan speed if temp is between 50 and 55 degrees | |
speed=40 | |
elif [ "$temp" -lt 60 ]; then | |
# 50% fan speed if temp is between 55 and 60 degrees | |
speed=50 | |
elif [ "$temp" -lt 65 ]; then | |
# 60% fan speed if temp is between 60 and 65 degrees | |
speed=60 | |
elif [ "$temp" -lt 70 ]; then | |
# 70% fan speed if temp is between 65 and 70 degrees | |
speed=70 | |
elif [ "$temp" -lt 75 ]; then | |
# 80% fan speed if temp is between 70 and 75 degrees | |
speed=80 | |
elif [ "$temp" -lt 80 ]; then | |
# 90% fan speed if temp is between 75 and 80 degrees | |
speed=90 | |
else | |
# 95% fan speed if temp is above 80 degrees | |
speed=95 | |
fi | |
# Print current temperature and fan speed | |
echo "Current temperature: $temp°C, Fan speed: $speed%" | |
# Set the fan speed | |
if nvidia-settings -a "[fan:0]/GPUTargetFanSpeed=$speed"; then | |
echo "Fan speed set to $speed%" | |
else | |
echo "Error setting fan speed" | |
fi | |
# Sleep for 1 second before checking again | |
sleep 1 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=NVIDIA Fan Control Service | |
After=multi-user.target | |
[Service] | |
User=root | |
ExecStart=/bin/bash /usr/local/bin/fan-control.sh | |
Restart=always | |
Environment="DISPLAY=:1" | |
Environment="XAUTHORITY=/run/user/1000/gdm/Xauthority" | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment