Author

Topic: Auto temperature control .bat script using clocktweak tool (Read 3949 times)

full member
Activity: 168
Merit: 100
Very nice.
hero member
Activity: 742
Merit: 500
This looks phenomenal. I'll be giving it a shot tonight Smiley
sr. member
Activity: 503
Merit: 283
Hi! I make this script for myself, but maybe if will be useful to smb else.
It's very simple, but it can to control gpu core temperature by changing core speed depends on Minumum and Maximum margin values.
You can customize it to fit your needs
You need clocktweak tool to make it work http://forum.bitcoin.org/index.php?topic=9982.0

Here is the source code:

main script clock_adj.bat:  http://ge.tt/91RUcA6 or http://uploadbox.com/files/4c7516d82e/
Code:
echo off

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Setting up base params ::
:: DeltaClock - Value that will be added or subtracted
:: MaxTemp - Maximum Core Temperature. If it exceeded, DeltaClock subtractin is occurs
:: MinTemp - Minimum Core Temperature. If temperature will be less than this value, DeltaClock is added to core clock
:: MaxClock - Maximum Core Clock value. Core clock will never exceeds this value
:: MinClock - Minimum Core Clock value. Core clock can't be less than this value
:: ShutDownTemp - Alarm Temperature.  If it exceeded, ShutDown Actions are occurs
:: IdleValue - Idle Margin. If gpu load less than this value, no actions taken
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

SET DeltaClock=10
SET MaxTemp=77
SET MinTemp=75

SET MaxClock=960
SET MinClock=800

SET ShutDownTemp=95
SET IdleValue=50

:::::::::::::::::::::::::::::::::::::::::::::::
:: Repeat this action for each gpu installed ::
:::::::::::::::::::::::::::::::::::::::::::::::

FOR /F "tokens=1,3,5,7,9 delims=:# " %%A IN ('clocktweak.exe -r ^| Find "Temp"') DO (
echo "CardNo - %%A; Clock -  %%E; Temp -  %%B; Load -  %%C%%;"

:: If current gpu temp (%%B) greater than ShutDownTemp do ShutDown Actions ::
  if %%B GTR %ShutDownTemp% call:ShutDown %%A %%E %%B %%C

:: If current gpu temp (%%B) greater than MaxTemp do DownClock Actions ::
  if %%B GTR %MaxTemp% call:DownClock %%A %%E %%B %%C

:: If current gpu temp (%%B) less than MinTemp do UpClock Actions ::
  if %%B LSS %MinTemp% call:UpClock %%A %%E %%B %%C
)

goto:eof

:::::::::::::::::::::::::::::
:: Down Core Clock Actions ::
:::::::::::::::::::::::::::::
:DownClock
:: If gpu is idle do noting ::
if %~4 LSS %IdleValue% ( echo Card %~1 is idle! Load -  %~4; && goto:eof)

:: This speeds up a little clock Decreasing ::
set /A DeltaTempSpeed=%~3-%MinTemp%

:: Calculating new gpu clock ::
set /A NewTemp=%~2-DeltaClock-DeltaTempSpeed

:: Clock already has it's minimum value, exiting ::
if %~2 EQU %MinClock% goto:eof

:: Clock already has less than min value, so setting it to MinClock ::
if %NewTemp% LSS %MinClock% SET NewTemp=%MinClock%

echo. Decreasing clock, new value %NewTemp%; Card %~1; Old Clock %~2; Temp %~3;

:: If you didn't need a log, comment line below
echo. Decreasing clock, new value %NewTemp%; Card %~1; Old Clock %~2; Temp %~3; >> log.txt

:: Setting up new gpu clock and rotating fan to 99% (-s 99) ::
clocktweak.exe -c %NewTemp% -s 99 -y -a %~1 > nul
goto:eof

:::::::::::::::::::::::::::
:: Up Core Clock Actions ::
:::::::::::::::::::::::::::
:UpClock

:: If gpu is idle do noting ::
if %~4 LSS %IdleValue% ( echo Card %~1 is idle! Load -  %~4; && goto:eof)

:: This speeds up a little clock Increasing ::
set /A DeltaTempSpeed=%MaxTemp%-%~3

:: Calculating new gpu clock ::
set /A NewTemp=%~2+DeltaClock+DeltaTempSpeed

:: Temperature already has it's maximum value, exiting ::
if %~2 EQU %MaxClock% goto:eof

:: Clock already has more than max value, so setting it to MaxClock ::
if %NewTemp% GTR %MaxClock% SET NewTemp=%MaxClock%

echo. Increasing clock, new value %NewTemp%; Card %~1; Old Clock %~2; Temp %~3;

::If you didn't  need a log, comment line below
echo. Increasing clock, new value %NewTemp%; Card %~1; Old Clock %~2; Temp %~3; >> log.txt

:: Setting up new gpu clock and setting up fan to auto mode (-s auto)::
clocktweak.exe -c %NewTemp% -s auto -y -a %~1 > nul
goto:eof

::::::::::::::::::::::
:: ShutDown Actions ::
::::::::::::::::::::::
:ShutDown
echo Shutting down with Card %~1; Old Clock %~2; Temp %~3;
shutdown.exe -r -f -t 300 /c "I am overheating! So shutting down. Card %~1; Last Clock %~2; Last Temp %~3; Last load %~4; . "
goto:eof
This needs to be launched through certain period f.e. 1 minute or more. Use standard schedule or script listed below (cron.bat)

cron.bat http://ge.tt/8JGacA6 or http://uploadbox.com/files/751265b61b/
Code:
:10
call clock_adj.bat
timeout 60
goto 10
60 - seconds to repeat

Params are simple:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: DeltaClock - Value, that will be added or subtracted from current gpu core clock
:: MaxTemp - Maximum Core Temperature. If it exceeded, DeltaClock subtractin is occurs
:: MinTemp - Minimum Core Temperature. If temperature will be less than this value, DeltaClock is added to core clock
:: MaxClock - Maximum Core Clock value. Core clock will never exceeds this value
:: MinClock - Minimum Core Clock value. Core clock can't be less than this value
:: ShutDownTemp - Alarm Temperature.  If it exceeded, ShutDown Actions are occurs
:: IdleValue - Idle Margin. If gpu load less than this value, no actions taken
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

How does it work's ?
clock_adj.bat being launched checking current gpu core temperature , if it above MaxTemp script decrease core clock on  DeltaClock value, if below MinTemp it will increased.
If gpu core temperature is above ShutDownTemp Shut Down actions are fired.  This ShutDown Actions now  can only to shut down workstation, but you can teach it to send sms, using services like yakoon

just add line below to your Shut Down Actions
Code:
wget http://sms.yakoon.com/sms.asmx/Send?Username=YourYakoonUsername&Password=YourYakoonPassword&Sender=YourYakoonSender&Recipient=YourYakoonRecipient&Co
(you will ned a wget tool ( http://www.gnu.org/s/wget/ ) and yakoon account (http://yakoon.com/?Affiliate=Lexiko)

will be sms like this:

Code:
....
::::::::::::::::::::::
:: ShutDown Actions ::
::::::::::::::::::::::
:ShutDown
echo Shutting down with Card %~1; Old Clock %~2; Temp %~3;

:: Sending sos sms ::
wget http://sms.yakoon.com/sms.asmx/Send?Username=YourYakoonUsername&Password=YourYakoonPassword&Sender=YourYakoonSender&Recipient=YourYakoonRecipient&Co
shutdown.exe -r -f -t 300 /c "I am overheating! So shutting down. Card %~1; Last Clock %~2; Last Temp %~3; Last load %~4; . "
goto:eof

Suggestions and additions are welcome
If you like it you can donate here 1VCtYerBMGiRcGMnqdr4mZnT59Ba4L3xg , it will stimulate me to further develop.
Have a nice day! Smiley
Jump to: