Last active
August 16, 2017 17:52
-
-
Save Madh93/187553738887692dfd059bc4a213fc6d to your computer and use it in GitHub Desktop.
Check temperature and set fan speed value of Nvidia card
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# | |
# nvidia-fanspeed | |
# | |
# `nvidia-fanspeed` check temperature and set fan speed value | |
# | |
# Requirements: nvidia-xconfig --cool-bits=4 | |
############################## | |
# Custom configuration: | |
# "TEMPERATURE(ºC) TARGET_SPEED(%)" | |
######## | |
config=( | |
"35 0" | |
"40 20" | |
"45 30" | |
"50 40" | |
"60 50" | |
"65 60" | |
"70 70" | |
"75 80" | |
"80 90" | |
"100 100" | |
) | |
############################## | |
# Set fan control | |
nvidia-settings -a "GPUFanControlState=1" > /dev/null 2>&1 | |
# Get temperature value | |
temp() { | |
echo $1 | |
} | |
# Get speed value | |
speed() { | |
echo $2 | |
} | |
# Get current Nvidia temperature | |
current_gpu_temp() { | |
nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits || echo 0 | |
} | |
# Set target fan speed | |
set_fan_speed() { | |
nvidia-settings -a "[fan:0]/GPUTargetFanSpeed=$1" > /dev/null 2>&1 | |
} | |
while true; do | |
for values in "${config[@]}"; do | |
if [ $(current_gpu_temp) -lt $(temp $values) ]; then | |
break | |
fi | |
done | |
set_fan_speed $(speed $values) | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment