Bitcoin Forum
April 19, 2024, 07:17:28 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Automatic temperature/clock speed control  (Read 4128 times)
bcforum (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
August 01, 2011, 10:26:09 PM
Last edit: August 11, 2011, 03:40:39 AM by bcforum
 #1

Since my miners run unattended in unconditioned space I need to insure they don't get too hot and shutdown (or burn out), so I wrote this script (derived in small part from gputempmon.sh by myrond) to automatically lower the clock if the chip gets too hot, or raise the clock if it is below the maximum frequency.

Code:
#!/bin/bash
#version 0.01

TARGETTEMP=88
MAXCLOCK=940
MINCLOCK=500

# Get number of adapters
export DISPLAY=:0
num=`aticonfig --adapter=all --odgt | grep Temperature | wc | awk -- '{ print $1 }'`

# Set all adapters to maximum fan speed
for (( i=0; i<$num; i++ )) do
    export DISPLAY=:0.$i
    aticonfig --od-enable
    aticonfig --adapter=$i --pplib-cmd "set fanspeed 0 99"
done

#
while true; do
    sleep 10
    clear
    date

    for (( i=0; i<$num; i++ )) do
        export DISPLAY=:0.$i

        # Collect current clock speed/temperature
        curtemp=`aticonfig --adapter=$i --odgt | grep "Sensor 0:" | tr -s ' ' | cut -f 6 -d ' ' | cut -f 1 -d '.'`
        curclk=`aticonfig --adapter=$i --odgc | grep "Current Clocks"|tr -s ' '|cut -f 5 -d ' '`

# Status
echo "Adapter $i clock:${curclk}, Temp:${curtemp}C"
        # Lower clock if too hot, raise clock if to slow
        if [ "$curtemp" -gt "$TARGETTEMP" ]; then
            echo "Adapter $i is overheating, slowing it down"
            let "curclk -= 1"
            aticonfig --adapter=$i --odsc=$curclk,0 > /dev/null
        elif [ "$curtemp" -eq "$TARGETTEMP" ]; then
   echo "Adapter $i at target temp"
        elif [ "$curclk" -lt "$MINCLOCK" ]; then
            echo "Adapter $i is idle"
        elif [ "$curclk" -lt "$MAXCLOCK" ]; then
            echo "Adapter $i can run faster, speeding it up"
            let "curclk += 1"
            aticonfig --adapter=$i --odsc=$curclk,0 > /dev/null
        else
   echo "Adapter $i at maximum clock"
        fi
    done
done

A new version that allows different speeds/temps/enables for adapters (only lightly tested):

Code:
#!/bin/bash
#version 0.03

# The parentheses make these variables into arrays
# The arrays will be padded with the last value in each line
ENABLE=(1 0)
TARGETTEMP=(88)
MAXCLOCK=(940 940)

# Get number of adapters
export DISPLAY=:0
num=`aticonfig --adapter=all --odgt | grep Temperature | wc | awk -- '{ print $1 }'`

# Find the last element in each array, then pad to the number of adapters
i=0
for tmp in ${ENABLE[@]} ; do
    let "i += 1"
done
for (( j=i; j<$num; j++ )) do
    ENABLE[j]=$tmp
done
i=0
for tmp in ${TARGETTEMP[@]} ; do
    let "i += 1"
done
for (( j=i; j<$num; j++ )) do
    TARGETTEMP[j]=$tmp
done
i=0
for tmp in ${MAXCLOCK[@]} ; do
    let "i += 1"
done
for (( j=i; j<$num; j++ )) do
    MAXCLOCK[j]=$tmp
done

# Set all adapters to maximum clock speed
for (( i=0; i<$num; i++ )) do
    if [ "${ENABLE[i]}" -eq "1" ]; then
        export DISPLAY=:0.$i
        aticonfig --od-enable
        aticonfig --adapter=$i --pplib-cmd "set fanspeed 0 99"
    fi
done

#
while true; do
    sleep 10
    clear
    date

    for (( i=0; i<$num; i++ )) do
        if [ "${ENABLE[i]}" -eq "1" ]; then
            export DISPLAY=:0.$i

            # Collect current clock speed/temperature
            curtemp=`aticonfig --adapter=$i --odgt | grep "Sensor 0:" | tr -s ' ' | cut -f 6 -d ' ' | cut -f 1 -d '.'`
            curclk=`aticonfig --adapter=$i --odgc | grep "Current Clocks"|tr -s ' '|cut -f 5 -d ' '`

    # Status
    echo "Adapter $i clock:${curclk}, Temp:${curtemp}C"
            # Lower clock if too hot, raise clock if to slow
            if [ "$curtemp" -gt "${TARGETTEMP[i]}" ]; then
                echo "Adapter $i is overheating, slowing it down"
                let "curclk -= 1"
                aticonfig --adapter=$i --odsc=$curclk,0 > /dev/null
            elif [ "$curtemp" -eq "${TARGETTEMP[i]}" ]; then
        echo "Adapter $i at target temp"
            elif [ "$curclk" -lt "500" ]; then
                echo "Adapter $i is idle"
            elif [ "$curclk" -lt "${MAXCLOCK[i]}" ]; then
                echo "Adapter $i can run faster, speeding it up"
                let "curclk += 1"
                aticonfig --adapter=$i --odsc=$curclk,0 > /dev/null
            else
        echo "Adapter $i at maximum clock"
            fi
        fi
    done
done
Edit: Added idle detection to stop adjusting clock when slowed down

If you found this post useful, feel free to share the wealth: 1E35gTBmJzPNJ3v72DX4wu4YtvHTWqNRbM
1713554248
Hero Member
*
Offline Offline

Posts: 1713554248

View Profile Personal Message (Offline)

Ignore
1713554248
Reply with quote  #2

1713554248
Report to moderator
1713554248
Hero Member
*
Offline Offline

Posts: 1713554248

View Profile Personal Message (Offline)

Ignore
1713554248
Reply with quote  #2

1713554248
Report to moderator
1713554248
Hero Member
*
Offline Offline

Posts: 1713554248

View Profile Personal Message (Offline)

Ignore
1713554248
Reply with quote  #2

1713554248
Report to moderator
"You Asked For Change, We Gave You Coins" -- casascius
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713554248
Hero Member
*
Offline Offline

Posts: 1713554248

View Profile Personal Message (Offline)

Ignore
1713554248
Reply with quote  #2

1713554248
Report to moderator
1713554248
Hero Member
*
Offline Offline

Posts: 1713554248

View Profile Personal Message (Offline)

Ignore
1713554248
Reply with quote  #2

1713554248
Report to moderator
Endeavour79
Full Member
***
Offline Offline

Activity: 174
Merit: 100



View Profile WWW
August 02, 2011, 06:32:44 AM
 #2

Nice.. Any way to port this to a windows app?

NSW, Australia - Rigs, Mining, Pools - Local help needed? Send me a message!
bcforum (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
August 02, 2011, 12:31:40 PM
 #3

Nice.. Any way to port this to a windows app?

Unfortunately, I don't know if ATI offers a command line version in Windows. Something similar could be written (the logic is very simple) but I don't have a platform to develop it on.

If you found this post useful, feel free to share the wealth: 1E35gTBmJzPNJ3v72DX4wu4YtvHTWqNRbM
Departure
Sr. Member
****
Offline Offline

Activity: 1204
Merit: 288


View Profile
August 02, 2011, 11:49:18 PM
 #4

We could make something similar in windows... Would be GUI application for easier settings, or a simple console with .ini file for settings... I might look at it doing something like this soon.
simplecoin
Sr. Member
****
Offline Offline

Activity: 406
Merit: 250



View Profile WWW
August 04, 2011, 05:25:16 AM
Last edit: August 04, 2011, 06:22:49 AM by simplecoin
 #5

For anyone who wants a silent box I modified this to adjust fan speed as a second priority to speed. As well as a few display tweaks

Code:
#!/bin/bash
#version 0.011

TARGETTEMP=81
TARGETFAN=60
MAXFAN=80
MAXCLOCK=960

# Get number of adapters
export DISPLAY=:0
num=`aticonfig --adapter=all --odgt | grep Temperature | wc | awk -- '{ print $1 }'`

# Set all adapters to maximum clock speed
for (( i=0; i<$num; i++ )) do
    export DISPLAY=:0.$i
    aticonfig --od-enable
    aticonfig --odsc=$MAXCLOCK,0 --adapter=$i
    aticonfig --adapter=$i --pplib-cmd "set fanspeed 0 $TARGETFAN"
done

#
while true; do
    sleep 10
    clear
    date

    for (( i=0; i<$num; i++ )) do
    echo ">>>>>> Adapter $i <<<<<<"
        export DISPLAY=:0.$i

        # Collect current clock speed/temperature
        curtemp=`aticonfig --adapter=$i --odgt | grep "Sensor 0:" | tr -s ' ' | cut -f 6 -d ' ' | cut -f 1 -d '.'`
        curclk=`aticonfig --adapter=$i --odgc | grep "Current Clocks"|tr -s ' '|cut -f 5 -d ' '`
        curfan=`aticonfig --pplib-cmd "get fanspeed 0" | grep "Fan Speed:" | tr -s ' '|cut -f 4 -d ' '|cut -f 1 -d '%'`

        # Status
        echo "clock:${curclk}, Temp:${curtemp}C, Fan:${curfan}%"
        # Lower clock if too hot, raise clock if to slow
        if [ "$curtemp" -gt "$TARGETTEMP" ]; then
                if [ "$curfan" -lt "$MAXFAN" ]; then
                        echo "Over target temperature, speeding up fan"
                        let "curfan += 5"
                        aticonfig --adapter=$i --pplib-cmd "set fanspeed 0 $curfan" > /dev/null
                else
                    echo "Over target temperatre, lowering clock speed"
                    let "curclk -= 1"
                    aticonfig --adapter=$i --odsc=$curclk,0 > /dev/null
                fi
        elif [ "$curtemp" -eq "$TARGETTEMP" ]; then
                echo "Adapter is at target temp"
        elif [ "$curclk" -lt "$MAXCLOCK" ]; then
            echo "Adapter can run faster, speeding it up"
            let "curclk += 1"
            aticonfig --adapter=$i --odsc=$curclk,0 > /dev/null
        else    
            if [ "$curfan" -gt "$TARGETFAN" ]; then
                echo "Lowering fan speed"
                let "curfan -= 1"
                aticonfig --adapter=$i --pplib-cmd "set fanspeed 0 $curfan" > /dev/null
            else
                echo "Adapter is at optimal targets"
            fi

        fi
        echo " "
    done
done


Donations: 1VjGJHPtLodwCFBDWsHJMdEhqRcRKdBQk
bcforum (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
August 04, 2011, 11:26:15 AM
 #6

For anyone who wants a silent box I modified this to adjust fan speed as a second priority to speed. As well as a few display tweaks

FYI, I saw issues with executing pplib commands while mining. Occasionally, the hash rate would drop ~20% on one of the adapters, then recover. There seems to be some interaction between phoenix and aticonfig that I haven't had time to dig into.

If you found this post useful, feel free to share the wealth: 1E35gTBmJzPNJ3v72DX4wu4YtvHTWqNRbM
simplecoin
Sr. Member
****
Offline Offline

Activity: 406
Merit: 250



View Profile WWW
August 04, 2011, 04:27:15 PM
 #7

For anyone who wants a silent box I modified this to adjust fan speed as a second priority to speed. As well as a few display tweaks

FYI, I saw issues with executing pplib commands while mining. Occasionally, the hash rate would drop ~20% on one of the adapters, then recover. There seems to be some interaction between phoenix and aticonfig that I haven't had time to dig into.


I've seen that as well, when pushing the mhz wall (usually get a few bad shares at that speed too). However, I'm running this script with cgminer and 4x6870s, there are tiny, quick dips in hashrates but usually only when overheating. I'd rather turn up the fans and have a 1sec dip then downclock as a priority.

I use it and have no issues, so I shared Wink YMMV

Donations: 1VjGJHPtLodwCFBDWsHJMdEhqRcRKdBQk
krzynek1
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
August 10, 2011, 11:29:18 AM
 #8

bcforum, can you modify your script to control only specified adapter ?

this could be useful in cases when user have different clocks for cards
bcforum (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
August 11, 2011, 03:41:32 AM
 #9

bcforum, can you modify your script to control only specified adapter ?

this could be useful in cases when user have different clocks for cards

Take a look at the OP. I haven't tested it much.

If you found this post useful, feel free to share the wealth: 1E35gTBmJzPNJ3v72DX4wu4YtvHTWqNRbM
krzynek1
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
August 15, 2011, 09:26:50 AM
 #10

how do I specify clocks and max temperatures for each adapter ?

is it like this ?

Code:
TARGETTEMP=(88 90 92 89)
MAXCLOCK=(940 930 900 920)
bcforum (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
August 15, 2011, 01:01:22 PM
 #11

how do I specify clocks and max temperatures for each adapter ?

is it like this ?

Code:
TARGETTEMP=(88 90 92 89)
MAXCLOCK=(940 930 900 920)


Yes, that is exactly right. If you have more adapters than numbers, the last number will be used for all remaining adapters.

If you found this post useful, feel free to share the wealth: 1E35gTBmJzPNJ3v72DX4wu4YtvHTWqNRbM
krzynek1
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
August 15, 2011, 09:25:16 PM
 #12

ok, i will try that script, will be reporting, thank you anyway
deti
Member
**
Offline Offline

Activity: 65
Merit: 10


View Profile WWW
August 17, 2011, 08:04:33 PM
 #13

I like this security improvement! Smiley

Am I right that if the current clock is below 500 it will not speed up again?

Code:
            elif [ "$curclk" -lt "500" ]; then
                echo "Adapter $i is idle"

What is the purpose of that?

bcforum (OP)
Full Member
***
Offline Offline

Activity: 140
Merit: 100


View Profile
August 18, 2011, 01:41:16 AM
 #14

I like this security improvement! Smiley

Am I right that if the current clock is below 500 it will not speed up again?

Code:
            elif [ "$curclk" -lt "500" ]; then
                echo "Adapter $i is idle"

What is the purpose of that?

When my miners went idle the clock would drop to 250MHz. Since the script is (intentionally) stateless, it would attempt to speed the GPUs up and write 251MHz. This was accepted as 500MHz (the minimum clock speed for the 6970). When the miner was started, it would slowly increase speed from 500MHz to 940MHz, taking approximately 1 hour to reach full speed.

If you found this post useful, feel free to share the wealth: 1E35gTBmJzPNJ3v72DX4wu4YtvHTWqNRbM
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!