Stress Testing the Raspberry Pi

1,493

13

3

Introduction: Stress Testing the Raspberry Pi

About: By day I am an electronic engineer for a certification and approvals company, by night I am an avid technology hobbyist and DIY'er. I enjoy learning how things work, and sharing my learning experiences with ...

When the Raspberry Pi first got released I was swept up in the hype of buying one, but in the end I spent more time with the Arduino as they are more suited to electronics projects.

I have two Original Raspberry Pi's in the shed, and I thought it was about time I did something with them. So in this instructable I will show you how to "stress" test your Pi's CPU to help you determine how much cooling you need and how much you might be able to overclock it.

This instructable uses Stressberry, If you haven't used it before check it out in the python package index.

Step 1: Setup Your Pi

You will need:

  • Raspberry Pi
  • 8GB SD card
  • 5V, 1A power supply with micro USB
  • A HDMI monitor (or one with S-video/composite)
  • USB Keyboard & Mouse
  • Internet connection (either wired or USB WiFi adapter)

For this instructable I had already made a raspberry Pi laptop (pictured above). Unfortunately I didn't take enough photographs of this one so I couldn't write an instructable.

By reading this instructable I assume you already know how to flash your SD card and setup your Pi. In my case I formatted a fresh SD card using "SD card formatter", then I downloaded the latest raspbian stretch img file and flashed it to an SD card with win32diskimager. You will then need to plug in a mouse, keyboard, monitor and power supply into the Raspberry Pi with you newly flashed SD card. I won't detail the specifics because this is already well documented.

The following instructable will only work easily with Raspbian Stretch. Although you can probably use Wheezy or Jessie alot of the repositories are outdated and you will probably struggle to download and compile everything from source. I initially tried with Wheezy and struggled mainly because the software relies on Python 3.5 which is not installed by default in Wheezy.

Step 2: Download and Install Dependant Software

We are going to use a program called "stressberry". It loads the CPU to 100% and logs the temperature (I am guessing this is the Junction temperature not the surface temperature). If you are running the GUI click on the terminal to open a new terminal window, else login to your Pi using the command line and type the following.

Firstly do an update:

sudo apt-get update

This will update everything so we are using the most up to date sources. Next we will install all the pre-requisites for using stressberry.

Install Atlas

sudo apt-get install Libatlas-base-dev

Install cairo

Sudo pip3 install cairocffi

Install PyQt5

sudo apt-get install python3-pyqt5

Finally install stressberry using the following two install commands

sudo apt install stress

then

sudo -H pip3 install -U stressberry

During installation answer yes "Y" to any prompts when installing and assuming all that went well we can go to the next step which is modifying the matplotlib backend. In the terminal type:

sudo python 3

This will bring up the python terminal inside the LXDE terminal. You will be able to tell because the start of each line is prefixed with >>. Type the following followed by enter:

>>>import matplotlib

then

>>>matplotlib.matplotlib_fname()

This will give you the filepath where your matplotlib RC file is stored which we will now need to edit. For example this was mine:

/usr/local/lib/python3.5/dist-packages/matplotlib/mpl-data/matplotlibrc

So you need to prefix this line with "sudo nano" to open the nano terminal text editor to edit the file:

sudo nano /usr/local/lib/python3.5/dist-packages/matplotlib/mpl-data/matplotlibrc

Now we are editing the text file we need to look for where the backend is specified. For this, nano has a useful built in search command called "where is". To use it simply hold Ctrl + W and type in "backend" and it will search the document for you, instead of having to scroll through it. Now edit the line:

backend: gtk3agg

to

backend: qt5agg

Then when you are done hold Ctrl + X to save. When prompted answer Y or yes to save any changes and overwrite the file.

Step 3: Running Stressberry

Finally you have done all the pre-requisites you can finally run the program without any problems. Simply type the following command to run stressberry:

sudo stressberry-run out.dat

This runs the program for you and records the temperature in a file in your home directory called 'out.dat'. The program will run the CPU as low as possible to allow it to "cooldown", then idle it for a short while before stressing it with a maximum load for five minutes, then stops and records the cooldown. The data is stored in your home directory with the name "out.dat" but you could call this whatever you like. Stressberry will also produce a nice looking graph too if you run the following command after the stress test is complete:

sudo stressberry-plot out.dat

Try using different heat sinks and enclosures, overclocking settings etc to see how this changes thermal behaviour. To plot multiple lines on the graph all you do is add them in front of the command:

sudo stressberry-plot out1.dat out2.dat out3.dat

You can also save the graph directly to a .png file by using the following command:

sudo stressberry-plot out.dat -o out.png

This will save a file called "out.png" to your home directory. If you have any error messages during the installation of the previous step have a look at the troubleshooting step.

Step 4: Some Example Plots

Here are some interesting plots I've created using Stressberry. My Pi is a basic Pi1, and I've added some small aluminium heat sinks to the IC's, and then I've replotted again using a small 3cm fan added (note, put 5cm but this is actually a 30mm fan!). Then I set the overclock to "Turbo" using raspi-config, removed the fan, and put it inside an acrylic enclosure. The three plots are on the same graph above

Step 5: Troubleshooting

If your reading this step you may have had a few errors whilst installing or running stressberry. Here I've documented all the problems I encountered whilst trying to get this to work, and hopefully should help you overcome anything similar.

Error message 1.

libf77blas.so.3: Cannot open shared object file: No such file or directory

What is the issue?

The pacakage depends on Atlas which is not installed by default

Solution

Install Atlas with the following:

sudo apt-get install Libatlas-base-dev

Error message 2

ImportError: cairo backend requires that cairocffi or pycairo is installed

What is the issue?

Cairo has not been installed by default

Solution

install cairo with the following:

sudo pip3 install cairocffi

Error message 3

TypeError: Couldn’t find foreign struct converter for ‘cairo.Context’

What is the issue?

The problem is using the GTK3Agg backend, this can either be changed in the matplotlibrc file.

Solution

when you run "stressberry-plot out.dat" instead run:

sudo MPLBACKEND=Agg stressberry-plot out.dat

This will force stressberry to run the specified backend rather than the one stored in the RC file.

Step 6: Finish!

This is just one of many methods you can use to benchmark your Pi. Another program you can consider using is "sysbench" which should work out of the box without issues.

I hope you enjoyed this instructable. Let me know if you enjoyed this or made it yourself. As always I am happy to receive constructive feedback and comments (be nice, no trolls please).

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Water Contest

      Water Contest
    • Metalworking Contest

      Metalworking Contest

    3 Discussions

    You inspired me to start researching up different testing for my Rpi3 bramble.. 3 hours deep in the docs already haha. Thanks for posting this!

    2 replies

    Cool! I'm happy I've.managed to inspire you. Will you write an instructable for your project? Watch this space, I've got similar Rpi powered projects coming soon.

    For sure!! I was reading up on Parallel computing last night and wanted to build something that compares the performance of the cluster as I add / remove nodes to it. Consider yourself followed! :)