2012-02-26, 15:24
So I've been experimenting with a perl script to control fan speeds on my Nvidia GT430 based on GPU temp.
This came about because I was finding the automatic fan control would fluctuate too much. For example the fan would alternatate between 45% and 50% when the temperature sensor fluctutated between 59C-60C. I personally found it was the change in fan speed that was more annoying than the fan speed itself. So I wrote a script to gradually change fan speed instead.
The issue I have is that when calling nvidia-settings to adjust the fan speed it causes video playing in xbmc to stutter.
My script uses the following command to set fan speed (where X is fan speed %):
Experimenting further it seems any call to nvidia-settings causes stutter, even when lowering the priority using 'nice'.
Can anyone else confirm this issue? Is there an alternative (possibly more low level) way of setting GPU fan speeds without nvidia-settings? As you will see from my script I'm already using nvidia-smi to get the GPU temp rather than calling nvidia-settings as I get 0 stutter with it.
Here is my (amatuer) perl script for anyone interested:
PS The script must be from from a desktop terminal. To run over SSH then first do: I also had to put: in the screen section of my xorg.conf file to enable fan control.
This came about because I was finding the automatic fan control would fluctuate too much. For example the fan would alternatate between 45% and 50% when the temperature sensor fluctutated between 59C-60C. I personally found it was the change in fan speed that was more annoying than the fan speed itself. So I wrote a script to gradually change fan speed instead.
The issue I have is that when calling nvidia-settings to adjust the fan speed it causes video playing in xbmc to stutter.
My script uses the following command to set fan speed (where X is fan speed %):
PHP Code:
nvidia-settings -a [fan:0]/GPUCurrentFanSpeed=X
Experimenting further it seems any call to nvidia-settings causes stutter, even when lowering the priority using 'nice'.
Can anyone else confirm this issue? Is there an alternative (possibly more low level) way of setting GPU fan speeds without nvidia-settings? As you will see from my script I'm already using nvidia-smi to get the GPU temp rather than calling nvidia-settings as I get 0 stutter with it.
Here is my (amatuer) perl script for anyone interested:
PHP Code:
#!/usr/bin/perl
# fancontrol.pl - Experimental script to control nVidia GPU fan speed
# Minimum possible fan speed
$fan_min_speed = 40;
# Maximum possible fan speed
$fan_max_speed = 100;
# Set fan to 40% at start
$current_fan_speed = 40;
# Trigger temperature for decreasing/increasing fan speed
$ideal_temp = 60;
# 'Dead' zone around $ideal_temp where no change is made to fan speed
$temp_var = 2;
# Enable manual fan control
system "nvidia-settings -a [gpu:0]/GPUFanControlState=1";
# Open log file
open (LOGFILE, '>>/tmp/fancontrol.log');
while(1) {
# Current current GPU temp
$gpu_temp = getGPUTemp();
# If GPU temp > $ideal_temp raise fan speed
if ($gpu_temp > ($ideal_temp + $temp_var)) { $current_fan_speed = $current_fan_speed + 5; }
# If GPU temp > $ideal_temp reduce fan speed
if ($gpu_temp < ($ideal_temp - $temp_var)) { $current_fan_speed = $current_fan_speed - 2.5; }
# Ensure fan speed is within useable range
if ($current_fan_speed < $fan_min_speed) { $current_fan_speed = $fan_min_speed; }
if ($current_fan_speed > $fan_max_speed) { $current_fan_speed = $fan_max_speed; }
# Log status
print LOGFILE convEpoch(time)." - GPU Temp: $gpu_temp\C, Fan Speed: $current_fan_speed\%\n";
# If current_fan_speed has changed then set new fan speed
if ($current_fan_speed != $prev_fan_speed) {
setFanSpeed(sprintf("%.0f",$current_fan_speed));
}
$prev_fan_speed = $current_fan_speed;
# Sleep for 15 seconds
sleep(15);
}
close(LOGFILE);
exit;
sub getGPUTemp {
# Use nvidia-smi to get GPU temp (doesn't make XBMC video stutter)
@gpu_temp = `nice -n20 nvidia-smi -q -d TEMPERATURE | grep Gpu | cut -c35-36 2>&1`;
$gpu_temp[0] =~ s/\s*$//g;
return $gpu_temp[0];
}
sub setFanSpeed {
# Use nvidia-settings to set fan speed
system "nice -n20 nvidia-settings -a [fan:0]/GPUCurrentFanSpeed=$_[0] > /dev/null";
}
sub convEpoch {
# Returns human friendly time stamp
my @abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
( my $ss, my $mm, my $hh, my $day, my $month, my $y, my $wday, my $yday, my $isdst ) = localtime( $_[0] );
$y = $y + 1900;
return "$day $abbr[$month] $hh:$mm:$ss $y $isdst";
}
PS The script must be from from a desktop terminal. To run over SSH then first do:
PHP Code:
export DISPLAY=:0.0
PHP Code:
Option "Coolbits" "5"