Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bpytop doesn't show temps on RPi4 #45

Closed
RedBearAK opened this issue Aug 9, 2020 · 71 comments
Closed

[BUG] Bpytop doesn't show temps on RPi4 #45

RedBearAK opened this issue Aug 9, 2020 · 71 comments
Assignees
Labels
bug Something isn't working

Comments

@RedBearAK
Copy link
Contributor

Hardware: Raspberry Pi 4B 8GB
Software: Twister OS 1.5 (basically just a skin on top of Raspbian 32-bit)

Bpytop doesn't show CPU temps for me on this platform, which is odd because Bashtop shows the temps just fine on the same machine. Doesn't seem to be a problem with the menu setting.

Screenshot (Bashtop left, Bpytop right):

Screenshot_2020-08-08_16-00-59

@RedBearAK RedBearAK added the bug Something isn't working label Aug 9, 2020
@RedBearAK
Copy link
Contributor Author

I also noticed just now that Bashtop shows its name in the terminal title bar, while Bpytop doesn't. A minor issue, but it can be handy when Alt+Tabbing between many open terminal windows.

@RedBearAK
Copy link
Contributor Author

Notice there is a mysterious "e" off by itself in the Bpytop screenshot. That disappears when I set "Check temp" to false. So maybe it's just some kind of screen rendering issue. Like the temps are being covered up by the rest of the CPU info box.

@aristocratos
Copy link
Owner

aristocratos commented Aug 9, 2020

@RedBearAK
Fixed in v1.0.8

@RedBearAK
Copy link
Contributor Author

Celebrated too soon. Regret to report mission failure, Captain.

The phantom "e" has certainly disappeared, but the temp block doesn't show even after cycling the "Check temp" option True-False-True. This time there is no visible difference regardless of the setting.

Still working fine in bashtop. Let me know if there is something I can do to help troubleshoot, like running a debug version.

Screenshot:
Screen Shot 2020-08-09 at 2 15 40 PM

@RedBearAK
Copy link
Contributor Author

Neofetch output just in case there's a clue to why it isn't working:

Screen Shot 2020-08-09 at 2 26 59 PM

@RedBearAK
Copy link
Contributor Author

Just noticed the name is back in the title bar already in BpyTOP. Nice.

@aristocratos
Copy link
Owner

@RedBearAK
New attempt: Fixed in v1.0.9 :)

@drazil100
Copy link
Contributor

Screenshot from 2020-08-10 14-12-04
No temps on my pi on v1.0.9

@aristocratos
Copy link
Owner

@drazil100

Can you run commands:
vcgencmd measure_temp
and
python3 -c "import subprocess; print(round(float(subprocess.check_output(['vcgencmd', 'measure_temp'], text=True)[5:-2])))"
on your pi.

@drazil100
Copy link
Contributor

austin@coded-dragon:~$ sudo vcgencmd measure_temp
temp=33.0'C
austin@coded-dragon:~$ sudo python3 -c "import subprocess; print(round(float(subprocess.check_output(['vcgencmd', 'measure_temp'], text=True)[5:-2])))"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: could not convert string to float: "33.0'"
austin@coded-dragon:~$ 

@aristocratos
Copy link
Owner

Forgot a newline at the end I think.

try: python3 -c "import subprocess; print(round(float(subprocess.check_output(['vcgencmd', 'measure_temp'], text=True)[5:-3])))"

@aristocratos
Copy link
Owner

or instead:
python3 -c "import subprocess; print(round(float(subprocess.check_output(['vcgencmd', 'measure_temp'], text=True).strip()[5:-2])))"

@drazil100
Copy link
Contributor

sudo python3 -c "import subprocess; print(round(float(subprocess.check_output(['vcgencmd', 'measure_temp'], text=True).strip()[5:-2])))"
34

@aristocratos
Copy link
Owner

Alright, thanks :) Should be fixed in next version.

Always a bother to get these things working when not having the actual hardware to test on.

@aristocratos
Copy link
Owner

Finally fixed in v1.0.10

@drazil100
Copy link
Contributor

Screenshot from 2020-08-10 15-46-04
Screenshot from 2020-08-10 15-46-45

@RedBearAK
Copy link
Contributor Author

I get the same output from those commands as drazil100.

