Julia language for Raspberry Pi

Julia is a free and open-source general purpose programming language made specifically for scientific computing. It combines the ease of writing in high-level languages like Python and Ruby with the technical power of MATLAB and Mathematica and the speed of C. Julia is ideal for university-level scientific programming and it’s used in research.

Julia language logo

Some time ago Viral Shah, one of the language’s co-creators, got in touch with us at the Raspberry Pi Foundation to say his team was working on a port of Julia to the ARM platform, specifically for the Raspberry Pi. Since then, they’ve done sterling work to add support for ARM. We’re happy to announce that we’ve now added Julia to the Raspbian repository, and that all Raspberry Pi models are supported!

Not only did the Julia team port the language itself to the Pi, but they also added support for GPIO, the Sense HAT and Minecraft. What I find really interesting is that when they came to visit and show us a demo, they took a completely different approach to the Sense HAT than I’d seen before: Simon, one of the Julia developers, started by loading the Julia logo into a matrix within the Jupyter notebook and then displayed it on the Sense HAT LED matrix. He then did some matrix transformations and the Sense HAT showed the effect of these manipulations.

Viral says:

The combination of Julia’s performance and Pi’s hardware unlocks new possibilities. Julia on the Pi will attract new communities and drive applications in universities, research labs and compute modules. Instead of shipping the data elsewhere for advanced analytics, it can simply be processed on the Pi itself in Julia.

Our port to ARM took a while, since we started at a time when LLVM on ARM was not fully mature. We had a bunch of people contributing to it – chipping away for a long time. Yichao did a bunch of the hard work, since he was using it for his experiments. The folks at the Berkeley Race car project also put Julia and JUMP on their self-driving cars, giving a pretty compelling application. We think we will see many more applications.

I organised an Intro to Julia session for the Cambridge Python user group earlier this week, and rather than everyone having to install Julia, Jupyter and all the additional modules on their own laptops, we just set up a room full of Raspberry Pis and prepared an SD card image. This was much easier and also meant we could use the Sense HAT to display output.

Simon kindly led the session, and before long we were using Julia to generate the Mandelbrot fractal and display it on the Sense HAT:

Naturally, one of the attendees, Rich Wareham, progressed to the Julia set – find his code here: gist.github.com/bennuttall/…

Last year at JuliaCon, there were two talks about Julia on the Pi. You can watch them on YouTube:

Install Julia on your Raspberry Pi with:

sudo apt update
sudo apt install julia

You can install the Jupyter notebook for Julia with:

sudo apt install julia libzmq3-dev python3-zmq
sudo pip3 install jupyter
julia -e 'Pkg.add("IJulia");'

And you can easily install extra packages from the Julia console:

Pkg.add("SenseHat")

The Julia team have also created a resources website for getting started with Julia on the Pi: juliaberry.github.io

Julia team visiting Pi Towers

There never was a story of more joy / Than this of Julia and her Raspberry Pi

Many thanks to Viral Shah, Yichao Yu, Tim Besard, Valentin Churavy, Jameson Nash, Tony Kelman, Avik Sengupta, Simon Byrne and Elliott Saba for their work on the port. We’re all really excited to see what people do with Julia on Raspberry Pi, and we look forward to welcoming Julia programmers to the Raspberry Pi community.

28 comments

Avatar

Hmmmm interesting, particularly the built-in parallel processing functions which seems more robust than python’s built-in implementation. However, though I realize it may not be needed as much in scientific computing, I did not see any option for general socket programming beyond websockets. Though at least there is a python wrapper. May have to investigate a little more to see if it warrants me learning another “general purpose” programming language.

Avatar

Lets not confuse this – C is slow. Only when it is compiled into machine code can one appreciate the power of the CPU running the program. But even then, C/C++ programs can be very bloated.

Except for this one bit, I can see this being a promising tool to some, if not many.

Avatar

C slow !!! compared to what? Well written C is about as fast as it gets, beaten only by hand-tuned (non portable) assembler.
As to bloat, there was never a language yet that you couldn’t bloat programs in if you really tried.

Avatar

C is slow? Where do you come from, Mars ?

Avatar

You must be thinking of Java or C#. C and C++ are ALWAYS compiled to machine code. There is no pseudo-code for C/C++.

Avatar

Hmm… interesting. Too bad I have no means of comparing it to Haskell. Does anyone here have experience with Raspberry Pi and Haskell?

Avatar

This is a great development which considerably expands the range and versatility of the Raspberry Pi.

Congrats to all involved:)

Richard

Avatar

Is there a link to the image, that is open for public download?

Avatar

What do you mean by ‘the image’?

Avatar

I think he meant this image “rather than everyone having to install Julia, Jupyter and all the additional modules on their own laptops, we just set up a room full of Raspberry Pis and prepared an SD card image”…

