Category Archives: memory

Linking Nvidia GPU temperature with a motherboard PWM fan in Linux

So I have a closed loop water cooler on my GPU and I replaced the stock single speed fan with two Noctua PWM fans (doing push/pull) connected to my motherboard. Even though the fans can be seen by lm_sensors and fancontrol the Nvidia GPU does not appear as it’s proprietary driver.

I knew nvidia-settings could be used to query the temperature (and the pump speed if you care) so I wrote a script to tie it all together:

#!/usr/bin/env bash
set -e

# This is the path to the PWM controlled fan (use lm_sensors/fancontrol to help you identify this)
# Read for your PWM chip to find the correct values (I have a nct6792)
# Temperature at which to run fan at 100% speed

# Re-enable automatic fan control on exit
trap "echo ${automatic} > ${fan}_enable; exit" SIGHUP SIGINT SIGTERM ERR EXIT

# Enable manual fan control
echo ${manual} > ${fan}_enable

function temperature() {
        nvidia-settings -q [gpu:0]/gpucoretemp -t

function fan_speed() {
        echo Setting FAN Speed to $1%
        echo $(((($1 * 255)) / 100)) > ${fan}

while true; do
        echo GPU Temperature: $temp

        if [ "$temp" -ge "$max" ] ; then
                fan_speed 100
                fan_speed $(($temp + ((100 - $max))))

        sleep 1

Then make the script sudoable without password and run on login. Now my fans run at 600rpm at idle and go up to 1100rpm when running a GPU burn in tool.

AMD ATI Graphics tearing in Chrome on Ubuntu 15.04

I had to switch to using proprietor AMD drivers as the open source ones don’t support audio via display port, but after switching, Chrome was tearing and just going completely black.

The chrome GPU page reported no hardware acceleration enabled.

So I went to Chrome Flags page and forced GPU acceleration and rasterisation

Override software rendering list -> Disabled
Enable GPU rasterization -> Force enabled on all layers
Smooth Scrolling Linux -> Enable

Bash function to switch Java versions

setjava() {
	if [ "$1" = "-q" ]; then
                local quiet=true

	local jdk=~/Applications/Java/jdk1.$1
        if [ ! -d "${jdk}" ]; then
                echo Jdk not found: ${jdk}
                return 1
	export JAVA_HOME=${jdk}
        export PATH=${JAVA_HOME}/bin:${PATH}
        if [ -z "${quiet}" ]; then
                java -version

export -f setjava

I have symlinks for all major versions of Java so that in IntelliJ and the command line I can upgrade minor Java versions just by changing the symlink:

$ ls -la ~/Applications/Java/
total 20
drwxrwxr-x. 5 dan dan 4096 Mar 27 10:12 .
drwxrwxr-x. 8 dan dan 4096 Mar 27 10:13 ..
lrwxrwxrwx. 1 dan dan   11 Mar 27 10:12 jdk1.6 -> jdk1.6.0_45
drwxr-xr-x. 8 dan dan 4096 Mar 26  2013 jdk1.6.0_45
lrwxrwxrwx. 1 dan dan   11 Mar 18 13:55 jdk1.7 -> jdk1.7.0_51
drwxr-xr-x. 8 dan dan 4096 Dec 19 03:24 jdk1.7.0_51
lrwxrwxrwx. 1 dan dan    8 Mar 27 10:12 jdk1.8 -> jdk1.8.0
drwxr-xr-x. 8 dan dan 4096 Mar  4 11:18 jdk1.8.0

Then I can switch version by either just saying the major version:

$ setjava 8
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

or I can be specific about minor version:

$ setjava 6.0_45
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

I’ve also started adding the following to my build and execution scripts so they can specify the Java version themselves:

type -t setjava > /dev/null && setjava -q 8 || if [ -n "${JAVA_HOME}" ]; then PATH=${JAVA_HOME}/bin:${PATH}; fi

Currently this is designed to be optional and will fallback to JAVA_HOME etc.