SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2012-04-09 23:03:51

2Karl
#! CrunchBanger
Registered: 2012-03-25
Posts: 216
Website

Automatically adjust Nvidia GPU fan speed

Users of certain Nvidia cards may notice that they get rather hot when playing games. it is possible to manually set the fan speed using a slider in nvidia-settings, but that's tedious. Wouldn't it be great if you could assign hotkeys to speed up or slow down the fans, or even have them automatically adjust themselves based on the GPU temperature? Supposedly that's what the cards SHOULD do, but in my experience they never have done. I wrote a couple of scripts that allow you to do it.

All of the usual disclaimers apply; don't fool around with these things if you're not entirely sure what you're doing, don't blame me / Nvidia / #! / Rick Moranis if something breaks.

Still here? Good.

The first thing you need to do is actually enable the fan speed adjustments. To do this you'll need to edit /etc/X11/xorg.conf.

MAKE A BACKUP FIRST!
Run:

sudo cp /etc/X11/xorg.conf ~/xorg.conf.backup

To copy the xorg.conf file to your home directory. Then:

sudo geany /etc/X11/xorg.conf

In the "device" section, add the following:

Option    "Coolbits" "4"

So the section should look something like:

Section "Device"
    Identifier  "Video Card"
    Driver    "nvidia"
    Option    "Coolbits" "4"
EndSection

NOTE: The coolbits 4 option enables fan speed adjustments in nvidia-settings and is required for this script to work. you can also set coolbits 1 to enable clock frequency adjustments or coolbits 5 to enable both. Also, it could be that you don't actually have an xorg.conf file. There may be a file in /etc/xorg.conf.d/ which contains your nvidia device settings. I'll leave it as an exercise to the reader to find out where their settings are. Next, restart the X server.

OK, fan speed adjustments should now be enabled, so go into nvidia settings and check the box under "thermal settings" to
If you don't already have one, create a /bin/ directory in your home:

mkdir ~/bin

and add it to your $PATH environment variable.
in this directory we're going to add our adjustment scripts. The first is called "nvfanspeedadjust". Fire up your favourite text editor and write the following code:

#!/bin/bash
# read the current fan speed from nvidia-settings
current_speed=`nvidia-settings -t -q [fan:0]/GPUCurrentFanSpeed`
new_speed=0

#read arguments from command line
case "$1" in
#if argument is "up", increase fan speed by 10%, unless already at 100%
"up")    let "new_speed = $current_speed + 10"
    if [ $new_speed -gt 100 ]
    then
        new_speed=100
    fi
    eval "nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed=$new_speed"
    ;;
#if argument is "down", decrease fan speed by 10%, unless already at 35
"down")    let "new_speed = $current_speed - 10"
    if [ $new_speed -lt 35 ]
    then
        new_speed=35
    fi
    eval "nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed=$new_speed"
    ;;
#if "min", set fan speed to 35%
"min")    nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed=35
    ;;
#if "maX2, set fan speed to 100%
"max")    nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed=100
    ;;
#if "mid", set fan speed to 60%
"mid")    nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed=60
    ;;
esac

exit 0

Save as ~/bin/nvfanspeedadjust. and run:

chmod +x ~/bin/nvfanspeedadjust

to make it executable.
I've added some comments to explain what the script is doing at each step of the way. You can run the script with:

nvfanspeedadjust [up|down|min|mid|max]

To tweak your fan speed. Now, you can either assign keyboard shortcuts to relevant script calls to control the fan manually, or read on to find out how to have your system automatically adjust the fan speed based on your GPU temperature.

Still here? Good!

Fire up that text editor again and write the following:

#!/bin/bash

#nvautoadjust 
#periodically checks Nvidia GPU temperature and adjusts fan appropriately
#using the nvfanspeedadjust script
#min mid and max speeds are defined in the nvspeedfanadjust script.

#recommended invokation: nvautoadjust &
#run at startup to continually monitor temperature and adjust fan speed.

#get current temperature
current_temp=`nvidia-settings -t -q [GPU:0]/GPUCoreTemp`

#sets the refresh interval in seconds
interval=5

