Deepesh Thakur / Jun 19 2019

Julia DiffEq Dev Env

We'll base our environment off of our Minimal Bash image. Note that the Julia version is set as an environment variable on the runtime.

Julia 1.1 Minimal
Julia 1.1 Minimal (Bash)
Type: Nextjournal
Environment:
Resources:
Environment Variables:
PATH/usr/local/julia/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
JULIA_PATH/usr/local/julia
JULIA_VERSION1.1.1
Download this environment as a Docker image from:
tarArch='x86_64'
dirArch='x64'
JULIA_VERSION_SHORT=${JULIA_VERSION/-rc/}
FILENAME="julia-${JULIA_VERSION}-linux-${tarArch}.tar.gz"
FILEURL="https://julialang-s3.julialang.org/bin/linux/${dirArch}/${JULIA_VERSION_SHORT%[.-]*}/${FILENAME}"

echo "Downloading ${FILEURL}."

curl -fL -o julia.sha256 \
  "https://julialang-s3.julialang.org/bin/checksums/julia-${JULIA_VERSION}.sha256"
curl -fL -o julia.tar.gz.asc "${FILEURL}.asc"
curl -fL -o julia.tar.gz "${FILEURL}"

echo `grep $FILENAME julia.sha256 | cut -d " " -f1` > j256sig

Check the signatures to verify our download.

sha256=`cat j256sig`
echo "${sha256} *julia.tar.gz" | sha256sum -c -

Install and remove the archive.

mkdir -p "$JULIA_PATH"
tar -xzf julia.tar.gz -C "$JULIA_PATH" --strip-components 1
rm julia.tar.gz j256sig

And verify it runs.

julia -v

The JSON package is required to run on Nextjournal.

julia -E 'using Pkg

pkg"update"
pkg"add JSON"
pkg"build"
pkg"precompile"'

Build Julia 1.1

We'll add a number of packages as well as the libraries and support programs required by them. The major packages installed are JuliaPlots along with the GR and PlotlyJS backends, Makie, and the DataFrames, CSV, and HDF5 data-handling packages. The setup requires a GPU node for Makie to successfully precompile, but not to transclude and use unless Makie itself is needed.

First we'll check that the minimal Julia env works.

"$VERSION"
"1.1.1"

Some Julia packages require gcc to compile, so first we'll install that, as well as various required tools and libraries.

apt-get -qq update
apt-get install --no-install-recommends \
  imagemagick libhdf5-dev hdf5-tools mesa-utils \
  build-essential gfortran cmake automake libtool libltdl-dev pkg-config \
  libxt6 libxrender1 libgl1-mesa-glx libqt5widgets5 `# for GR` \
  libhttp-parser2.7.1 `# for PlotlyJS` \
  libxrandr-dev libxinerama-dev libxcursor-dev libglfw3-dev `# for Makie`
apt-get clean
rm -r /var/lib/apt/lists/* # Clear package list so it isn't stale

Plots also needs FFmpeg to create animations, so we'll install a 64-bit static build from an install package we download in the Appendix.

IDIR="/usr/local/ffmpeg"

mkdir -p $IDIR
cd $IDIR

tar -Jxf 
ffmpeg-release-amd64-static.tar.xz
--strip 1 for ex in $IDIR/{ffmpeg,ffmpeg-10bit,ffprobe,qt-faststart}; do ln -s $ex /usr/local/bin/ done

Next the Julia package installs. Bugfix: Makie release fails to precompile, recommendation is using #master for Makie, GLMakie, and AbstractPlotting—mpd, 9 Dec 2018.

using Pkg

pkg"update"
pkg"add BenchmarkTools DiffEqBase DiffEqDevTools DiffEqFlux DiffEqOperators DiffEqProblemLibrary DifferentialEquations FillArrays Flux LSODA ODEInterfaceDiffEq ParameterizedFunctions Test Plots RecursiveArrayTools StaticArrays Sundials Weave LinearAlgebra Random"
pkg"add StochasticDiffEq OrdinaryDiffEq"

Build all packages.

pkg"build"

And finally precompilation of any qualifying packages.

pkg"precompile"

Finally, add font defaults for JuliaPlots and Makie. These named Code Listings will be mounted as files to the runtime's filesystem, and saved with the environment.

PLOTS_DEFAULTS = Dict(:fontfamily => "Open Sans")
Julia
Attributes(font = "Open Sans")
Julia