Bitcoin Forum
December 05, 2016, 08:38:31 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Any linux script for maintain GPU temp? (changing fan speed)  (Read 3989 times)
brunoshady
Sr. Member
****
Offline Offline

Activity: 264

Dubs Get


View Profile
July 08, 2011, 09:32:22 PM
 #1

anyone got something on this?


for example, I wan't to set my GPU temp in 70 ºC, so, when the temp is above, the fan speeds gets higher and when the temp is lower, the fan speed go slow...
1480927111
Hero Member
*
Offline Offline

Posts: 1480927111

View Profile Personal Message (Offline)

Ignore
1480927111
Reply with quote  #2

1480927111
Report to moderator
1480927111
Hero Member
*
Offline Offline

Posts: 1480927111

View Profile Personal Message (Offline)

Ignore
1480927111
Reply with quote  #2

1480927111
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
brunoshady
Sr. Member
****
Offline Offline

Activity: 264

Dubs Get


View Profile
July 08, 2011, 09:55:40 PM
 #2

something simple like



vartemp = 70


while true:
     if temp > vartemp
          fan_speed_increase
    else if temp < vartemp
          fan_speed_decrease
swivel
Newbie
*
Offline Offline

Activity: 17

0.00000001 BTC at a time


View Profile
July 08, 2011, 11:32:30 PM
 #3

Here's a simple shell script. Save as fanmon.sh.

Code:
#!/bin/bash

DEVICE=$1
if [ "${DEVICE}" == "" ];
then
        echo "Usage: fanmon.sh <deviceid>"
        exit 1
fi

# temp levels in C
# fan speeds in %
MAXTEMP=80
MAXFAN=99

MIDTEMP=60
MIDFAN=70

MINTEMP=40
MINFAN=50

IDLEFAN=20
LASTTEMP=0

export DISPLAY=:0.${DEVICE}

while true;
do
        TEMP=`aticonfig --adapter=${DEVICE} --odgt | grep Temp | sed  's/.* \([0-9]*[0-9][0-9]\)\..*/\1/'`
        if [ "${TEMP}" -ne "${LASTTEMP}" ];
        then
                echo -n "Temp: ${TEMP}C "
                if [ "${TEMP}" -gt "${MAXTEMP}" ];
                then
                        echo "setting fan speed ${MAXFAN}%"
                        aticonfig --pplib-cmd "set fanspeed 0 ${MAXFAN}"
                elif [ "${TEMP} -gt ${MIDTEMP}" ];
                then
                        echo "setting fan speed ${MIDFAN}%"
                        aticonfig --pplib-cmd "set fanspeed 0 ${MIDFAN}"
                elif [ "${TEMP} -gt ${MINTEMP}" ];
                then
                        echo "setting fan speed ${MINFAN}%"
                        aticonfig --pplib-cmd "set fanspeed 0 ${MINFAN}"
                else
                        echo "setting fan speed ${IDLEFAN}%"
                        aticonfig --pplib-cmd "set fanspeed 0 ${IDLEFAN}"
                fi
        fi
        LASTTEMP=${TEMP}
        sleep 10
done


Run it like so:
Code:
# ./fanmon.sh 0 &

Adjust the temperature thresholds so the fan speed doesn't jump up and down.

16qMYQq7G14zevVmUMuwF3jNFpka3WjMhQ
Keninishna
Hero Member
*****
Offline Offline

Activity: 551



View Profile WWW
July 09, 2011, 02:43:00 AM
 #4

amdoverdrivectrl can also set up fan profiles.
brunoshady
Sr. Member
****
Offline Offline

Activity: 264

Dubs Get


View Profile
July 09, 2011, 02:48:07 AM
 #5

amdoverdrivectrl can also set up fan profiles.


yes but you only control the fan speed, not the temp..


and btw, I didn't managed to use it with 2 GPUs
swivel
Newbie
*
Offline Offline

Activity: 17

0.00000001 BTC at a time


View Profile
July 09, 2011, 04:57:01 AM
 #6

OK I think this is more what you want.

Code:
#!/bin/bash

MAXSPD=80
MINSPD=20

if [ $# -lt 2 ];
then
        echo "Usage: setfantemp.sh <deviceid> <temp>"
        exit 1
fi

DEVICE=$1
SETTEMP=$2

export DISPLAY=:0.${DEVICE}
aticonfig --pplib-cmd "set fanspeed 0 ${MAXSPD}"

while true;
do
        CURTEMP=`aticonfig --adapter=${DEVICE} --odgt | grep Temp | sed  's/.* \([0-9]*[0-9][0-9]\)\..*/\1/'`
        CURSPD=`aticonfig --pplib-cmd "get fanspeed 0" | grep Result | sed  's/.* \([0-9]*[0-9][0-9]\)\%.*/\1/'`

        echo -n "Set temp: ${SETTEMP}C Current temp: ${CURTEMP}C Current speed: ${CURSPD}% - "

        if [ "${CURTEMP}" -ne "${SETTEMP}" ]; then
                if [ "${CURTEMP}" -lt "${SETTEMP}" ]; then
                        NEWSPD=$((${CURSPD} - 1))
                        if [ "${NEWSPD}" -lt "${MINSPD}" ]; then
                                echo "MIN speed limit"
                        else
                                echo "Decreasing speed to ${NEWSPD}"
                        fi
                else
                        NEWSPD=$((${CURSPD} + 1))
                        if [ "${NEWSPD}" -gt "${MAXSPD}" ]; then
                                echo "MAX speed limit"
                        else
                                echo "Increasing speed to ${NEWSPD}"
                                aticonfig --pplib-cmd "set fanspeed 0 ${NEWSPD}"
                        fi
                fi
        else
                echo "Stable"
        fi
        sleep 10
done


Save to setfantemp.sh. To run:

Code:
# ./setfantemp.sh 0 55 &

That will set your target temperature for card 0 to 55C. The script will adjust the fan speed to hit that target.

Max fan speed and min fan speed are hard coded in the script to be 80% and 20% respectively. You can raise the max speed if your card isn't getting cooled to your target temp.


16qMYQq7G14zevVmUMuwF3jNFpka3WjMhQ
brunoshady
Sr. Member
****
Offline Offline

Activity: 264

Dubs Get


View Profile
July 12, 2011, 05:12:29 PM
 #7

OK I think this is more what you want.

Code:
#!/bin/bash

MAXSPD=80
MINSPD=20

if [ $# -lt 2 ];
then
        echo "Usage: setfantemp.sh <deviceid> <temp>"
        exit 1
fi

DEVICE=$1
SETTEMP=$2

export DISPLAY=:0.${DEVICE}

while true;
do
        CURTEMP=`aticonfig --adapter=${DEVICE} --odgt | grep Temp | sed  's/.* \([0-9]*[0-9][0-9]\)\..*/\1/'`
        CURSPD=`aticonfig --pplib-cmd "get fanspeed 0" | grep Result | sed  's/.* \([0-9]*[0-9][0-9]\)\%.*/\1/'`

        echo -n "Set temp: ${SETTEMP}C Current temp: ${CURTEMP}C Current speed: ${CURSPD}% - "

        if [ "${CURTEMP}" -ne "${SETTEMP}" ]; then
                if [ "${CURTEMP}" -lt "${SETTEMP}" ]; then
                        NEWSPD=$((${CURSPD} - 1))
                        if [ "${NEWSPD}" -lt "${MINSPD}" ]; then
                                echo "MIN speed limit"
                        else
                                echo "Decreasing speed to ${NEWSPD}"
                                aticonfig --pplib-cmd "set fanspeed 0 ${NEWSPD}"
                        fi
                else
                        NEWSPD=$((${CURSPD} + 1))
                        if [ "${NEWSPD}" -gt "${MAXSPD}" ]; then
                                echo "MAX speed limit"
                        else
                                echo "Increasing speed to ${NEWSPD}"
                                aticonfig --pplib-cmd "set fanspeed 0 ${NEWSPD}"
                        fi
                fi
        else
                echo "Stable"
        fi
        sleep 10
done


Save to setfantemp.sh. To run:

Code:
# ./setfantemp.sh 0 55 &

That will set your target temperature for card 0 to 55C. The script will adjust the fan speed to hit that target.

Max fan speed and min fan speed are hard coded in the script to be 80% and 20% respectively. You can raise the max speed if your card isn't getting cooled to your target temp.



I didn't test yet, but seems good for my porpose... I will test later today, but I have one question.


this line is correct?


Code:
        CURSPD=`aticonfig --pplib-cmd "get fanspeed 0" | grep Result | sed  's/.* \([0-9]*[0-9][0-9]\)\%.*/\1/'`

the get fanspeed 0 part... is 0 for device?
if yes, I will just change it to 1 over device 2, correct?
Vince
Jr. Member
*
Offline Offline

Activity: 38


View Profile
July 12, 2011, 05:23:22 PM
 #8

Here's my card fan regulator tool, written in php.
It adjusts the card temp to a specific temperature. It also catches temperature changes faster and adjusts the fan better than the simple version above.

It also has some safety extras:
Set fan to 100% if card is above 96° (can be adjusted)
Clock card down to 500Mhz at 100°C (100% fan here already)

and you can change clock frequencies by typing 1 <enter> to 5 <enter> (Silent to full speed), adjust frequencies if needed. 6 is for full speed + cooler card

Have fun  Smiley


Code:
<?

// Start with this fan speed
$fan = 40;

// Target temperature
$targetb = 86;

// At this temp switch to 100% fan
$highlim = 96;

$memspeed = 900;

$hyst = 2; $temp = 0; $target = $targetb;

while ( true) {
        $last = $temp;
        $temp = gt();
        if($last) {
                $diff = $temp - $last;
                if($diff > 2) $fan+=5+2*$diff;
                if($diff < -2) $fan-=5-2*$diff;
        }

        if($temp > $target + $hyst + 2) $fan+=4;
        if($temp > $target + $hyst + 4) $fan+=20;
        if($temp < $target - $hyst - 4) $fan-=4;
        if($temp > $target + $hyst) $fan++;
        if($temp < $target - $hyst) $fan--;
        if($fan > 100) $fan = 100;
        if($fan < 0) $fan = 0;
        if($temp > $highlim) $fan = 100;
        // At 100 Deg throttle card
        if($temp > 100) throttle();
        sf($fan);

        $a = array(STDIN);
        $l = array();

        if(stream_select($a, $l, $l, 10) > 0) {
                $d = fread(STDIN,1);
                echo "--".$d."--";
                switch($d) {
                        case '1':
                                sett(500); $target = $targetb + 1; break;
                        case '2':
                                sett(600); $target = $targetb + 1; break;
                        case '3':
                                sett(700); $target = $targetb; break;
                        case '4':
                                sett(800);  $target = $targetb - 1; break;
                        case '5':
                                sett(840); $target = $targetb - 2; break;
                        case '6':
                                sett(840); $target = $targetb - 4;
                }
        }

}

echo "\n";


function sett($speed) {
        echo "Setting clock to ".$speed."\n";
        exec("aticonfig --odsc ".$speed.",".$GLOBALS["memspeed"]);
}


function throttle() {
        echo "Too hot. Clocking card down to 500Mhz ...\n";
        exec("aticonfig --odsc 500,".$globals["memspeed"]);
}

function sf($speed) {
        echo "Setting fan to ".$speed."\n";
        exec('aticonfig --pplib-cmd "set fanspeed 0 '.$speed.'"');
}

function gt() {
        $ausgabe = array();
        $e = exec("aticonfig --odgt", $ausgabe);
        foreach($ausgabe as $line) {
                $t = explode("Sensor 0: Temperature -", $line);
                if(count($t) > 1) {
                        $t2 = explode(".", $t[1]); echo "Card at ".$t2[0]."\n"; return (int)$t2[0];
                }
        }
}


?>

Like what I'm posting? -> 1DtHZgVufX1tc5jRCoNiUnygenwRWj939C
swivel
Newbie
*
Offline Offline

Activity: 17

0.00000001 BTC at a time


View Profile
July 12, 2011, 10:46:34 PM
 #9


I didn't test yet, but seems good for my porpose... I will test later today, but I have one question.

this line is correct?


Code:
        CURSPD=`aticonfig --pplib-cmd "get fanspeed 0" | grep Result | sed  's/.* \([0-9]*[0-9][0-9]\)\%.*/\1/'`

the get fanspeed 0 part... is 0 for device?
if yes, I will just change it to 1 over device 2, correct?

Yes that's correct. aticonfig get the parameters for the card according to the DISPLAY variable. The DISPLAY variable has the device number assigned to it:

Code:
export DISPLAY=:0.${DEVICE}

16qMYQq7G14zevVmUMuwF3jNFpka3WjMhQ
marcus_of_augustus
Legendary
*
Offline Offline

Activity: 2086



View Profile
July 12, 2011, 11:04:43 PM
 #10


Yes there is this thread that has python script for doing exactly that on AMD cards ... (you got python if you're mining most likely)

http://forum.bitcoin.org/index.php?topic=10062.0

Wanted to also see the PID controller bit implemented for geek kicks but nobody with python skills ran with it ...

http://forum.bitcoin.org/index.php?topic=10062.20

... this way you would INPUT a desired TEMP. and controller would keep fan speed controlled to acheive temperature set-point ... as best it could.

brunoshady
Sr. Member
****
Offline Offline

Activity: 264

Dubs Get


View Profile
July 12, 2011, 11:32:29 PM
 #11

is there anything to see the voltage consume of the gpu?
brunoshady
Sr. Member
****
Offline Offline

Activity: 264

Dubs Get


View Profile
July 13, 2011, 03:58:03 PM
 #12

swivel, could you add something in it with starting fan speed? something like 50%...


when I turn on the script, it's starts from the idle and until get to the desired speed, the GPU gets very hot, even with sleep 5


could be done?


and works like a charm, thank you very much
swivel
Newbie
*
Offline Offline

Activity: 17

0.00000001 BTC at a time


View Profile
July 13, 2011, 08:21:21 PM
 #13

swivel, could you add something in it with starting fan speed? something like 50%...


when I turn on the script, it's starts from the idle and until get to the desired speed, the GPU gets very hot, even with sleep 5


could be done?


and works like a charm, thank you very much

Yup just add the following after the export line:

Code:
export DISPLAY=:0.${DEVICE}
aticonfig --pplib-cmd "set fanspeed 0 50"

16qMYQq7G14zevVmUMuwF3jNFpka3WjMhQ
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!