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.
#!/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):
#!/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