NVidia 风扇速度再探讨
发布于 2008年10月30日
在我上一篇关于调整NVidia显卡风扇速度的文章的评论中,有人提到需要一个脚本来根据温度调整速度。 这里介绍的脚本正是做这件事的。
该脚本接受一个参数,即期望的温度(默认为50C)。 然后,它根据此温度计算低和高温度,如果温度高于最大值,则提高风扇速度;如果温度低于最小值,则降低风扇速度。
它通过解析以下命令的输出确定温度和风扇速度:nvclock事不宜迟,这是脚本
#!/bin/bash
#
# Adjust fan speed automatically.
# Location of the nvclock program.
nvclock_bin=/usr/local/bin/nvclock
# Target temperature for video card.
target_temp=50
# Value used to calculate the temperature range (+/- target_temp).
target_range=1
# Time to wait before re-checking.
sleep_time=120
# Minimum fan speed.
min_fanspeed=20
# Fan speed increment.
adj_fanspeed=5
if [[ "$1" ]]; then target_temp=$1; fi
let target_temp_low=target_temp-target_range
let target_temp_high=target_temp+target_range
while true
do
temp=$(echo $($nvclock_bin --info | grep -i 'GPU temperature' | cut -d ':' -f 2))
pwm=$(echo $($nvclock_bin --info | grep -i 'PWM duty cycle' | cut -d ':' -f 2))
temp_val=${temp/C/}
pwm_val=${pwm%.*}
if [[ $temp_val -gt $target_temp_high ]]; then
# Temperature above target, see if the fan has any more juice.
if [[ $pwm_val -lt 100 ]]; then
echo "Increasing GPU fan speed, temperature: $temp"
let pwm_val+=adj_fanspeed
if [[ $pwm_val -gt 100 ]]; then pwm_val=100; fi
$nvclock_bin -f --fanspeed $pwm_val
fi
elif [[ $temp_val -lt $target_temp_low ]]; then
# Temperature below target, lower the fan speed
# if we're not already at the minimum.
if [[ $pwm_val -gt $min_fanspeed ]]; then
echo "Decreasing GPU fan speed, temperature: $temp"
let pwm_val-=adj_fanspeed
if [[ $pwm_val -lt $min_fanspeed ]]; then pwm_val=$min_fanspeed; fi
$nvclock_bin -f --fanspeed $pwm_val
fi
fi
sleep $sleep_time
done
# vim: tabstop=4: shiftwidth=4: noexpandtab:
# kate: tab-width 4; indent-width 4; replace-tabs false;
可以更改脚本顶部的设置值进行调整
- 位置nvclock位于。
- 默认目标温度。
- 温度范围的宽度。
- 检查温度的频率。
- 最小风扇速度。
- 改变风扇速度时的调整幅度。