However, although I'm sure you're fixing something, I still don't see the temps. I've verified I'm using 1.0.10 and "Check temp" is enabled.

Also this version seems to take an unusually long time to go through the checklist before it starts up. Like around 10 seconds, where previously it seemed more like around 3 seconds at the most.

@drazil100
Copy link
Contributor

@RedBearAK The checklist is completely and entirely optional and can be turned off in the options. Loads pretty much instantly when "Show init" is disabled

@RedBearAK
Copy link
Contributor Author

RedBearAK commented Aug 10, 2020

@RedBearAK The checklist is completely and entirely optional and can be turned off in the options. Loads pretty much instantly when "Show init" is disabled

@drazil100
I did not realize that, thanks. Still odd that it's suddenly taking a lot longer.

@drazil100
Copy link
Contributor

I figured out the problem. vcgencmd requires sudo to run. Bashtop has the same issue with pi temperatures but if I run it with sudo it works. Sudo does not however help with bpytop. My friend suggests checking out "/sys/class/thermal/thermal_zone0/temp". He says it works with x86 too.

@drazil100
Copy link
Contributor

From my friend:
"I really recommend that he looks into more stuff that he could look up in /proc or /sys without shelling out to subprocess
It'd be a lot lighter
Spinning up processes and pipes is kinda expensive
(that said using /proc for processes would be counterproductive and using psutil like he is is definitely the better approach)"

@RedBearAK
Copy link
Contributor Author

I figured out the problem. vcgencmd requires sudo to run. Bashtop has the same issue with pi temperatures but if I run it with sudo it works. Sudo does not however help with bpytop. My friend suggests checking out "/sys/class/thermal/thermal_zone0/temp". He says it works with x86 too.

@drazil100
That doesn't make much sense to me. Neither of the commands from earlier in this thread required sudo to run on my system, and I actually don't understand why you ran them with sudo. I've also never needed to run BashTOP as sudo to see the temps displayed on any Raspberry Pi operating system I've tried. The shell script that I made to display GPU and CPU temps on the RPi4B (copied from some online forum) has never needed sudo to work. I think you're barking up the wrong tree. What OS are you using?

@drazil100
Copy link
Contributor

Raspbian. And I ran them with sudo because it returned this when I didn't

austin@coded-dragon:~$ vcgencmd measure_temp
VCHI initialization failed
austin@coded-dragon:~$ python3 -c "import subprocess; print(round(float(subprocess.check_output(['vcgencmd', 'measure_temp'], text=True).strip()[5:-2])))"
VCHI initialization failed
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['vcgencmd', 'measure_temp']' returned non-zero exit status 255.
austin@coded-dragon:~$

@dasrocky
Copy link

+1. This still doesn't work yet (v1.0.10). I use both Bashtop & Bpytop. You mentioned this command and this works perfectly {sudo python3 -c "import subprocess; print(round(float(subprocess.check_output(['vcgencmd', 'measure_temp'], text=True).strip()[5:-2])))"}

Love your work. Fan of this TUI

@drazil100
Copy link
Contributor

@RedBearAK
Also just cause bashtop doesn't require you to run it as sudo to see temps doesn't mean mine doesn't and i'm on the official distro. Trying to provide as much information as I can is all. :P

@RedBearAK
Copy link
Contributor Author

RedBearAK commented Aug 11, 2020

@drazil100
That is weird. I don't recall needing to use sudo to run vcgencmd even on stock Raspberry Pi OS, but I could be wrong. Perhaps you should think about getting a newer version of the OS.

I don't feel like it's normal to need to sudo just to check the temps. I can't run something like "apt update" on my system without sudo, but I can run vcgencmd just fine with user permissions.

Certainly it will need to be addressed if that is actually how Raspbian or current Raspberry Pi OS behaves by default, but I think your issue is actually a separate problem from why the temps aren't displaying, at least on my system.

@drazil100
Copy link
Contributor

Its possible its because im not using the pi account the image came with. Either way vcgencmd is probably not something that should be permissionless cause it does quite a bit more than just check the temperatures. Also I got my pi is pretty current on the OS.

@RedBearAK
Copy link
Contributor Author

Its possible its because im not using the pi account the image came with.