Avatar

Oh I see – no, there’s not much point making the image available. It’s just a Raspbian image with Julia installed.

Avatar

The purpose of the image was mainly to reduce the downtime of waiting for the packages we were using to download and install.

For instructions on using Julia and Jupyter on the Pi, see https://juliaberry.github.io/

Avatar

Julia is intended to be more a better faster MATLAB than it is a general purpose programming language. Proper MATLAB isn’t available for the Pi and the open source alternatives Octave and Scilab are too slow. Thus, Julia being available and working well on the Pi could serve as an important tool for teaching numerical computation without resorting to Fortran, C or C++.

While Fortran, C and C++ are used for most high performance computing (and in the case of C and C++ many other things), there is also real work being done with MATLAB-like programming languages. Julia is new, but being available on the Pi may make it more popular.

Avatar

This is good to see – I’ve been meaning to play around with julia for a couple of years..

r.e. your comment on julia with the sense hat. I did suggest switching to using a numpy 3D array to represent the LEDs (see my pull request from 2015!) which would seem more intuitive and significantly faster (than python not julia), oh well.

Avatar

Definitely a good idea – we just haven’t got around to working it in yet.

Avatar

I got around to playing with something like that a while back. Didn’t make a PR out of it (except for the joystick stuff) as it departs quite significantly from the existing library, but it’s here in case anyone wants a play: https://github.com/waveform80/pisense

Avatar

Didn’t really know Julia existed until I stumbled upon some people using it to solve Project Euler problems, and thought to myself that it looks…interesting (and that’s usually enough to get me going). Thanks for making it more readily available!

Oh, and take a look at Project Euler if you’re in for some programming challenges. Cheers

Avatar

+1 to that! Project Euler is great – and a good practical way to learn a new language.

https://projecteuler.net/

Avatar

Can Julia in Jupyter do symbolic algebra and calculus as e.g. the Octave package octave-symbolic, or Maxima?

Avatar

I got errors when installing. I have Raspberry Pi 2 with most dist-updated Raspbian.

$ sudo pip3 install jupyter

And then when I try to do next I get more errors:

$ julia -e ‘Pkg.add(“IJulia”);’

Did someone get it to work?

Avatar

There’s an issue with apt’s version of pip. You probably want to reinstall it and get it to upgrade to the latest version:

sudo apt purge python3-pip
sudo apt install python3-pip
sudo pip3 install pip –upgrade

Then try installing jupyter again and continue from there.

Avatar

I succeeded, but in http://localhost:8888/tree# I don’t have a notebook.

I had to do some extra things to install:
$ julia
julia> Pkg.update()
julia> Pkg.add(“IJulia”)
julia> Pkg.build(“IJulia”)
julia> using IJulia
julia> notebook()

Then the browser starts with Jupyter.

I followed these instructions, but I don’t know what to set PATH to in cd(“PATH”):
https://www.math.uci.edu/~lzepeda/documents/ijulia_installation.pdf

Avatar

I found how to create a notebook using New, Julia 0.5.1 in the top right corner of http://localhost:8888/tree

Now I have run all examples on Try Jupyter https://try.jupyter.org/ , Welcome Julia – Intro to Gadfly, see example on Raspberry Pi 2:
http://i.cubeupload.com/DgYKhN.png

When it does most computations it looks like Julia from Raspbian apt is using only one core on htop. I uses rather lot of RAM the first time a command is run. I run the commands in the LXTerminal first.

Avatar

The first-time run slowness is caused by the JIT.

Avatar

Thank you for your hints about getting past the failure to install jupyter. Unfortunately, after all the pip upgrade etc. I still got all the red error messages, just as before. This is a fully updated Pi3 (as far as I can tell) with very few added programs, such as the Okular .pdf reader. That doesn’t seem to be working properly any more. Have you any more advice for failed jupyters?

Avatar

Problem over, so no need to reply thanks. Being rather inept, I failed to notice that the above “sudo pip3 install pip -upgrade” was a misprint for –upgrade.After running that, sudo pip3 install jupyter and thence to PKg.build(“Ijulia”) within Julia, did the trick. I include that for others who, like me, don’t know what they’re doing.

Avatar

Sorry- more clarification required for others like me- the screen printing is distorting the input: what you need is sudo pip3 install pip – – upgrade. There is no space between – and -, but the screen lumps the 2 minuses together.

Avatar

I have Raspian Jessie running in a virtual Raspberry Pi. I have only been able to install Julia 0.3 but the extra packages, SenseHat etc, require Julia 0.4 or 0.5 so Pkg.add fails. I haven’t even found an appropriate forum in which to post this question!
Is Julia 0.5 available for the Pi somewhere?

Leave a Comment

Comments are closed