≡ Menu

How to find out Raspberry Pi GPU and ARM CPU temperature on Linux

I am using a Raspberry PI 2/3 credit size computer. How do I find out my GPU or ARM CPU temperature from Linux operating system command line option?

You can easily find out the GPU and ARM CPU temperature using the following commands.

Show Raspberry Pi GPU temperature

Open the Terminal application and type the following command to view GPU (Graphics Processing Unit) temperature:
vcgencmd measure_temp
OR
/opt/vc/bin/vcgencmd measure_temp
Sample output:

Fig.01: Find Raspberry pi GPU temperature

Fig.01: Find Raspberry pi GPU temperature

Display Raspberry Pi ARM CPU temperature

Type the following cat command:
cat /sys/class/thermal/thermal_zone0/temp
Divide it by 1000 to get the ARM CPU temperature in more human readable format:

cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((cpu/1000)) c"

Sample outputs:

Fig.02: Check on the ARM CPU temperature of Raspberry Pi

Fig.02: Check on the ARM CPU temperature of Raspberry Pi

Putting it all together

Create a simple bash script called my-pi-temp.sh to see both ARM CPU and GPU temperature of Raspberry Pi. Type the following command:
nano my-pi-temp.sh
OR
vi my-pi-temp.sh
Append the following code:

#!/bin/bash
# Script: my-pi-temp.sh
# Purpose: Display the ARM CPU and GPU  temperature of Raspberry Pi 2/3 
# Author: Vivek Gite <www.cyberciti.biz> under GPL v2.x+
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"

Save and close the file. Set permission:
chmod +x my-pi-temp.sh
Run it as follows:
./my-pi-temp.sh
Sample outputs:

Thu 10 Mar 01:02:19 IST 2016 @ raspberrypi
-------------------------------------------
GPU => temp=44.4'C
CPU => 44'C

Sysadmin because even developers need heroes!!!

