Quantcast
Channel: hashcat Forum - All Forums
Viewing all articles
Browse latest Browse all 7675

Temperature control for multiple sessions

$
0
0
I have had some scenarios with hashcat that lead to the creation of this script.  It is bash for use with an Nvidia GPU in Linux.  I hope you guys get some use out of it.

Enjoy.

Code:
#!/bin/bash

#This script will keep the fan running on a single gpu in the event that you have more than one hashcat process running and one hashcat process is terminated.
#This script assumes that you already have the fan speed running to your liking during an existing hashcat session.
#KEEP THIS IN MIND BEFORE YOU RUN IT.  It will not set your fan speeds prior to you running hashcat for the first time.

#In cases where the fan speed has been set manually and --gpu-temp-retain has not been used to maintain the fan speeds, this has utility.

#Some scenarios where this might be useful are:
#1. --gpu-temp-retain has not been used.
#2. There was more than one hashcat session running, but one has terminated for some reason and has taken the fan speed down with it.
#3. You have old sessions (.restore files) that were not using --gpu-temp-retain and want to run more than one of these sessions at a time.  This could be from converting from water cooling to air cooling.  Manual fan control would be necessary as a result.

#This script will keep the GPU below 61 C by resetting the fan speed to 80 percent.
#This script was designed for use with fast hashes using the GTX 1080 FE.  80 percent fan is usually enough to keep the temperature below 61 C.
#This script uses nvidia-settings to get the temperature reading on the GPU (gpu:0).
#There is a 200 Mhz overclock in the keep_fan_on function.  This was put in for the GTX 1080 FE, but can be adjusted or removed as you see fit.
#You can adjust the other values as you see fit.

#debug on
set -x

#Declare GPU temp integer

declare -i gpu0temp

#Declare functions for fan control

function keep_fan_on {
nvidia-settings -a GPUFanControlState=1 --ctrl-display=:0
nvidia-settings -a GPUTargetFanSpeed=80 --ctrl-display=:0
nvidia-settings -a GPUPowerMizerMode=1 --ctrl-display=:0
nvidia-settings -a GPUGraphicsClockOffset[3]=200 --ctrl-display=:0
}

function turn_fan_off {

#Reset fans when process ends
nvidia-settings -a GPUGraphicsClockOffset[3]=0 --ctrl-display=:0
nvidia-settings -a GPUPowerMizerMode=0 --ctrl-display=:0
nvidia-settings -a GPUFanControlState=0 --ctrl-display=:0
}

while :
do
       #Watch for running hashcat process
       pidcheck=$(ps -e | grep 'hashcat')
       #Get temp from single gpu
       gpu0temp=$(nvidia-settings -q all --ctrl-display=:0 | grep 'GPUCoreTemp' | grep 'Attribute' | grep 'gpu' | awk -F':' '{print $4}' | awk -F'.' '{print $1}' | awk -F ' ' '{print $1}')
       date
       echo "Watching hashcat process(es)..."

       #As long as one hashcat process is detected, then keep the gpu fan running to keep the temperature down
       if [[ $pidcheck != "" ]]
       then
               if (( $gpu0temp > 60 ))
               then
                       #Keep fan at 80 percent if the conditions are met
                       #This may execute more than once at an interval of 10 seconds until the temperature is below 61 C.
                       echo "Temperature has risen above 60 C"
                       echo "Restoring fan speed to 80 percent."
                       turn_fan_off
                       sleep 1
                       keep_fan_on
               fi
       else
               echo "No hashcat process(es) are detected."
               echo "Resetting fans to normal speed."
               turn_fan_off
               #All done, breaking out of while loop
               break
       fi
sleep 10
clear
done
echo "hashcat no longer has any processes/sessions running."
echo "Fan speeds are back to normal."

Viewing all articles
Browse latest Browse all 7675

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>