# continually loop
while [ "1" -eq "1" ]; do

    #check current temperature and adjust fan speed
    if [ "$current_temp" -gt "45" ]; then
        if [ "$current_temp" -gt "60" ]; then
            #if temp greater than 60, set fan speed to max
            nvfanspeedadjust max
        fi
        #if temp greater than 45, set fan speed to mid
        nvfanspeedadjust mid
    fi
    #if temp below 45, set fan speed to minimum
    nvfanspeedadjust min

    #wait until interval expires before rechecking
    sleep "$interval"
done

Save as ~/bin/nvautoadjust and run

chmod +x ~/bin/nvautoadjust

to make it executable.

You can run the script with:

nvautoadjust &

Now you can add it to your startup applications in ~/.config/openbox/autostart or whatever other method you employ in your window manager of choice and have your system automatically adjust your GPU fan speed!
Obviously if you wanted to you could easily modify the scripts to either switch to different fan speeds for different temperatures, or have a greater level of gradation between adjustments.
Hope this is of some use to people.


"It's a pity she won't live... But then who does?" - Gaff.

Offline

Be excellent to each other!

#2 2012-04-11 19:05:23

mad_dev
Member
From: Planet Earth
Registered: 2011-11-12
Posts: 42
Website

Re: Automatically adjust Nvidia GPU fan speed

Genius solution. A Conky script could be used as a visual indicator.

Thanks,


Crunch Out

Offline

#3 2012-04-12 18:48:37

2Karl
#! CrunchBanger
Registered: 2012-03-25
Posts: 216
Website

Re: Automatically adjust Nvidia GPU fan speed

I was working on an G-15 LCD readout for it too.


"It's a pity she won't live... But then who does?" - Gaff.

Offline

#4 2012-05-22 15:16:35

micsas
New Member
Registered: 2012-05-22
Posts: 1

Re: Automatically adjust Nvidia GPU fan speed

Hi.
I like what u did here. Most of it is just fine but the nvautoadjust script isnt. You'v put a curent temp variable outside the while loop so it basicly fix the fan speed on a first value.

#!/bin/bash
interval=10
while true; do
    current_temp=`nvidia-settings -t -q [GPU:0]/GPUCoreTemp`
    if [ "$current_temp" -gt "70" ]; then
        nvfanspeedadjust max
    elif [ "$current_temp" -le "70" -a "$current_temp" -gt "60" ]; then
        nvfanspeedadjust mid
    elif [ "$current_temp" -le "60" ]; then
        nvfanspeedadjust min
    fi
    sleep "$interval"
done

Last edited by micsas (2012-05-22 15:17:10)

Offline

#5 2012-06-21 04:11:31

mynis01
#! Die Hard
From: 127.0.0.1
Registered: 2010-07-02
Posts: 2,005

Re: Automatically adjust Nvidia GPU fan speed

As I discovered the hard way, coolbits and nvclock do not work with newer nvidia cards, including the 500, 600, and possibly the 400 series. Buyer beware.

Offline

#6 2013-08-23 06:18:05

dakos
New Member
Registered: 2013-08-23
Posts: 1

Re: Automatically adjust Nvidia GPU fan speed

Hello, followed your little tutorial and works great except for one thing, there is a minimus fan speed setting of 40%, the problem is the fan is too loud at that setting, cant set it to less then that either from the terminal nor from nvidia settings application, anyone knows how to set a different minimum fan speed or a speed lower then 40%?

Thanks

Offline

#7 2013-08-23 09:49:51

mynis01
#! Die Hard
From: 127.0.0.1
Registered: 2010-07-02
Posts: 2,005

Re: Automatically adjust Nvidia GPU fan speed

dakos wrote:

Hello, followed your little tutorial and works great except for one thing, there is a minimus fan speed setting of 40%, the problem is the fan is too loud at that setting, cant set it to less then that either from the terminal nor from nvidia settings application, anyone knows how to set a different minimum fan speed or a speed lower then 40%?

Thanks

I don't want to jump the gun and shoot you down here if there is a way but, all of the Nvidia GPUs I've ever owned have had a fixed minimum and maximum percentage that you can't override. I think my GTX 670 only goes from 40% to 80%. You might be able to flash the bios on the card and change it like that somehow but that's risky. You do have the fan speed slider in Nvidia-settings right?

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: zapp

Debian Logo