nvidia-settings - How to call it from script on a server when nobody is logged ( No X display ).

Hello.
I need to set up the fan speed on my server.
When logged in, I can use this command to set up the fan speed to 30% :

/usr/bin/nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUCurrentFanSpeed=30"

this one works also :

/usr/bin/nvidia-settings -a ":0[gpu:0]/GPUFanControlState=1" -a ":0[fan:0]/GPUCurrentFanSpeed=30"

I have created a service “after.local.service” and put the command in the associated after.local script.
I got the following error in /var/log/message :

No protocol specified. ERROR: The control display is undefined; please run `/usr/bin/nvidia-settings --help` for usage information.

How to setup fan speed after startup when nobody is logged in.

Any help is welcome.

nvidia-settings requires that an X is running, there’s just no way around it.

In theory you could run xvfb which is a virtual X or you could try what this gent did; https://sites.google.com/site/akohlmey/random-hacks/nvidia-gpu-coolness#TOC-Faking-a-Head-for-a-Headless-X-Server

That would be xvfb-run, of course:

http://download.opensuse.org/repositories/X11:/XOrg/openSUSE_13.1/noarch/xvfb-run-1.5.2-1.1.noarch.rpm

Hello.
I am testing my script within runlevel 5, and it dose not work.

LINUX-TEST-123:~ # xvfb-run  --server-num=100 --server-args="-screen 0 640x480x24"  "/usr/bin/nvidia-settings -t --query GPUCoreTemp" 
/usr/bin/xvfb-run: line 168: /usr/bin/nvidia-settings -t --query GPUCoreTemp: No such file or directory
/usr/bin/xvfb-run: line 173: kill: (9070) - No such process
LINUX-TEST-123:~ # 


May I must run from level 3 ?

Any help is welcome

Try running the nvidia settings command without the " "'s around it, it tries to parse it as a singular command instead of the executable and then the parameters.

OK. That do it.

I cannot make my different scripts working with xvfb-run

/usr/bin/nvidia-settings -t --query GPUCoreTemp return a temperature value.
I use to use this value like this way.

CUR_TEMPERATURE=$(/usr/bin/nvidia-settings -t --query GPUCoreTemp)
if  $CUR_TEMPERATURE -gt 90]] ; thendo something

elif  $CUR_TEMPERATURE -gt 70]] ; thendo something

.....
.....
fi

How and where I can get the response from :

xvfb-run  --server-num=100 --server-args="-screen 0 640x480x24"  /usr/bin/nvidia-settings -t --query GPUCoreTemp

Any help is welcome.

by the way these commands return an error from nvidia :

LINUX-TEST-123:~ # xvfb-run  --server-num=100 --server-args="-screen 0 640x480x24"  /usr/bin/nvidia-settings -a "[gpu:0]/GPUFanControlState=1" -a "[fan:0]/GPUCurrentFanSpeed=30"


ERROR: Invalid GPU 0 specified in assignment '[gpu:0]/GPUFanControlState=1' (there are only 0 GPUs on this Display).

LINUX-TEST-123:~ # 

 LINUX-TEST-123:~ # xvfb-run  --server-num=100 --server-args="-screen 0 640x480x24"  /usr/bin/nvidia-settings -a ":100[gpu:0]/GPUFanControlState=1" -a ":100[fan:0]/GPUCurrentFanSpeed=30"


ERROR: Invalid GPU 0 specified in assignment ':100[gpu:0]/GPUFanControlState=1' (there are only 0 GPUs on this Display).

LINUX-TEST-123:~ # 

any help is welcome

Well then, either nVidia has changed something or the nVidia GPU isn’t being recognised/used by the xvfb as in the past.

Unfortunately I have no further suggestions, perhaps the person who made the original article I linked has some ideas about it.