Building Julia on a Raspberry Pi

I’m trying to build Julia from source (v1.10.1) on a Raspberry Pi (4 Model B, with OS 64-bit, Lite, Bookworm on it). It’s been a struggle… I’ve installed zram, and that does help with the process, but it does occasionally fail.

Does anyone have a foolproof way of building Julia on an RPI?

(The reason I’m not using one of the pre-built binaries is that I have repeatedly suffered form segfaults when using the ApriTags library, and using a locally built Julia completely solves that problem).

1 Like

I believe you could cross-compile for the Pi, i.e. armv7, and I’m not sure why it should not work. It gets you “pre-built binaries”, i.e. those you have made that way I suppose. I didn’t expect you could compile on the Pi at all, too little memory, and while zram worked, amazing, it’s interesting it’s not deterministic. Likely meaning it gives you effectively more RAM, but just barely enough. If you do everything the same each time, it should be deterministic, you would think, except with multi-core that’s no longer realistic. You may do things in slightly different order because of it or for other reasons, and I suppose that could affect zram.

Compression, e.g. zram, seems could and must be completely deterministic, at least the output, and everything relating to it, assuming the rest of the system is, so maybe if you boot to single-core operation (assuming you can select that in Linux), and do everything by a script to compile, then maybe it solves your problem…

Maybe increasing the swap does help (possibly instead of zram). The build process will be quite slow, but I guess you need to build julia only once.

Did you also consider compiling the library within Yggdrasil? It might allow you to use the pre-build binaries.

Maybe increasing the swap does help (possibly instead of zram). The build process will be quite slow, but I guess you need to build julia only once.

This might be better than using zram… I should try that!

Did you also consider compiling the library within Yggdrasil? It might allow you to use the pre-build binaries.

I am already using Readme · AprilTags_jll.jl

swap is really slow (especially on a pi where you don’t have nvme). I would recommend zram and swap to reduce the swap amount

In hopes of helping anyone attempting a similar thing, I can report that, unsurprisingly, I found it impossible to build Julia on an RPI with only 2 GB RAM, even with the following steps:

  1. increase swap from 100 MB to 1 GB
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=1024/g' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
  1. use zram to further increase swap by 12 GB (3 times the 4 GB needed to build Julia)
git clone https://github.com/foundObjects/zram-swap
cd zram-swap/
sudo ./install.sh
sudo sed -i 's/#_zram_fixedsize="2G"/_zram_fixedsize="12G"/g' /etc/default/zram-swap
sudo systemctl restart zram-swap.service