@drazil100
You know, I was going to ask about exactly that. Maybe you're missing one of the permission groups the pi user was in. It's unlikely that it would be worth the trouble for the dev to try and work around not being able to run vcgencmd without sudo, when you could just run bpytop as sudo if you need to, the same way you've been running bashtop to make it show temps.

@RedBearAK
Copy link
Contributor Author

Yes, it does fix it for RedBearAK.

Whodunit? You dunit, @aristocratos 👍

I can't really tell because the room the Pi is in is cold at the moment and it has a big Ice Tower cooler with thermal paste, so the stress test is failing to increase the temp, but did you make the color of the temp display responsive to the temperature range? Or is it just changed from solid blue to solid purple?

Screen Shot 2020-08-11 at 11 14 01 AM

Screen Shot 2020-08-11 at 11 18 43 AM

@aristocratos
Copy link
Owner

@RedBearAK

No it's because:

Is this the color you would expect it to draw the temps as for the temperature?

Nope, I forgot to set the cpu_temp_high and cpu_temp_crit values manually.

@drazil100
Copy link
Contributor

Not offhand unfortunately @aristocratos

@RedBearAK he has confirmed he forgot to set the ranges for the colors thats why they are purple

@aristocratos
Copy link
Owner

Seems like at least the pi 4 soft throttles at 60C and hard throttles at 80C. So might use those values for now.

@RedBearAK
Copy link
Contributor Author

My output running 32-bit Twister OS 1.5.2

pi@twisteros:~/Downloads $ python3 -c "import psutil; print(psutil.sensors_temperatures())"
{'cpu_thermal': [shwtemp(label='', current=31.154, high=None, critical=None)]}

@aristocratos
Copy link
Owner

Might have to look into the psutil source to investigate if 'cpu_thermal' is something reported from the sensors or a common name used by psutil. If it is, I should be able to get rid of using "vcgencmd".

@RedBearAK
Copy link
Contributor Author

So the temp display in bashtop and bpytop does respond to temp changes by changing color?

Guess I never really noticed because my cooler is too efficient. I can never get it to go above 40C anymore under a stress test, even when the room is warm. With the thermal pad that came with the cooler the temps would go to 60C.

@drazil100
Copy link
Contributor

AHA. Figured it out. The group that lets me run vcgencmd without root is "video". Still would be best if temps could be obtained by something that isn't permission locked but now I know what group I need to be in.

@aristocratos
Copy link
Owner

Fixed color range in v1.0.12

@drazil100
Copy link
Contributor

Color range works! Thanks!

@RedBearAK
Copy link
Contributor Author

Fixed color range in v1.0.12

@aristocratos
Nice work.
Want me to close the thread since the main issue seems to be solved?

AHA. Figured it out. The group that lets me run vcgencmd without root is "video". Still would be best if temps could be obtained by something that isn't permission locked but now I know what group I need to be in.

That totally figures since what vcgencmd is actually reporting is the GPU temp, isn't it?

@drazil100
Copy link
Contributor

I have no clue actually.

@aristocratos
Copy link
Owner

Wouldn't it be the temperate for the whole SoC that's reported if it's just 1 value?

I know Pine64 reports multiple SoC values, but they are named CPU and GPU so pretty telling what's what.

@aristocratos
Copy link
Owner

Want me to close the thread since the main issue seems to be solved?

Yeah, let's close it for now. And just reopen if new related bugs surface.

@drazil100
Copy link
Contributor

I know that vcgencmd is how I was told to check temperatures on the pi

@aristocratos
Copy link
Owner

I would guess that vcgencmd measure_temp is just converting the value from /sys/class/thermal/thermal_zone0/temp.

@RedBearAK
Copy link
Contributor Author

Hey, I've been noticing on a couple of machines that bpytop seems to have some issues updating reliably at times. Almost as if it's getting "stuck" from time to time, especially when the CPU is very busy, but sometimes even when it isn't. For instance, here is bashtop and bpytop side by side, both set to update every 2000ms and both have been running since I started stress-ng, but as you can see the graphs are different.

Screen Shot 2020-08-11 at 11 47 05 AM

@aristocratos
Copy link
Owner

The graphs on bpytop have double the horizontal resolution that the default on bashtop has. (Two values for each character)
If you enable "hires graphs" in bashtop they should look the same, but bashtops cpu consumption increases to almost double with that option on.