Share this tutorial on:
{ 12 comments… add one }
  • onebuck March 12, 2016, 2:52 pm

    The temperature sensor for the SoC is on the same silicon. Your reading the same sensor for CPU when you say access to GPU. Propagation(delay) is what you are seeing when accessing the temperature for the CPU when you are assigning for the GPU temperature. Same sensor, CPU temperature access is correct but your GPU does not have a sensor independently. Just a CPU temperature can be truly accessed. Leave out the GPU temp and you will be correct. Same metric for temperatures.

    • meow April 28, 2016, 11:05 am

      You are right, no need for measuring CPU and GPU separately for SoC.

  • Riven March 29, 2016, 7:16 pm

    best way to see thermal temps and arm_freq via terminal command:
    while true; do vcgencmd measure_clock arm; vcgencmd measure_temp; sleep 1; done

    To check it under 100% CPU load:
    sudo apt-get install sysbench
    while true; do vcgencmd measure_clock arm; vcgencmd measure_temp; sleep 1; done& sysbench –num-threads=8 –test=cpu –cpu-max-prime=10000000000 run

    For optimizing, benching, and overclocking, see:
    https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=138840

  • Riven March 29, 2016, 7:22 pm

    to see all cores and load % (hit ‘1’), enter in terminal:
    top

  • dmaraid April 10, 2016, 7:08 am

    In one line:

    echo -e "CPU => $(echo "scale=1; $(cat /sys/class/thermal/thermal_zone0/temp)/1000" | bc)'C\nGPU => $(/opt/vc/bin/vcgencmd measure_temp | sed "s/^.....//g")"

  • hannes June 3, 2016, 7:37 am

    Thank you, great post!

    Just a simple addition to your ‘my-pi-temp.sh’ script:

    echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp | cut -d = -f2)"

    Makes the output a little cleaner ;-)

  • Larry Dighera July 25, 2016, 10:10 pm

    Below is the script I use for displaying RPi temperature and frequencies. It’s a hack, but usable.

    #!/usr/bin/ksh
    # Required for floating point arithmetic.  (Use bc to accommodate bash)
    # sensors.sh
    # A script to display Raspberry Pi on-board sensor data
    #
    # LGD: Mon Dec 23 04:07:23 PST 2013
    # LGD: Mon Aug 10 14:02:46 PDT 2015: Added degree symbols, over-temperature based on degrees C so it will work without bc
    #
    
    f2c(){                          # Fahrenheit to Celsius
      echo $(( ((${1}-32)*5)/9 ))
    }
    
    c2f(){                          # Celsius to Fahrenheit
      echo $(( ${1}*9/5+32 ))
    }
    
    addcomma(){                     # Format numbers with commas
      (echo "obase=1000"; cat) | bc | sed 's/^ *0*\([0-9]\)/\1/;s/ /,/g'
    }
    
    # Display current clock frequencies
    FREQ (){ echo -e "\n\t\t\t`tput smso`  C L O C K    F R E Q U E N C I E S  `tput rmso`\n"
      for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ;do
        echo -e "\t$src\t$(vcgencmd measure_clock $src) Hz"
      done| pr --indent=5 -r -t -2 -e3
      echo
    }
    
    
    TEMPC=$(/opt/vc/bin/vcgencmd measure_temp|awk -F "=" '{print $2}')      # Get Temp C
    TEMPf=$(echo -e "$TEMPC" | awk -F "\'" '{print $1}' 2>/dev/null)        # Get numeric-only Temp C
    
    TEMPF=$(c2f $TEMPf)                                                     # Convert CPU temp C to F
    OVRTMP=70                                                               # High-temp limit degrees C
    ALRM=""
    
    [[ `echo $TEMPC|cut -d. -f1` -gt ${OVRTMP:-70} ]] && ALRM="\n\t\t\t TOO HOT! \t TOO HOT! \t TOO HOT! "           # Check for over-temp: Max = 70C or 158F
    TEMPB4OVER=$(echo "${OVRTMP:-70}-${TEMPf}"|bc -l)                               # Calculate the number of degrees before over-temp condition
    
    echo -e "\n\t\t\t`tput smso`  S Y S T E M    T E M P E R A T U R E  `tput rmso`   `[[ -n $ALRM ]] || COLOR=green; setterm -foreground ${COLOR:-red}`${ALRM:-OK}"; setterm -foreground white
    
    echo -e "\n\tThe BCM2835 SoC (CPU/GPU) temperature is: ${TEMPF}° F\t(${TEMPf}° C) `tput smso;setterm -foreground red`$ALRM`setterm -foreground white;tput rmso`"        # ksh & bash
    
    echo -e "\t\t(${OVRTMP:-70}° C HIGH-TEMP LIMIT will be reached in `tput smso`${TEMPB4OVER}° C`tput rmso` higher)\n"
    
    echo -e "\n\t\t\t`tput smso`  S Y S T E M    V O L T A G E S  `tput rmso`"
    echo -e "\n\tThe Core voltage is:\t\t\c"
    /opt/vc/bin/vcgencmd measure_volts core|awk -F "=" '{print $2}'
    
    echo -e "\tThe sdram Core voltage is:\t\c"
    /opt/vc/bin/vcgencmd measure_volts sdram_c|awk -F "=" '{print $2}'
    
    echo -e "\tThe sdram I/O voltage is:\t\c"
    /opt/vc/bin/vcgencmd measure_volts sdram_i|awk -F "=" '{print $2}'
    
    echo -e "\tThe sdram PHY voltage is:\t\c"
    /opt/vc/bin/vcgencmd measure_volts sdram_p|awk -F "=" '{print $2 "\n"}'
    
    FREQ
    exit
    
  • Richard August 28, 2016, 6:21 pm

    Larry, very useful script! I hope you don’t mind a few changes that I made.

    # sensors.sh
    # ==========
    #
    # A script to display Raspberry Pi on-board sensor data
    #
    # Larry Dighera: Mon Dec 23 04:07:23 PST 2013
    # Larry Dighera: Mon Aug 10 14:02:46 PDT 2015: Added degree symbols, over-temperature based on degrees C so it will work without bc
    # Richard Elkins: 2016-08-28:
    #   * Checked for installation of `bc`.  Proceed with installation if not present (which fails if no Internet connection).
    #   * Miscellaneous readability
    #   * Deleted f2c() and addcomma() because they are never used
    #   * Deleted c2f() because it produces bash syntax errors and Farenheit is not useful in this context
    #   * Deleted first line "#!/usr/bin/ksh".  Diagnosing the Bourne shell instead.
    #   * Deleted the  characters which seem to be spurious (?)
    
    # --- FREQ: Display current clock frequencies
    FREQ () {
       echo -e "\n\t\t\t`tput smso`  C L O C K    F R E Q U E N C I E S  `tput rmso`\n"
       for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ;do
          echo -e "\t$src\t$(vcgencmd measure_clock $src) Hz"
       done | pr --indent=5 -r -t -2 -e3
       echo
    }
    
    # --- Main Procedure
    
    # Diagnose the Bourne shell which is not supported
    if [ `ps | tail -n 4 | sed -E '2,$d;s/.* (.*)/\1/'` = "sh" ]; then
       echo
       echo "*** Oops, the Bourne shell is not supported"
       echo
       exit 86
    fi
    
    # Make sure that `bc` is installed
    flagbc=`which bc`
    if [ -z $flagbc ]; then
       echo Installing bc # {small}
       sudo apt-get -y install bc
    fi
    
    # Do temperature calculations
    TEMPC=$(/opt/vc/bin/vcgencmd measure_temp|awk -F "=" '{print $2}')      # Get Temp C
    TEMPf=$(echo -e "$TEMPC" | awk -F "\'" '{print $1}' 2>/dev/null)        # Get numeric-only Temp C
    OVRTMP=70                                                               # High-temp limit degrees C
    ALRM=""
    [[ `echo $TEMPC|cut -d. -f1` -gt ${OVRTMP:-70} ]] && ALRM="\n\t\t\t TOO HOT! \t TOO HOT! \t TOO HOT! "           # Check for over-temp: Max = 70C or 158F
    TEMPB4OVER=$(echo "${OVRTMP:-70}-${TEMPf}"|bc -l)                               # Calculate the number of degrees before over-temp condition
    
    # Display temperatures
    echo -e "\n\t\t\t`tput smso`  S Y S T E M    T E M P E R A T U R E  `tput rmso`   `[[ -n $ALRM ]] || COLOR=green; setterm -foreground ${COLOR:-red}`${ALRM:-OK}"; setterm -foreground white
    echo -e "\n\tThe BCM2835 SoC (CPU/GPU) temperature is: ${TEMPf}°C `tput smso;setterm -foreground red`$ALRM`setterm -foreground white;tput rmso`"
    echo -e "\t(${OVRTMP:-70}°C HIGH-TEMP LIMIT will be reached in `tput smso`${TEMPB4OVER}°C`tput rmso` higher)\n"
    
    # Display voltages
    echo -e "\n\t\t\t`tput smso`  S Y S T E M    V O L T A G E S  `tput rmso`"
    echo -e "\n\tThe Core voltage is:\t\t\c"
    /opt/vc/bin/vcgencmd measure_volts core|awk -F "=" '{print $2}'
    echo -e "\tThe sdram Core voltage is:\t\c"
    /opt/vc/bin/vcgencmd measure_volts sdram_c|awk -F "=" '{print $2}'
    echo -e "\tThe sdram I/O voltage is:\t\c"
    /opt/vc/bin/vcgencmd measure_volts sdram_i|awk -F "=" '{print $2}'
    echo -e "\tThe sdram PHY voltage is:\t\c"
    /opt/vc/bin/vcgencmd measure_volts sdram_p|awk -F "=" '{print $2 "\n"}'
    
    # Display frequencies
    FREQ
    exit
    
  • Richard August 28, 2016, 6:24 pm

    Somehow, I lost some spacing in the script even though my copy has them. Aargh!

    • Vivek Gite August 28, 2016, 8:47 pm

      You need to wrap script between <pre> and </pre> . I edited out to add <pre> and </pre> in your comment. Cheers.

      • Richard November 10, 2016, 4:09 pm

        Vivek – thanks (belated!).

  • enola September 29, 2016, 7:18 pm

    Thanks mate, this is really helpful !
    enola

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , ,