How to set fanspeed in Linux from terminal

I logged into my linux laptop via an SSH session. I issued the following command:

nvidia-settings --display :1.0 -q DitheringMode

and I got the same (expected) output that I would get if I issued that command locally from a terminal on the laptop itself. The 1:0 display indicator may be different on other systems.

For attributes that are queryable based on gpu not display, such as GPUFanControlState, I was able to do this successfully from a remote system over SSH:

nvidia-settings --display :1.0 -q [gpu:0]/GPUFanControlState

I don’t know if any of this works if there is not actually a graphical X desktop running on the target machine. These did not require -Y on the ssh command.

Adding ‘-Y’ or ‘-y’ does the same thing. Nothing.

The output of the line below:

nvidia-settings --display :1.0 -q DitheringMode

Unable to init server: Could not connect: Connection refused


ERROR: Error resolving target specification '' (No targets match target specification), specified in query
       'DitheringMode'.

On the machine where the X server is running (i.e. the target machine) try running:

xhost +

then retry the nvidia-settings command from the remote machine. And it’s quite possible that 1:0 is not the correct display indicator for your target machine.

also report what

echo $DISPLAY

reports on the target machine, if anything

For ease of use I added this to my .bashrc script.

fans() {
        nvidia-settings --display :1.0 -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=$1"
        echo "Fan speeds set to $1 percent"
}

Now you can just type ‘fans 100’ and voila. Adjust as needed.
Also, you could add this to a crontab to check the temp or if the gpu is training and set the fan speed accordingly.

1 Like

when running
nvidia-settings --display :10.0 -q [gpu:0]/GPUFanControlState
($DISPLAY=localhost:10.0 in my case) I am getting this message
libEGL warning: DRI2: failed to authenticate
Did anyone face the same problem?

I don’t see why this has to be a problem that we all have. As it was said earlier in a thread, if there was just a simple nvidia-smi command, that would be great. I’m currently trying to determine what cards are dead in a server, and I would like to just use nvidia-smi to max out the fan speed on the cards that work correctly (I tried to make them all run at full load, but it was still hard to determine which was which, they all seemed around the same temp to the touch, and at full load were at 40% RPM vs 20% idle, adjacent cards were probably warming up the dead card, and idk how to map pcie bus to physical slot on the board).

2 Likes

I solved this problem for SSH users>

root@pop-os:/home/laneone# nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=70

ERROR: The control display is undefined; please run nvidia-settings --help for usage information.

root@pop-os:/home/laneone# sudo apt install nvidia-xconfig
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
E: Unable to locate package nvidia-xconfig
root@pop-os:/home/laneone# export XDG_RUNTIME_DIR=/run/user/$(id -u)
mkdir -p $XDG_RUNTIME_DIR
chmod 700 $XDG_RUNTIME_DIR
root@pop-os:/home/laneone# nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=70

ERROR: The control display is undefined; please run nvidia-settings --help for usage information.

root@pop-os:/home/laneone# sudo apt-get install xvfb
Xvfb :1 -screen 0 1024x768x16 &
export DISPLAY=:1
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
xvfb is already the newest version (2:21.1.4-2ubuntu1.7~22.04.10).
0 upgraded, 0 newly installed, 0 to remove and 76 not upgraded.
[1] 4037
root@pop-os:/home/laneone# export DISPLAY=:1
root@pop-os:/home/laneone# nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=70

Attribute ‘GPUFanControlState’ (pop-os:1[gpu:0]) assigned value 1.
Attribute ‘GPUFanControlState’ (pop-os:1[gpu:1]) assigned value 1.

Attribute ‘GPUTargetFanSpeed’ (pop-os:1[fan:0]) assigned value 70.
Attribute ‘GPUTargetFanSpeed’ (pop-os:1[fan:1]) assigned value 70.
Attribute ‘GPUTargetFanSpeed’ (pop-os:1[fan:2]) assigned value 70.
Attribute ‘GPUTargetFanSpeed’ (pop-os:1[fan:3]) assigned value 70.

