In linux, the fan speed is not controlled by default and the card itself auto adjusts the fan speed; in this tutorial I’m going to teach a way to Automatically and Manually control the fan speed of an Nvidia graphics card on Linux with proprietary drivers at Boot and Reboot.
Table of contents:
1. Controlling Fan Speed manually (Mandatory step)
2. Controlling Fan Speed Automatically at boot with a script
3. Controlling Fan Speed Automatically at boot with the Green With Envy GUI
4. Controlling Fan Speed Headlessly
1.Controlling fan speed Manually (Mandatory configuration changes)
Nvidia doesn’t enable this feature by default and it’s on the user to enable it using the command line.
Back in the days, it used to be
nvclock but the support was dropped in 2010. Here’s a short guide on how to control the fan using Nvidia X Server Settings.
The ‘Nvidia X server Settings’ application is installed along with the proprietary driver.The following command needs to be executed in Terminal to enable fan control in Nvidia X server Settings:
sudo nvidia-xconfig -a --cool-bits=28 --allow-empty-initial-configuration
Note that this might not work on some distributions and you may be required to edit
/etc/xorg.conf.d/20-nvidia.conf and add the following lines:
# You may change the identifier number to your use case.
BoardName "GeForce GTX"
VendorName "NVIDIA Corporation"
Option "Coolbits" "28"
Note: You may want to change the
Coolbits value to your own needs. The reference sheet is available at http://download.nvidia.com/XFree86/Linux-… But it’s recommended to keep it at 28 to enable all the features.
After this, a reboot or a logout is required to apply the changes.
After the reboot/login, open the
NVIDIA X Server Settings application
Go to the ‘Thermal Settings’ section and you can control the fan speed by your own hands:
2.Controlling fan speed Automatically at boot with a script (Step 1 required)
Now this was only controlling it manually through the
nvidia-settings software. These changes will not apply at boot and do not auto adjust; but the changes were required in order to enable fan control.
I found a little program on github to control the fan speed with a fan curve:
Download the program from github with this command:
git clone https://github.com/nan0s7/nfancurve
cd to the directory which it downloaded in:
now we see a few files:
The only file which needs to be modified is the
config file; inside this file, fan curve and some other options can be set; here are some of the important ones:
min_t="25" # This is the temperature which any number below it will cause the fan speed to drop to 0 fcurve = "30 37 45 55 57" # Fan Speeds tcurve = "45 55 65 75 85" # Temperatures
Now in this example; the fan speed would be 30% at the temperature of 45 Celsius, 37% at 55 Celsius and so on. after changing the values to your preference, save the changes.
The fan speed is controlled by file temp.sh. First make the script, executable with the command below:
chmod +x ./temp.sh
Then run the script:
If everything is working fine, the fan speed will adjust and you’ll see the changes on your terminal. Now stop the script by using
Now if I want the script to run at reboot without being bothered; it can be added to the startup applications manager of the DE(kde has ~/.config/autostart-scripts/) or add it to
~/.xprofile. The latter is highly recommended since it will start whenever your X server has started and every distribution supports it.
If you want to add it to your Desktop Environment’s startup application manager; just simply search it and add the
temp.sh script wherever you saved it. Every Desktop Environment is different and the process is super easy; so I’m not including it in this tutorial. You can search for it for your own Desktop Environment.
To add this script to
~/.xprofileand make it executable; do as follows:
echo '~/nfancurve/temp.sh &' >> ~/.xprofile
chmod +x ~/.xprofile
Or just edit it with your own text editor. Note that this file might not exist in some cases; but it will execute anyways.
Save the file and wallah! Now the script will run and auto adjust the fan speed by the curve set at boot.
3.Controlling fan speed Automatically at boot with the Green With Envy GUI
There is a nice GUI to properly control Nvidia graphics cards in linux called Green With Envy or GWE for short.
It’s not available in ubuntu’s official repos as of now but it’s available on
flatpak. Setup flatpak using this link: https://flatpak.org/setup/.
After setting up flatpak; install GWE with the following commands:
flatpak install flathub com.leinardi.gwe
After that, you can run it with the following command:
flatpak run com.leinardi.gwe
Working with the GUI is pretty easy and straightforward(Hell, that’s why I introduced it) and doesn’t require explanation.
This program can be added to startup by adding the above to
~/.xprofile; To do so, execute the following:
echo 'flatpak run com.leinardi.gwe --hide-window &' >> ~/.xprofile
By default, this program cannot add itself to startup but the above will work around that.
4. Controlling Fan Speed Headlessly
In order to control an nvidia graphics card’s fan speed headlessly; an X server needs to be started. It can be the minimum. Just to get X initialized; then
nvidia-settings will work and so will tools such as nfancurve.
There is a great tool to do that automatically by starting an X server for each gpu: https://github.com/andyljones/coolgpus
Apparently nvidia unlike amd doesn’t provide hwmon in sysfs in order to control the fans.