Try out the Raspberry Pi Model 3 B Plus! - Review

Table of contents

RoadTest: Try out the Raspberry Pi Model 3 B Plus!

Author: vish

Creation date:

Evaluation Type: Development Boards & Tools

Did you receive all parts the manufacturer stated would be included in the package?: True

What other parts do you consider comparable to this product?:

What were the biggest problems encountered?:

Detailed Review:

Raspberry Pi has evolved from being an educational platform for students to much more including a computational platform for research over the years. With this evolution, it is worth exploring the capabilities of Raspberry Pi as a tool for numerical computation. On this context, I would like to introduce a young language called Julia. Julia is a high-level, high-performance dynamic programming language for numerical computing. With its inbuilt capability for distributed parallel execution, Julia can utilize raspberry pi's multi-core hardware and leverage it's low cost to make Pi a cost-effective computational platform for both hobbyists and researchers a like. In this roadtest, I would like to explore this very possibility. I would like to start with the steps for installation of julia in Raspberry Pi3 B+ followed by a performance comparison of julia in both Pi3 B and Pi3 B+.

 

Installing Julia

Installing Julia is very easy if we go with pre-built binaries. Official julia website (https://julialang.org/downloads/ ) provides julia ARM builds for both 32bit and 64bit ARM chips. With my Pi3 B+, I'm using the latest version of Raspbian OS which is 32 bit. The corresponding build for Raspbian 32 bit is available under "Generic Linux Binaries for ARM". Download the 32bit (armv7-a hard float) variant. In this roadtest, I will be using version "0.6.3" which is the latest stable version available (as on writing this review). After downloading, just unzip the tarball to a convenient location (I unzipped it into "/opt/julia").

 

wget https://julialang-s3.julialang.org/bin/linux/armv7l/0.6/julia-0.6.3-linux-armv7l.tar.gz 
tar -xvf julia-0.6.3-linux-armv7l.tar.gz

 

The tarball will unzip to a folder with name "julia-<commit_id>".  I will be referring to the unzipped folder as "julia" from now on.

The julia binary can be found in "julia/bin" directory. You can start julia by executing

$/opt/julia/bin/julia

 

This should start the julia REPL as shown below:

 

To quickly check the version information and other platform specific details in julia, execute the following in julia REPL.

julia> versioninfo()

 

Julia Basics

Julia language is very much like Python/Matlab; with one major difference -- It's fast also. Below picture shows how julia compares against various other main stream languages and you can clearly see Julia is one of it kind for blending in the simplicity of Python but reaching the speed of C.

Image Courtesy: https://julialang.org/

 

Even if you don't have any prior experience with any other programming languages, it is easy to learn the language. An excellent introductory material to Julia is available at https://en.wikibooks.org/wiki/Introducing_Julia.

 

Performance comparison between Pi3 B and Pi3B+

A comparison of various languages against julia in some computational tasks are given in https://julialang.org/benchmarks/. It shows out the power of julia language; in most of the cases, julia is able to beat even the C implementations. For this roadtest, I tried to compare the performance of Pi3 B, Pi3 B+ and a HP Mini 110 netbook (Atom Dual Core/1GB RAM/Ubuntu 18.04 mini edition) using the same tests. Even though the official test scripts are available at https://github.com/JuliaLang/Microbenchmarks, those are now being modified for the upcoming 0.7.0 release and will not work with 0.6.3. The scripts are modified to run on 0.6.3 (attached below). Each test is repeated 100 times and the boxplot with mean, max and minimum time taken is reported. Let's have a look at some of those results.

1. Recursive fibonacci

2. Integer parsing

3. Calculation of mandelbrot set

4. Sorting of random numbers using quicksort

5. Summation of a power series

6. Statistics on a random matrix

7. Multiplication of random matrices

8. Printing to a file descriptor

When I included HP Mini 110 (2010 make) for the test, I thought the it may emerge as the winner, but to my surprise, in most of the tests, Pi emerged better than Atom processor with 1GB RAM :O. This was surprising to me; clearly shows how much raspberry pi has come as a computing platform.

 

Remote coding with IJulia

One of the main things with raspberry pi and me is that i usually use it headless. Whether it's my home automation server, or my media server, my Pi usually runs without display and I ssh into it while coding/setting stuff up. It is great, if you are a hobbyist. You are not afraid of green on black terminals and cryptic commands. However, this roadtest presents Pi as a computational device, I think we need a neat way to access the system. If you are familiar with python for computational projects, you will most probably be familiar with python notebooks. Jupyter notebooks provide a nice browser based coding environment to run python. Julia is also now supported by Jupyter using IJulia kernel and in this part, I will discuss how to set up a remote IJulia server hosted in Pi.

Installing Jupyter

Installing jupyter in Pi is super easy. Just run the following commands and you can install jupyter to your pi.

 

$ sudo apt-get install -y python-dev
$ sudo pip install --upgrade pip
$ sudo pip install jupyter

 

This will install jupyter in your Pi. If you want to try out Jupyter, jump to terminal an execute

 

$ jupyter notebook

 

This will start a jupyter server from the directory you execute this command from. If you have a GUI/Display for you raspberry pi, this should also open your the web browser. I should also list "Python" as one of the available kernels.

However, I run Pi without a display and want to access julia in pi over the network. So we have to configure Jupyter to serve over network. For that, first we have to create a jupyter configuration file by executing:

 

$ jupyter notebook --generate-config

 

This should create a configuration file at "/home/pi/.jupyter/jupyter_notebook_config.py". We have to edit this file to make jupyter available over the network.

Open that file in your favorite text editor and modify the following line as below.

 

c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False

 

It is advised to setup the security options also for the server to avoid any malicious access. I will not cover it in this post, interested users can refer Running a notebook server — Jupyter Notebook 5.5.0 documentation  for setting up security.

Now save the file, exit text editor and start jupyter again with the command

 

$ jupyter notebook

 

This time, it will printout some address and an authentication token for accessing jupyter notebook over the network. If you have note changed the hostname of you Pi, you will be able to access it as "http://raspberrypi.local:8888" followed by the access token URL printed in terminal. You can also access the Pi by replacing the hostname by the IP address of Pi. Once you are able to access Jupyter notebook over the network, it is time to install "IJulia" kernel.

Start julia in Pi from your terminal and execute:

 

julia> Pkg.add( "IJulia" )

 

This will install the IJulia kernel and other dependencies.

Now, for the first time, it is better to start IJulia from inside julia itself, otherwise it may complain about some timeout errors. So in your julia REPL,

 

julia> using IJulia
julia> notebook()

 

This will start a notebook server at the background, but may not print the URL for access.  To get the URL, you can open another terminal in Pi and execute

 

$ jupyter notebook list

This should print out all the running sessions on Pi. Connect using the access token provided and you can see that now both Python and Julia kernels are available.

From second time you can directly start jupyter notebooks from your terminal and julia kernel will be available inside the notebook by default.

 

 

Physical computing with Julia

There is not fun if you can't access the hardware GPIO features of Pi with the language. Julia also support these GPIO access and many more via specialized packages. I list a few of the below:

More details about these packages can be found at https://juliaberry.github.io/

 

This winds up my roadtest review and I'm extremely happy that raspberry pi has been evolving from a just hobby device to some serious computational device. I strongly believe that both Julia and Raspberry Pi community will like each other for the features they have to offer.

 

Happy Coding,

vish

Anonymous