@drazil100
Copy link
Contributor

I would guess that vcgencmd measure_temp is just converting the value from /sys/class/thermal/thermal_zone0/temp.

Out of curiosity is there a reason you can't use that?

@RedBearAK that should probably be its own issue since its not strictly related to the pi and is definitely not about temperatures.

@aristocratos
Copy link
Owner

Out of curiosity is there a reason you can't use that?

Would have to know for sure that it is a raspberry pi, otherwise that value could be anything. It's likely that that is the value psutil picks up as "cpu_thermal".

@RedBearAK
Copy link
Contributor Author

The script I copied from a forum somewhere uses both vcgencmd and /sys/class/thermal/thermal_zone0/temp and states that it measures both GPU and CPU. It is certainly an SoC, but the cores still separately report their own temps.

#!/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)

while true
  do
clear
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "CPU => $((cpu/1000))'C"
sleep 2
done

The output is often the same but also often shows a difference of 1-2 degrees.

Tue 11 Aug 2020 11:58:06 AM AKDT @ twisteros
-------------------------------------------
GPU => temp=31.0'C
CPU => 32'C

@aristocratos
Copy link
Owner

Huh, could you run python3 -c "import psutil; print(psutil.sensors_temperatures())" and cat /sys/class/thermal/thermal_zone0/temp a couple of times just to compare if they are the same.

@RedBearAK
Copy link
Contributor Author

The graphs on bpytop have double the horizontal resolution that the default on bashtop has. (Two values for each character)
If you enable "hires graphs" in bashtop they should look the same, but bashtops cpu consumption increases to almost double with that option on.

O-I-C

Ah, so that is what "hires graphs" is supposed to do. I never quite figured that out through casual use. Makes sense.

@aristocratos
Copy link
Owner

Could rewrite it so if vcgencmd is detected in the system (which should only be on raspberry pi's right?), then it reads from sys/class/thermal/thermal_zone0/temp.

@aristocratos
Copy link
Owner

Since now it's possibly reporting gpu temp as cpu...

Gonna take a look at it tomorrow, need some sleep before work :)

@drazil100
Copy link
Contributor

My friend says you can find it in "/sys/class/thermal/thermal_zone0/type"

Just checked mine and it says "cpu-thermal"

@RedBearAK
Copy link
Contributor Author

@aristocratos
Here is the output of a modified (and fixed) script run several times:

Tue 11 Aug 2020 12:14:19 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 34'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=34.076, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:21 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=34.0'C
CPU => 34'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=34.076, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:24 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 34'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=32.615, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:27 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 34'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=33.102, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:30 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 34'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=34.076, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:32 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 34'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=34.076, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:35 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 33'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=34.076, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:37 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=34.0'C
CPU => 33'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=34.563, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:40 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 32'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=32.615, high=None, critical=None)]}
Tue 11 Aug 2020 12:14:42 PM AKDT @ twisteros
-------------------------------------------
GPU => temp=33.0'C
CPU => 34'C
UNKNOWN => {'cpu_thermal': [shwtemp(label='', current=34.076, high=None, critical=None)]}

Here is the modified (and fixed) script:

#!/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+
# -------------------------------------------------------

clear

#cpu=$(</sys/class/thermal/thermal_zone0/temp)
#unknown=$(python3 -c 'import psutil; print(psutil.sensors_temperatures())')

while true
  do
#       clear
        cpu=$(</sys/class/thermal/thermal_zone0/temp)
        unknown=$(python3 -c 'import psutil; print(psutil.sensors_temperatures())')
        echo "$(date) @ $(hostname)"
        echo "-------------------------------------------"
        echo "GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
        echo "CPU => $((cpu/1000))'C"
        echo "UNKNOWN => $unknown"
        sleep 2
done

@RedBearAK
Copy link
Contributor Author

So that was weird. As you can see in the screenshots from earlier, both bashtop and bpytop were only showing 3 cores. Rebooted and it's back to normal. Very strange.

Screen Shot 2020-08-11 at 2 03 46 PM

@aristocratos
Copy link
Owner

Added collection through psutil if "cpu_thermal" is available, will fall back to vcgencmd measure_temp if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants