Bitcoin Forum

Bitcoin => Mining => Topic started by: mikegogulski on June 07, 2011, 04:50:27 PM



Title: gpu-temp-monitor: an optimum clocking tool for AMD GPUs
Post by: mikegogulski on June 07, 2011, 04:50:27 PM
I got inspired by this other thread (http://forum.bitcoin.org/index.php?topic=10062.msg167868#msg167868) and wrote a bash script to manage GPU core clocks versus temperature. gpu-temp-monitor supports up to 8 AMD GPUs (or more, by editing the initialization of the "holds" array).

The script assumes that you have DISPLAY and whatnot set up correctly in your environment, and that you've opened up a nice range for over/underclocking with AMDoverdrivectrl or similar.

Code:
#!/bin/bash

TEMP_HIGH=95 # degrees C
FREQ_MAX=900 # MHz
FREQ_STEP_UP=5 # MHz
FREQ_STEP_DOWN=30 # MHz
MEM_FREQ=150 # MHz
HOLD_TIME=15 # sec
TOLERANCE=2 # degrees C
IGNORE_TEMP=$((TEMP_HIGH-TOLERANCE))
OUTPUT_INTERVAL=1 # sec

holds=( 0 0 0 0 0 0 0 0 )

setclock() {
id=$1
clock=$2
if [ $clock -gt $FREQ_MAX ]; then
clock=$FREQ_MAX
fi
aticonfig --adapter=$id --odsc=$clock,$MEM_FREQ 2>&1 > /dev/null
holds[$id]=$HOLD_TIME
}

reclock() {
id=$1
temp=$2
clock=$3
flag='-'
hold=${holds[$id]}
if [ $hold -gt 0 ]; then
holds[$i]=$((${holds[$id]}-OUTPUT_INTERVAL))
elif [ $temp -ge $TEMP_HIGH ]; then
setclock $id $((clock-FREQ_STEP_DOWN))
flag='v'
elif [ $clock -lt $FREQ_MAX -a $temp -lt $IGNORE_TEMP ]; then
setclock $id $((clock+FREQ_STEP_UP))
flag='^'
fi
echo -n "$temp ($clock$flag) "
}

aticonfig --od-enable 2>&1 > /dev/null

while true
do
unset T
unset C
temps=`aticonfig --adapter=all --odgt | grep : | sed 's/.* - \([0-9]*\)\..*/\1/'`
clocks=`aticonfig --adapter=all --odgc | grep "Current Peak" | sed 's/.*: *\([0-9]*\) .*/\1/'`
i=0
for val in $temps; do
T[$i]=$val
i=$((i+1))
done

i=0
for val in $clocks; do
C[$i]=$val
i=$((i+1))
done

i=0
while [ $i -lt ${#T[*]} ]; do
reclock $i ${T[$i]} ${C[$i]}
i=$((i+1))
done

echo
sleep $OUTPUT_INTERVAL
done

And the mandatory megascreenshot:

https://i.imgur.com/6ZJOG.png (http://imgur.com/6ZJOG)


Title: Re: gpu-temp-monitor: an optimum clocking tool for AMD GPUs
Post by: HudsonStan on June 08, 2011, 10:36:17 AM
Nice bash script. Thanks for share.