Today, I was interested in overclocking an older nVidia card - a Geforce 240 GT - on a machine running Ubuntu. I'm using the latest nvidia drivers (ver 310.40) and found that simply enabling coolbits in xorg.conf was not quite enough to get the full range of overclocking I wanted.
Firstly, there are different levels to which you can enable coolbits. Under the "Device" section of /etc/X11/xorg.conf (for example: sudo nano /etc/X11/xorg.conf) you need to add Option "Coolbits" "x". Here x indicates what options you want available from the GUI menu. So that section will look something like:
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce GT 240"
Option "Coolbits" "5"
EndSection
"1" enables the core and memory overclocking.
"4" enables the fanspeed control
"5" enables both core and memory overclocking and fanspeed control.
I haven't checked what the others do, but I think "2" attempts to enable SLI support. It's possible you can adjust the shader clock with the correct integer, but I lost patience.
Now once cool bits is enabled you can adjust the core/memory clocks and fan speeds as you wish. However, the shader clock is tied to the core clock. I wanted to increase this independently and also automatically overclock while I ran a particular program along with increasing the fanspeed to full, followed by putting everything back to stock when I exited the program.
You can control the core, shader and memory clocks from the command line using the following commands (WARNING: USE AT OWN RISK):
nvidia-settings -a [gpu:0]/GPUOverclockingState=1 # Enables overclocking.
nvidia-settings -a [gpu:0]/GPU3DClockFreqs=corefreq,memfreq # set 3D profile's core and memory speeds.
nvidia-settings -a [gpu:0]/GPUCurrentProcessorClockFreqs=shaderfreq # set shader clock speed.
To set things back to default:
nvidia-settings -a [gpu:0]/GPUOverclockingState=0 # Disables overclocking.
To control the fan speeds:
nvidia-settings -a [gpu:0]/GPUFanControlState=1 # Enables manual fan control.
nvidia-settings -a [fan:0]/GPUCurrentFanSpeed=x # set fan speed as a percentage. Note that the attribute is fan, not gpu here.
To set back to default:
nvidia-settings -a [gpu:0]/GPUFanControlState=0 # Disable manual fan control.
You can check the current values and ranges for each of these by using nvidia-settings -q. For example:
nvidia-settings -q GPU3DClockFreqs
which will return the info about the core and memory clock command. Further, you can see every available option with nvidia-settings -q all. Which is probably best piped into a temporary file for readability and searching.
Another extra thing I learned today while using these in my bash script is that you can catch a ctrl+c kill command and perform a set of commands when it is issued using the trap command. For example:
#!/bin/bash
trap ctrl_c INT # trap ctrl-c and call ctrl_c()
ctrl_c() {
echo "\nExiting..."
exit
}
for i in $(seq 1 10);do
sleep 1; echo -n "."
done
This will print 10 dots before exiting or you can interrupt it with Ctrl+C.
Using these two, I got my script as I wanted:
#!/bin/bash
trap ctrl_c INT
ctrl_c(){
nvidia-settings -a [gpu:0]/GPUOverclockingState=0
nvidia-settings -a [gpu:0]/GPUFanControlState=0
echo "clocks and fan back to default.. exiting"
exit
}
nvidia-settings -a [gpu:0]/GPUFanControlState=1
nvidia-settings -a [fan:0]/GPUCurrentFanSpeed=100
nvidia-settings -a [gpu:0]/GPUOverclockingState=1
nvidia-settings -a [gpu:0]/GPU3DClockFreqs=665,1700
nvidia-settings -a [gpu:0]/GPUCurrentProcessorClockFreqs=1700
<commands I wanted to run with overclocked GPU>
You can also nest a trap within the function, so you might want multiple behaviours for each issue of ctrl+c or you might want to iterate the function so that it isn't possible to exit using ctrl+c.