If you just want a command: nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=60 Shouldn’t need sudo/root/elevated permissions but YMMV. But I wanted to give a full explanation/guide. I stumbled across this post while trying to find the answer myself, and through the answers here I fou… Answer from mdk.devvie on forums.developer.nvidia.com
🌐
Reddit
reddit.com › r/linux_gaming › heya, need a good way to control fan curve on linux - nvidia
r/linux_gaming on Reddit: Heya, need a good way to control fan curve on Linux - NVIDIA
February 26, 2024 -

So, let me summarize to a lot of you.

my GPU is a 1660 Super, and since NVIDIA has a lot of problems on Linux I tend to try and find solutions and alternatives, but nothing seems to get to fix it.

I want to set a fan curve for my GPU, and Green With Envy sadly seems to just never work.

Even after setting the optimal settings, and enabling coolbits, it still refuses to work no matter what. If there is some kind of way to control fans for GPU fans on Linux, I would be very glad and it would help me a lot.

NVIDIA in general is still awful on Linux from my point of view, but i'm hoping those kinds of things will improve in the future.

🌐
NVIDIA Developer Forums
forums.developer.nvidia.com › accelerated computing › cuda › cuda programming and performance
How to set fanspeed in Linux from terminal - CUDA Programming and Performance - NVIDIA Developer Forums
April 8, 2019 - I’m just trying to find help on how to manually set my fan speed on my Nvidia GPU. the command: nvidia-settings -a “[gpu:0]/GPUFanControlState=1” -a “[fan:0]/GPUCurrentFanSpeed=n” ...
Top answer
1 of 10
26

In the terminal run:

sudo nvidia-xconfig
sudo nvidia-xconfig --cool-bits=4

restart your computer and search for NVIDIA X Server Settings in the Dash. There should be an option to change fan speed under Thermal Settings.

2 of 10
8

To control Nvidia GPU fan speed via Terminal on Linux Mint 20 with a 1070 Ti:

sudo nvidia-xconfig --cool-bits=4

to tell nvidia-xconfig to allow the fan to be controlled in the command line. You may need to reboot here.

nvidia-smi

Gives information about the GPU(s) and their numbers. Importantly I note that my 1070 Ti is GPU 0.

nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=55"

For a much more detailed overview of this feature including multiple GPU fans, check out this thorough documentation Nvidia Overclocking and Cooling

For a somewhat rambling and wayward thread which lead me to the above link, check out Set Fanspeed in Linux from Terminal

==================END OF ANSWER==================

And as an extra tidbit not asked for in this question, you can also adjust the power output of your Nvidia GPU with:

sudo nvidia-smi -i 0 -pl 90

Where the 0 is my GPU number, and the 90 is the maximum power in watts. If you set this too low, you will get an error. In my limited experience, setting it too high had no effect. I found I can get 95%+ performance for ~75% energy cost by setting the power level to 100 in the above command in my mining rig, but I imagine other power conscious users would appreciate this too.

🌐
ArchWiki
wiki.archlinux.org › title › NVIDIA › Tips_and_tricks
NVIDIA/Tips and tricks - ArchWiki
3 weeks ago - Place the following line in your xinitrc file to adjust the fan when you launch Xorg. Replace n with the fan speed percentage you want to set. nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=n"
🌐
Massed Compute
massedcompute.com › home › faq – answers
How do I use NVIDIA SMI to set a custom fan speed on my NVIDIA GPU? - Massed Compute
July 8, 2024 - Set custom fan speed on NVIDIA GPU with NVIDIA SMI: learn how to adjust fan settings for optimal performance.
🌐
Reddit
reddit.com › r/linux_gaming › setting nvidia gpu fan speed
r/linux_gaming on Reddit: Setting Nvidia GPU fan speed
July 19, 2021 - Kind of a noob. Everything I've looked up suggested nvidia-settings -a [fan:0]/GPUTargetFanSpeed=80 to set the fan speed. This works as far as `nvidia-smi` and so forth, things reported the speed change.
🌐
Medium
medium.com › @s1ddok › control-your-gpu-fan-speeds-while-connecting-to-your-machine-via-ssh-e01895b8909e
Control your GPU fan speeds while connecting to your machine via SSH | by Andrey Volodin | Medium
October 14, 2022 - First argument enables controlling fans in the first GPU, second one assigns target fan speed in percentage (0–100) for the first fan. Note: Fans are enumareted continously across all GPUs, i.e. I have 2 fans on each GPU and in order to control first fan on second GPU I have to use fan:2 · However, after running this command through you’ll likely see this: Unable to init server: Could not connect: Connection refusedERROR: The control display is undefined; please run `nvidia-settings --help` for usage information.
🌐
NVIDIA Developer Forums
forums.developer.nvidia.com › graphics / linux › linux
Fan speed does not change (but nvidia-smi says it does) - Linux - NVIDIA Developer Forums
May 10, 2023 - Following other posts in this forum I have tried to change the fan speed doing sudo nvidia-settings --display :0 -a GPUFanControlState=1 -a GPUTargetFanSpeed=60 (I have also tried without the --display) The response is Attribute 'GPUFanControlState' ...
Find elsewhere
🌐
GitHub
github.com › KristianHolsheimer › nvidia-fan-controller
GitHub - KristianHolsheimer/nvidia-fan-controller: Nvidia GPU Fan Controller for linux · GitHub
nvidia-smi --loop=1 · If you'd like to selectively stress-test your GPUs, you can set the CUDA_VISIBLE_DEVICES variable. For example, here's how I sandwich an idle GPU between two fully-loaded ones: CUDA_VISIBLE_DEVICES=0,2 ./gpu-burn 600 · ...
Starred by 15 users
Forked by 9 users
Languages   Python
🌐
Reddit
reddit.com › r/nvidia › nvidia-smi (linux) - how to get fan rpm not % speed
r/nvidia on Reddit: nvidia-smi (linux) - How to get fan RPM not % speed
December 15, 2020 -

