Categories
Ubuntu

Adjust GPU Fan Speed NVIDIA on Ubuntu Server Headless

The problem when adjusting my dual RTX 4090 in Ubuntu Server 23.10 is, when running nvidia-settings its trigger error

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

I’ve been search on internet and not found a better solution, then I decided try to install X and attached, while running nvidia-setting. The result its works. Here are the step by step on how to enable GPU fan speed in Ubuntu Server 23.10

  1. Install XServer
sudo apt install -y xorg xinit

2. Give permission to run X for user

Edit the file and change console into anybody to give permission to running X

sudo vim /etc/X11/Xwrapper.config

If you don’t change this, it will trigger error

/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server

3. Run X and export display (excute each line)

X :1 &
export DISPLAY=:1


4. Now you can execute adjusting fan speed using nvidia-settings without problem on Ubuntu without X.

#!/bin/bash
nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUTargetFanSpeed=30"
nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:1]/GPUTargetFanSpeed=30"
nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:2]/GPUTargetFanSpeed=30"
nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:3]/GPUTargetFanSpeed=30"
Attribute 'GPUFanControlState' (server:1[gpu:0]) assigned value 1.

Attribute 'GPUTargetFanSpeed' (server:1[fan:0]) assigned value 30.

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

Attribute 'GPUTargetFanSpeed' (server:1[fan:1]) assigned value 30.

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

Attribute 'GPUTargetFanSpeed' (server:1[fan:2]) assigned value 30.

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

Attribute 'GPUTargetFanSpeed' (server:1[fan:3]) assigned value 30.

Hope its help you and have a great day!

If you logout and need to re-connect, you just export the display. First check whether X is running

$ ps aux | grep X
root        2681  0.1  0.0 25362060 66584 tty2   Ssl+ 08:56   0:03 /usr/lib/xorg/Xorg :1
user         5163  0.0  0.0   7048  1920 pts/1    S+   09:56   0:00 grep --color=auto X

Then you can export it

export DISPLAY=:1

Leave a Reply

Your email address will not be published. Required fields are marked *