Monday 25 March 2013

Using aticonfig over SSH


Want to overclock or underclock your AMD/ATI GPU on a linux box via SSH?

Usually, it'll return "aticonfig: This program must be run as root when no X server is active" or "ERROR - X needs to be running to perform ATI Overdrive(TM) commands" because it's looking for X on your local system. If you run as root and have an AMD card in the local machine then you'll get the info for your local card, not the system you're connected to.

To get around this use:

export DISPLAY=:0
xhost +

and now your aticonfig and amdconfig commands will run as normal on the remote machine, e.g. To check the temperature, retrieve the current core/memory clocks and get the current fanspeed:

aticonfig --odgt
aticonfig --odgc
aticonfig --pplib-cmd "get fanspeed 0"

To set the core and memory clocks

aticonfig --odsc 1000,1200

will set the core to 1000Mhz and memory to 1200Mhz.

To set the fanspeed

aticonfig --pplib-cmd "set fanspeed 0 100"

will set the fan to max speed.

aticonfig --pplib-cmd "set fanspeed 0 auto"

will put it back to temperature controlled.


Friday 15 March 2013

Overclocking Nvidia Cards from the linux command line.

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.