the secret sauce is : “sudo apt-get install xvfb
Xvfb :1 -screen 0 1024x768x16 &
export DISPLAY=:1”

created an account just to let people know, cheers ;)

2 Likes

You are my hero! But for me, the export DISPLAY=:1 is all that matters before setting the speed over ssh tunnel.

ah. glad to see it helped you. while i ssh in through vscode (vscode-server), it does not create an X Server automatically. Hence, have to do some gimmicks to run a virtual x server and set that as display. Everything works fine after that.

I am unable to get any of the above posted examples to work.

I have a headless server, no display monitors connected, with rtx running in debian 12 installed with https://download.nvidia.com/XFree86/Linux-x86_64/565.77/NVIDIA-Linux-x86_64-565.77.run
I am able to run nvidia-smi and also have applications utilizing the gpu so the driver and hardware are functioning.

I have not been able to find how to increase fan speeds in cli.

When I try to run the commands I get errors

root:~# nvidia-xconfig -a --cool-bits=28

Using X configuration file: "/etc/X11/xorg.conf".

WARNING: Unable to parse X.Org version string.

Backed up file '/etc/X11/xorg.conf' as '/etc/X11/xorg.conf.backup'
New X configuration file written to '/etc/X11/xorg.conf'

root:~# nvidia-settings -a '[gpu:0]/GPUFanControlState=1' -a '[fan:0]/GPUTargetFanSpeed=99'

ERROR: libgtk-3.so.0: cannot open shared object file: No such file or directory
       libnvidia-gtk3.so: cannot open shared object file: No such file or directory
       libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
       libnvidia-gtk2.so: cannot open shared object file: No such file or directory


ERROR: A problem occurred when loading the GUI library. Please check your installation and library path. You may need to specify this library when
       calling nvidia-settings. Please run `nvidia-settings --help` for usage information.

When I run other nvidia-settings commands they do provide returns

# nvidia-settings -e list

OperatingSystem
NvidiaDriverVersion
NvControlVersion
GLXServerVersion
GLXClientVersion
...

Here is what apt shows

# apt list --installed | grep nvidia

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

nvidia-installer-cleanup/now 20151021+11 amd64 [installed,upgradable to: 20220217+3~deb12u1]
nvidia-modprobe/stable,now 535.161.07-1~deb12u1 amd64 [installed]

I tried to manually install newer nvidia-settings from https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/nvidia-settings_565.57.01-1_amd64.deb and get

# dpkg -i nvidia-settings_565.57.01-1_amd64.deb
dpkg: regarding nvidia-settings_565.57.01-1_amd64.deb containing nvidia-settings, pre-dependency problem:
 nvidia-settings pre-depends on nvidia-installer-cleanup
  nvidia-installer-cleanup is unpacked, but has never been configured.

dpkg: error processing archive nvidia-settings_565.57.01-1_amd64.deb (--install):
 pre-dependency problem - not installing nvidia-settings
Errors were encountered while processing:
 nvidia-settings_565.57.01-1_amd64.deb

Hi all,
Hitting same issue with Fedora41 with Driver 565.77 (NVIDIA GeForce RTX 4090). Reported via: RTX4090 - Fedora 41 (LLM AI) Unable to determine the device handle for GPU0000:01:00.0: Unknown Error · Issue #846 · NVIDIA/nvidia-container-toolkit · GitHub
But no response so far.

I see quite a few posts here but couldn’t find how to control Fan speed via terminal on a headless server, also no display monitors or any other peripherals connected, unless you have GUI or XServer installed.
The workaround works here as well, thanks! Just to summarise the commands to manually choose fan speed, could you check if the below is correct?

nvidia-settings -a GPUFanControlState=1 -a GPUTargetFanSpeed=90 # set it to 90%
nvidia-settings -a GPUFanControlState=0 # set back to system , is this correct?

Thanks!