I know it's possible to get GPU fan RPM values via nvidia-settings, but my gnome-extension switched to nvidia-smi due to high CPU usage when polling for GPU temp.

$ nvidia-smi --help-query-gpu | grep fan

"fan.speed"

The fan speed value is the percent of the product's maximum noise tolerance fan speed that the device's fan is currently intended to run at. This value may exceed 100% in certain cases. Note: The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, this output will not match the actual fan speed. Many parts do not report fan speeds because they rely on cooling via fans in the surrounding enclosure.

Sadly, it appears that nvidia-smi has just one option for fan speed which displays it as a percentage (for ex. 51%).

I understand it would be possible to approximate values based on inference by comparing to the RPM speeds from nvidia-settings but I was trying to avoid an ugly hack that like in my PR.

Is it possible to get RPM values natively from nvidia-smi at all?

Top answer
1 of 3
11

The following is a simple method that does not require scripting, connecting fake monitors, or fiddling and can be executed over SSH to control multiple NVIDIA GPUs' fans. It has been tested on Arch Linux.

Create xorg.conf

sudo nvidia-xconfig --allow-empty-initial-configuration --enable-all-gpus --cool-bits=7

This will create an /etc/X11/xorg.conf with an entry for each GPU, similar to the manual method.

Note: Some distributions (Fedora, CentOS, Manjaro) have additional config files (eg in /etc/X11/xorg.conf.d/ or /usr/share/X11/xorg.conf.d/), which override xorg.conf and set AllowNVIDIAGPUScreens. This option is not compatible with this guide. The extra config files should be modified or deleted. The X11 log file shows which config files have been loaded.

Alternative: Create xorg.conf manually

Identify your cards' PCI IDs:

nvidia-xconfig --query-gpu-info

Find the PCI BusID fields. Note that these are not the same as the bus IDs reported in the kernel.

Alternatively, do sudo startx, open /var/log/Xorg.0.log (or whatever location startX lists in its output under the line "Log file:"), and look for the line NVIDIA(0): Valid display device(s) on GPU-<GPU number> at PCI:<PCI ID>.

Edit /etc/X11/xorg.conf

Here is an example of xorg.conf for a three-GPU machine:

Section "ServerLayout"
        Identifier "dual"
        Screen 0 "Screen0"
        Screen 1 "Screen1" RightOf "Screen0"
        Screen 1 "Screen2" RightOf "Screen1"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:5:0:0"
    Option         "Coolbits"       "7"
    Option         "AllowEmptyInitialConfiguration"
EndSection

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:6:0:0"
    Option         "Coolbits"       "7"
    Option         "AllowEmptyInitialConfiguration"
EndSection

Section "Device"
    Identifier     "Device2"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:9:0:0"
    Option         "Coolbits"       "7"
    Option         "AllowEmptyInitialConfiguration"
EndSection

Section "Screen"
        Identifier     "Screen0"
        Device         "Device0"
EndSection

Section "Screen"
        Identifier     "Screen1"
        Device         "Device1"
EndSection

Section "Screen"
        Identifier     "Screen2"
        Device         "Device2"
EndSection

The BusID must match the bus IDs we identified in the previous step. The option AllowEmptyInitialConfiguration allows X to start even if no monitor is connected. The option Coolbits allows fans to be controlled. It can also allow overclocking.

Note: Some distributions (Fedora, CentOS, Manjaro) have additional config files (eg in /etc/X11/xorg.conf.d/ or /usr/share/X11/xorg.conf.d/), which override xorg.conf and set AllowNVIDIAGPUScreens. This option is not compatible with this guide. The extra config files should be modified or deleted. The X11 log file shows which config files have been loaded.

Edit /root/.xinitrc

nvidia-settings -q fans
nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=75
nvidia-settings -a [gpu:1]/GPUFanControlState=1 -a [fan:1]/GPUTargetFanSpeed=75
nvidia-settings -a [gpu:2]/GPUFanControlState=1 -a [fan:2]/GPUTargetFanSpeed=75

