Last active
July 15, 2025 23:52
-
-
Save danilogco/864589db7fad0a1757dc1e44c4189e52 to your computer and use it in GitHub Desktop.
Increase Nvidia fan speed for Linux
This file contains hidden or 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 | |
# Paths to the utilities we will need | |
SMI='/usr/bin/nvidia-smi' | |
SET='/usr/bin/nvidia-settings' | |
# Determine major driver version | |
VER=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader | cut -d. -f1) | |
# Drivers from 285.x.y on allow persistence mode setting | |
if [ ${VER} -lt 285 ] | |
then | |
echo "Error: Current driver version is ${VER}. Driver version must be greater than 285."; exit 1; | |
fi | |
# Read a numerical command line arg between 40 and 100 | |
$SMI -pm 1 # enable persistance mode | |
speed=100 # set speed | |
echo "Setting fan to $speed%." | |
# how many GPU's are in the system? | |
NUMGPU="$(nvidia-smi -L | wc -l)" | |
# loop through each GPU and individually set fan speed | |
n=0 | |
while [ $n -lt $NUMGPU ]; | |
do | |
# call nvidia-settings to enable fan control and set speed | |
${SET} -a [gpu:0]/GpuPowerMizerMode=1 | |
${SET} -a [gpu:${n}]/GPUFanControlState=1 -a [fan:${n}]/GPUTargetFanSpeed=$speed -- :0 -once | |
let n=n+1 | |
done | |
echo "Complete"; exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment