From a4a3d01c36154b8a3f4436bfa9bc52578eac2e4f Mon Sep 17 00:00:00 2001 From: SatoshiTerasaki Date: Wed, 5 Aug 2020 16:23:23 +0900 Subject: [PATCH 1/5] jetson --- jetson/balenasample/Dockerfile | 2 +- jetson/multiarch/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jetson/balenasample/Dockerfile b/jetson/balenasample/Dockerfile index d3c5a64..df1d7bb 100644 --- a/jetson/balenasample/Dockerfile +++ b/jetson/balenasample/Dockerfile @@ -3,7 +3,7 @@ FROM balenalib/jetson-nano:buster-20200518 -ARG VERSION="v1.4.2" +ARG VERSION="v1.5.0" MAINTAINER SATOSHI TERASAKI diff --git a/jetson/multiarch/Dockerfile b/jetson/multiarch/Dockerfile index d779573..37a899d 100644 --- a/jetson/multiarch/Dockerfile +++ b/jetson/multiarch/Dockerfile @@ -3,7 +3,7 @@ FROM multiarch/ubuntu-core:arm64-xenial -ARG VERSION="v1.4.2" +ARG VERSION="v1.5.0" MAINTAINER SATOSHI TERASAKI From 907a245d7413cca86197acbd2f10972ff17956a0 Mon Sep 17 00:00:00 2001 From: SatoshiTerasaki Date: Wed, 5 Aug 2020 16:24:07 +0900 Subject: [PATCH 2/5] rpi3 --- rpi3/Dockerfile-v1.5.0 | 46 +++++++++++++++++++++++++++++++++++++++++ rpi3/docker-compose.yml | 4 ++++ 2 files changed, 50 insertions(+) create mode 100644 rpi3/Dockerfile-v1.5.0 diff --git a/rpi3/Dockerfile-v1.5.0 b/rpi3/Dockerfile-v1.5.0 new file mode 100644 index 0000000..83ea396 --- /dev/null +++ b/rpi3/Dockerfile-v1.5.0 @@ -0,0 +1,46 @@ +# Build Julia binary for arm32-bit armv7-a devices e.g. RaspberryPi 2 or 3 + +FROM balenalib/raspberrypi3:buster-20200502 + +MAINTAINER SATOSHI TERASAKI + +# insta dependencies +RUN apt-get update && \ + apt-get install -y build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config \ + git && \ + apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* + +# build julia from source +ARG JL_VERSION="v1.5.0" +ARG WDIR=/home/pi/work +ARG JL_BUILD_DIR=$WDIR/build +WORKDIR $WDIR +RUN echo "\ +CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0\n\ +prefix=/home/pi/julia-$JL_VERSION\n\ +USE_BINARYBUILDER=0\n\ +LDFLAGS=-latomic\n\ +CFLAGS += "-mfpu=neon-vfpv4"\n\ +CXXFLAGS += "-mfpu=neon-vfpv4"\n\ +MARCH="armv7-a"\n\ +JULIA_CPU_TARGET=\"armv7-a\;armv7-a,neon\;armv7-a,neon,vfp4\"\n\ +JULIA_CPU_THREADS=4\n\ +" > Make.user && \ + cat Make.user && \ + git clone --depth=1 -b $JL_VERSION https://github.com/JuliaLang/julia.git $JL_BUILD_DIR &&\ + cp Make.user $JL_BUILD_DIR && \ + # add patches + sed -i -e '69s/devnull/stdout/' ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + sed -i -e '63,65 s/^/#/' ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + sed -i -e '190 s/^/#/' ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + cat ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + cd $JL_BUILD_DIR && make -j 16 && make install && \ + echo "clean up $JL_BUILD_DIR" && \ + rm -r $JL_BUILD_DIR && \ + echo "Done" + +# add path of Julia +ENV PATH=/home/pi/julia-$JL_VERSION/bin:$PATH +# runtime test +RUN julia -e "using InteractiveUtils; versioninfo()" +CMD ["julia"] diff --git a/rpi3/docker-compose.yml b/rpi3/docker-compose.yml index 62fd2ba..9e09830 100644 --- a/rpi3/docker-compose.yml +++ b/rpi3/docker-compose.yml @@ -28,3 +28,7 @@ services: build: context: ./ dockerfile: Dockerfile-v1.4.2 + v1.5.0: + build: + context: ./ + dockerfile: Dockerfile-v1.5.0 From f595df5183c25846381ff0468b01b83c7bcf30e9 Mon Sep 17 00:00:00 2001 From: SatoshiTerasaki Date: Wed, 5 Aug 2020 16:25:01 +0900 Subject: [PATCH 3/5] rpizero --- rpizero/Dockerfile-v1.5.0 | 51 ++++++++++++++++++++++++++++++++++++++ rpizero/docker-compose.yml | 4 +++ 2 files changed, 55 insertions(+) create mode 100644 rpizero/Dockerfile-v1.5.0 diff --git a/rpizero/Dockerfile-v1.5.0 b/rpizero/Dockerfile-v1.5.0 new file mode 100644 index 0000000..0d4bd26 --- /dev/null +++ b/rpizero/Dockerfile-v1.5.0 @@ -0,0 +1,51 @@ +# Build Julia binary for arm32-bit devices e.g. RaspberryPi Zero(W/WH) + +FROM balenalib/raspberry-pi:buster-20200518 + +MAINTAINER SATOSHI TERASAKI + +# install dependencies +RUN apt-get update && \ + apt-get install -y build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config \ + libopenblas-dev \ + liblapack-dev \ + libgmp3-dev \ + libmpfr-dev \ + git && \ + apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* + +# build julia from source +ARG JL_VERSION="v1.5.0" +ARG WDIR=/home/pi/work +ARG JL_BUILD_DIR=$WDIR/build +WORKDIR $WDIR +RUN echo "\ +prefix=/home/pi/julia-$JL_VERSION\n\ +JULIA_CPU_TARGET=arm1176jzf-s\n\ +LDFLAGS=-latomic\n\ +USE_BINARYBUILDER=0\n\ +JULIA_PRECOMPILE=0\n\ +override USE_SYSTEM_BLAS=1\n\ +override USE_SYSTEM_LAPACK=1\n\ +override USE_SYSTEM_LIBM=1\n\ +override USE_SYSTEM_GMP=1\n\ +override USE_SYSTEM_MPFR=1\n\ +" > Make.user && \ + cat Make.user && \ + git clone --depth=1 -b $JL_VERSION https://github.com/JuliaLang/julia.git $JL_BUILD_DIR &&\ + cp Make.user $JL_BUILD_DIR && \ + # add patches + sed -i -e '69s/devnull/stdout/' ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + sed -i -e '63,65 s/^/#/' ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + sed -i -e '190 s/^/#/' ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + cat ${JL_BUILD_DIR}/contrib/generate_precompile.jl && \ + cd $JL_BUILD_DIR && make -j 16 OPENBLAS_USE_THREAD=0 && make install && \ + rm -r $JL_BUILD_DIR && \ + echo "Done" + +# add path of Julia +ENV PATH=/home/pi/julia-$JL_VERSION/bin:$PATH +# runtime test +RUN julia -e "using InteractiveUtils; versioninfo()" +CMD ["julia"] + diff --git a/rpizero/docker-compose.yml b/rpizero/docker-compose.yml index 18abcdc..963596e 100644 --- a/rpizero/docker-compose.yml +++ b/rpizero/docker-compose.yml @@ -28,3 +28,7 @@ services: build: context: ./ dockerfile: Dockerfile-v1.4.2 + v1.5.0: + build: + context: ./ + dockerfile: Dockerfile-v1.5.0 From 52b0dd54228e017693fc1a75f22219eb0b54329d Mon Sep 17 00:00:00 2001 From: SatoshiTerasaki Date: Wed, 5 Aug 2020 16:25:15 +0900 Subject: [PATCH 4/5] x86-64 --- x86-64/Dockerfile | 2 +- x86-64/Dockerfile-gpu | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x86-64/Dockerfile b/x86-64/Dockerfile index 3e3f9d0..68c348e 100644 --- a/x86-64/Dockerfile +++ b/x86-64/Dockerfile @@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y \ git \ && apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* -ARG JL_VERSION="v1.4.2" +ARG JL_VERSION="v1.5.0" ARG WDIR="/root" ARG JL_BUILD_DIR=$WDIR/build WORKDIR $JL_BUILD_DIR diff --git a/x86-64/Dockerfile-gpu b/x86-64/Dockerfile-gpu index 794827e..ea6682e 100644 --- a/x86-64/Dockerfile-gpu +++ b/x86-64/Dockerfile-gpu @@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y \ git \ && apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* -ARG JL_VERSION="v1.4.2" +ARG JL_VERSION="v1.5.0" ARG WDIR="/root" ARG JL_BUILD_DIR=$WDIR/build WORKDIR $JL_BUILD_DIR From 827b665b43d005bc786ed8c624c2687efd03395b Mon Sep 17 00:00:00 2001 From: Satoshi Terasaki Date: Wed, 5 Aug 2020 23:44:44 +0900 Subject: [PATCH 5/5] update README.md --- README.md | 85 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 55e4a0c..836acd7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # jlcross -![image](https://user-images.githubusercontent.com/16760547/83024377-4356e580-a069-11ea-9ee2-e2d1b8317676.png) +Dockerfiles for arm devices e.g. Raspberry Pi Series + +![image](https://user-images.githubusercontent.com/16760547/89384527-2e699300-d739-11ea-9f2a-316cd631069a.png) + +![image](https://user-images.githubusercontent.com/16760547/89384552-39242800-d739-11ea-8cec-05dd275b859b.png) # About [this repository](https://github.com/terasakisatoshi/jlcross) @@ -30,14 +34,15 @@ # How to use - We will assume your build machine is - - Ubuntu 16.04 equipped with high end Intel CPU. + - Linux machine equipped with high-end CPU - macOS (Catalina) e.g. iMac + - WSL ??? (not tested) ## Read the official documentation/repositories. - - We recommend that you read through/checkout the following links. Once you've read through how to build julia for you device then come back here. - - https://github.com/JuliaLang/julia/tree/master/doc/build - - https://github.com/JuliaCI/julia-buildbot +- We recommend that you read through/checkout the following links. Once you've read through how to build julia for you device then come back here. + - https://github.com/JuliaLang/julia/tree/master/doc/build + - https://github.com/JuliaCI/julia-buildbot ## Prepare environment @@ -59,9 +64,9 @@ To prove Julia can run on arm devices We've uploaded Docker images on [Docker Hu - Install docker image from Docker Hub. ```console -$ docker pull terasakisatoshi/jlcross:rpizero-v1.4.2 -Unable to find image 'terasakisatoshi/jlcross:rpizero-v1.4.2' locally -rpizero-v1.4.2: Pulling from terasakisatoshi/jlcross +$ docker pull terasakisatoshi/jlcross:rpizero-v1.5.0 +Unable to find image 'terasakisatoshi/jlcross:rpizero-v1.5.0' locally +rpizero-v1.5.0: Pulling from terasakisatoshi/jlcross (start to pull image...) ``` @@ -74,34 +79,24 @@ using Pkg Pkg.add("Example") using Example hello("World") -$ sudo docker run --rm -it -v $PWD:/work -w /work terasakisatoshi/jlcross:rpizero julia hello.jl +$ docker run --rm -it -v $PWD:/work -w /work terasakisatoshi/jlcross:rpizero-v1.4.2 julia hello.jl Cloning default registries into `~/.julia` Cloning registry from "https://github.com/JuliaRegistries/General.git" - Resolving package versions... Added registry `General` to `~/.julia/registries/General` - Resolving package versions... - Installed Example ─ v0.5.1 - Updating `~/.julia/environments/v1.1/Project.toml` - [7876af07] + Example v0.5.1 - Updating `~/.julia/environments/v1.1/Manifest.toml` - [7876af07] + Example v0.5.1 - [2a0f44e3] + Base64 - [8ba89e20] + Distributed - [b77e0a4c] + InteractiveUtils - [56ddb016] + Logging - [d6f4376e] + Markdown - [9a3f8284] + Random - [9e88b42a] + Serialization - [6462fe0b] + Sockets - [8dfed614] + Test -Hello, World + Added registry `General` to `~/.julia/registries/General` + Resolving package versions... + Installed Example ─ v0.5.3 + Updating `~/.julia/environments/v1.4/Project.toml` + [7876af07] + Example v0.5.3 + Updating `~/.julia/environments/v1.4/Manifest.toml` + [7876af07] + Example v0.5.3 ``` ## Build Julia on your machine -- If you'd like to build Julia for your Raspberry Pi3, download, for example, `rpi3/Dockerfile-v1.4.2` and run the following command on your terminal to build Docker image which will include Julia binary: +- If you'd like to build Julia for your Raspberry Pi3, download, for example, `rpi3/Dockerfile-v1.5.0` and run the following command on your terminal to build Docker image which will include Julia binary: ```console -$ sudo docker build -t jl4rpi3 -f Dockerfile-v1.4.2 . +$ docker build -t jl4rpi3 -f Dockerfile-v1.5.0 . ``` - Please be patient, it will take long time (within a half day) to build. @@ -111,7 +106,7 @@ $ sudo docker build -t jl4rpi3 -f Dockerfile-v1.4.2 . - Using `docker-compose` will build each version of Julia. Namely: ```console -$ sudo docker-compose build --parallel +$ docker-compose build --parallel ``` @@ -129,7 +124,7 @@ $ sudo docker-compose build --parallel $ cat get_binary.sh # write shell script by yourself like below: #!/bin/bash -JL_VERSION=v1.4.2 +JL_VERSION=v1.5.0 IMAGE_NAME=terasakisatoshi/jlcross:rpizero-${JL_VERSION} CONTAINER_NAME=jltmp_${JL_VERSION} docker run --name ${CONTAINER_NAME} $IMAGE_NAME /bin/bash @@ -137,16 +132,16 @@ docker cp ${CONTAINER_NAME}:/home/pi/julia-${JL_VERSION} . docker rm ${CONTAINER_NAME} $ bash get_binary.sh $ ls -julia-v1.4.2 +julia-v1.5.0 ``` -- Copy `julia-v1.4.2` to your Raspberry Pi zero: +- Copy `julia-v1.5.0` to your Raspberry Pi zero: ```console -$ scp -r julia-v1.4.2 pi@raspberrypi.local:/home/pi +$ scp -r julia-v1.5.0 pi@raspberrypi.local:/home/pi ``` -- After copying `julia-v1.4.2` to your Raspberry Pi, one need install the following dependencies via `apt` which is almost same as Dockerfile-1.4.2. +- After copying `julia-v1.5.0` to your Raspberry Pi, one need install the following dependencies via `apt` which is almost same as Dockerfile-1.5.0. ```console # Open Your Raspberry Pi's terminal @@ -156,7 +151,7 @@ $ sudo apt-get update && \ liblapack-dev \ libgmp3-dev \ libmpfr-dev -$ export 'PATH=/home/pi/julia-v1.4.1/bin:$PATH' >> /home/pi/.bashrc +$ export 'PATH=/home/pi/julia-v1.5.0/bin:$PATH' >> /home/pi/.bashrc $ source /home/pi/.bashrc $ julia # Oh Yes!!! ``` @@ -168,21 +163,27 @@ That's all - we will show another example: ```console -$ sudo docker create --name jltmp -it terasakisatoshi/jlcross:jetson-v1.4.2 /bin/bash -$ sudo docker cp jltmp:/home/jetson-nano/work/julia-1.4.2 . -$ sudo docker stop jltmp +$ docker create --name jltmp -it terasakisatoshi/jlcross:jetson-v1.5.0 /bin/bash +$ docker cp jltmp:/home/jetson-nano/work/julia-1.5.0 . +$ docker stop jltmp $ docker rm jltmp -$ ls # you will see julia-1.4.2 current directory of your build machine -julia-1.4.2 +$ ls # you will see julia-1.5.0 current directory of your build machine +julia-1.5.0 ``` -That's all. +That's all. Note that since the official Julia page provides julia binary for aarch64 with Tier1 we do not have to use this image. + + # Restriction - We can't confirm building Julia version = `v1.2.0` on Raspberry Pi zero works fine. - You'll see some error message with respect to illegal instruction. - - `v1.0.5`, `v1.1.1`, `v1.3.1`, `v1.4.0`, `v1.4.1`, `v1.4.2` `v1.5.0-rc1` are O.K. + - `v1.0.5`, `v1.1.1`, `v1.3.1`, `v1.4.0`, `v1.4.1`, `v1.4.2`, `v1.5.0-rc1` and `v1.5.0` are O.K. + +- To pass building procedure for Julia v1.5.0, we have to modify `contrib/generate_precompile.jl` script that omit precompile statements regarding to `Pkg` installation to avoid this issue [armv7l: ptrtoint not supported for non-integral pointers #36062](https://github.com/JuliaLang/julia/issues/36062). This modification will increase the latency for users to install arbitrary packages. If you are new to Julia and want to try it on your Raspberry Pi, we strongly recommend to use julia `v1.4.2` not `v1.5.x` or build julia `v1.6.0-DEV` by yourself. +![image](https://user-images.githubusercontent.com/16760547/89385620-daf84480-d73a-11ea-8993-c786c249786e.png) + - We can't build Julia version = `v1.2.0` on Raspberry Pi3 using Docker its base image is `balenalib/raspberrypi3:buster-20191030` with error message something like: - ` undefined reference to llvm::BasicBlockPass::createPrinterPass(llvm::raw_ostream&, std::string const&) const'`