SEARCH

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

You are not logged in.

#1 2012-04-26 19:06:34

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

New improved Nvidia Fan Speed script

I made some changes to my previous nvidia fan speed auto adjustment script to save some clock cycles. It now uses nvidia-smi to poll the temperature and fan speeds and only sets a new fan speed if an actual change is warranted. You'll need to enable coolbits 4 (or 5) in xorg.conf.

#!/bin/bash

#nvautoadjust 
#periodically checks Nvidia GPU temperature and adjusts fan appropriately

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

#sets the refresh interval in seconds
interval=5
#sets the threshold temperatures and fan speeds for the three levels of cooling
#threshold is in degrees c, speed is in percentage of maximum. Set a number between
#35 and 100 for fan speeds.
min_threshold=45
max_threshold=60
min_speed=35
mid_speed=60
max_speed=100


# continually loop
while [ "1" -eq "1" ]; do
    #get current temperature and fan speed
    current_temp=`nvidia-smi -q -d TEMPERATURE | grep Gpu | sed 's/.*\([0-9]\{2\}\).*/\1/'`
    current_speed=`nvidia-smi -q | grep Fan | sed 's/.* \(1\?[0-9]\{2\}\) .*/\1/'`
    
    #check current temperature and adjust fan speed
    #only set the speed if it actually needs changing, as nvidia-settings eats CPU cycles
    if [[ $current_temp > $min_threshold ]]; then
        if [[ $current_temp > $max_threshold ]]; then
            #if temp greater than 60, set fan speed to max
            if [[ $current_speed != $max_speed ]]; then
                nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed="$max_speed" > /dev/null
            fi
        fi
        #if temp greater than 45, set fan speed to mid
        if [[ $current_speed != $mid_speed ]]; then
            nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed="$mid_speed" > /dev/null
        fi
    else
        #if temp below 45, set fan speed to minimum
        if [[ $current_speed != $min_speed ]]; then
            echo set
            nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUCurrentFanSpeed="$min_speed" > /dev/null
        fi
    fi

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

Last edited by 2Karl (2012-04-26 19:07:25)


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

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: acrobat

Debian Logo