I use .xinitrc to execute nvidia-settings for convenience, although there's probably other ways. The first line will print out every GPU fan in the system. Here, I set the fans to 75%.

Launch X

sudo startx -- :0

You can execute this command from SSH. The output will be:

Current version of pixman: 0.34.0
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sat May 27 02:22:08 2017
(==) Using config file: "/etc/X11/xorg.conf"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"

  Attribute 'GPUFanControlState' (pushistik:0[gpu:0]) assigned value 1.

  Attribute 'GPUTargetFanSpeed' (pushistik:0[fan:0]) assigned value 75.


  Attribute 'GPUFanControlState' (pushistik:0[gpu:1]) assigned value 1.

  Attribute 'GPUTargetFanSpeed' (pushistik:0[fan:1]) assigned value 75.


  Attribute 'GPUFanControlState' (pushistik:0[gpu:2]) assigned value 1.

  Attribute 'GPUTargetFanSpeed' (pushistik:0[fan:2]) assigned value 75.

Monitor temperatures and clock speeds

nvidia-smi and nvtop can be used to observe temperatures and power draw. Lower temperatures will allow the card to clock higher and increase its power draw. You can use sudo nvidia-smi -pl 150 to limit power draw and keep the cards cool, or use sudo nvidia-smi -pl 300 to let them overclock. My 1080 Ti runs at 1480 MHz if given 150W, and over 1800 MHz if given 300W, but this depends on the workload. You can monitor their clock speed with nvidia-smi -q or more specifically, watch 'nvidia-smi -q | grep -E "Utilization| Graphics|Power Draw"'

Returning to automatic fan management.

Reboot. I haven't found another way to make the fans automatic.

2 of 3
5

I've written a pip-installable Python script to do something similar to @AlexsandrDubinsky's suggestion.

When you run fans.py, it sets up a temporary X server for each GPU with a fake display attached. Then, it loops over the GPUs every few seconds and sets the fan speed according to their temperature. When the script dies, it returns control of the fans to the drivers and cleans up the X servers.

🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › hardware support › graphics cards & monitors
How to change Nvidia fan speed? - Linux Mint Forums
cd /etc/X11 sudo nvidia-xconfig --cool-bits=4 newer drivers don't respect nvidia-xconfig but you can try. in either case you need to undo the changes you made and use coolbits=4 which then you can open nvidia-settings and fan control should be under thermal settings https://wiki.archlinux....
🌐
EndeavourOS
forum.endeavouros.com › general system › newbie
Nvidia card how to increase fan speed - Newbie - EndeavourOS
June 30, 2023 - I am dong model training, nvidia-smi outputs like this: Fri Jun 30 17:06:43 2023 +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 535.54.03 Driver Version: 535.54.03 CUDA Version: 12.2 | |-----------------------------------------+----------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr.
🌐
Massed Compute
massedcompute.com › home › faq – answers
How do I use NVIDIA SMI to set a custom fan speed on my NVIDIA GPU - Massed Compute
July 8, 2024 - Set custom fan speed on NVIDIA GPU with SMI: a step-by-step guide to optimizing your NVIDIA graphics card's performance.
🌐
Techticity
techticity.com › howto › how-to-control-nvidia-graphics-card-fan-speed-in-linux
How to control Nvidia graphics card Fan Speed Automatically in Linux – Techticity
September 19, 2018 - 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 · 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.
🌐
NVIDIA Developer Forums
forums.developer.nvidia.com › graphics / linux › linux
How to control fan speed based on GPU index instead of fan index - Linux - NVIDIA Developer Forums
April 1, 2021 - I want to control fan speed from command line based on GPU index not fan index. I mean when I execute this command: nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=70 It will set ...
🌐
NVIDIA Developer Forums
forums.developer.nvidia.com › graphics / linux › linux
How to set fan speed WITHOUT X? - Linux - NVIDIA Developer Forums
December 13, 2018 - Since the card doesn’t increase ... without X. However, this doesn’t seem possible!?! Trying to run nvidia-settings -a [fan:1]/GPUTargetFanSpeed=70 results in ERROR: ......
🌐
Stack Exchange
unix.stackexchange.com › questions › 396490 › unable-to-change-fan-speed-through-nvidia-settings
ubuntu - Unable to change fan speed through nvidia-settings - Unix & Linux Stack Exchange
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings -a [gpu:0]/GPUFanControlState=1 DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 sudo nvidia-settings -a [gpu:0]/GPUTargetFanSpeed=100 · This seemed to work for the first command, ...
🌐
Medium
medium.com › carre4 › nvidia-fan-controller-for-linux-diy-2b6173176c8f
NVIDIA Fan Controller For Linux(DIY) | by Sabin Sharma | CARRE4 | Medium
May 4, 2021 - You could try executing this code with your window manager or any display manager. In case of awesome window manager you could just append this code into your rc.lua file: awful.spawn.with_shell("nvidia-settings -a '[fan]/GPUTargetFanSpeed=85'")