You were never here, you didn't see anything..

Cleaner GPU Temps

I wrote a post not too long ago about getting temps from the GPUs. I recently took a second look at that and came up with a cleaner and much more versatile approach to getting the data and ever presenting the data. All of the ugly sed-ness (not saying sed is bad or anything, just not the right approach here) and made it possible to much more easily change the output by having each temp as a variable. So the two things I did were:

  1. Added the “-t” option to the nvidia-settings string. This causes it to only return the values and not the details.
  2. Placed the temp values into a bash array

The cleaned up product:

# Get and return GPU and ambient temp readings from the 3 Nvidia cards
arrayTEMP=( $(nvidia-settings -t \
	-q kaon:0[thermalsensor:0]/ThermalSensorReading \
	-q kaon:0[thermalsensor:1]/ThermalSensorReading \
	-q kaon:0[thermalsensor:2]/ThermalSensorReading \
	-q kaon:0[thermalsensor:3]/ThermalSensorReading \
	-q kaon:0[thermalsensor:4]/ThermalSensorReading \
	-q kaon:0[thermalsensor:5]/ThermalSensorReading \
	2> /dev/null) )

	echo -e "GeForce GTX465 0"
	echo -e "       GPU  ------ ${arrayTEMP[0]}"
	echo -e "       Card ------ ${arrayTEMP[1]}"
	echo -e "GeForce GTX465 1"
	echo -e "       GPU  ------ ${arrayTEMP[2]}"
	echo -e "       Card ------ ${arrayTEMP[3]}"
	echo -e "GeForce GTX465 2"
	echo -e "       GPU  ------ ${arrayTEMP[4]}"
	echo -e "       Card ------ ${arrayTEMP[5]}"

And the output looks like:

andarius@kaon : ./
GeForce GTX465 0
       GPU  ------ 52
       Card ------ 42
GeForce GTX465 1
       GPU  ------ 46
       Card ------ 40
GeForce GTX465 2
       GPU  ------ 39
       Card ------ 35

Have any Question or Comment?

One comment on “Cleaner GPU Temps

Leave a Reply

Your email address will not be published. Required fields are marked *


This blog is kept spam free by WP-SpamFree.

Most who fail…

Most who fail have yet to really try!