From e343161256a27a347623ce17798e72980d62ef32 Mon Sep 17 00:00:00 2001 From: Falk Pollok Date: Fri, 18 Sep 2020 08:56:55 -0400 Subject: [PATCH] Added preliminary Ubuntu 20.04 images for both CPU and GPU as well as documentation. --- docker/GenCPU.dockerfile | 40 +++++++++++++++++++++++++++++++++++++++ docker/GenGPU.dockerfile | 40 +++++++++++++++++++++++++++++++++++++++ docker/Readme.md | 41 ++++++++++++++++++++++++++++++++++++++++ docker/ubuntu1604 | 33 -------------------------------- 4 files changed, 121 insertions(+), 33 deletions(-) create mode 100644 docker/GenCPU.dockerfile create mode 100644 docker/GenGPU.dockerfile create mode 100644 docker/Readme.md delete mode 100644 docker/ubuntu1604 diff --git a/docker/GenCPU.dockerfile b/docker/GenCPU.dockerfile new file mode 100644 index 00000000..92343b0c --- /dev/null +++ b/docker/GenCPU.dockerfile @@ -0,0 +1,40 @@ +FROM ubuntu:20.04 + +LABEL maintainer="MIT Probabilistic Computing Project" + +# Find current Julia version on https://julialang.org/downloads/ +ARG JULIA_VERSION_SHORT="1.5" +ARG JULIA_VERSION_FULL="${JULIA_VERSION_SHORT}.1" +ENV JULIA_INSTALLATION_PATH=/opt/julia + +ENV DEBIAN_FRONTEND=noninteractive +ENV JULIA_INSTALLATION_PATH=/opt/julia + +RUN apt-get update -qq \ + && apt-get install -qq -y --no-install-recommends\ + build-essential \ + ca-certificates \ + curl \ + ffmpeg \ + git \ + graphviz \ + hdf5-tools \ + python3-dev \ + python3-pip \ + python3-tk \ + rsync \ + software-properties-common \ + wget \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* && \ + ln -s /usr/bin/python3 /usr/bin/python + +RUN wget https://julialang-s3.julialang.org/bin/linux/x64/${JULIA_VERSION_SHORT}/julia-${JULIA_VERSION_FULL}-linux-x86_64.tar.gz && \ + tar zxf julia-${JULIA_VERSION_FULL}-linux-x86_64.tar.gz && \ + mkdir -p "${JULIA_INSTALLATION_PATH}" && \ + mv julia-${JULIA_VERSION_FULL} "${JULIA_INSTALLATION_PATH}/" && \ + ln -fs "${JULIA_INSTALLATION_PATH}/julia-${JULIA_VERSION_FULL}/bin/julia" /usr/local/bin/ && \ + rm julia-${JULIA_VERSION_FULL}-linux-x86_64.tar.gz && \ + julia -e 'import Pkg; Pkg.add("IJulia")' + +RUN julia -e 'import Pkg; Pkg.add(["Gen"])' diff --git a/docker/GenGPU.dockerfile b/docker/GenGPU.dockerfile new file mode 100644 index 00000000..3d9a7058 --- /dev/null +++ b/docker/GenGPU.dockerfile @@ -0,0 +1,40 @@ +FROM nvidia/opengl:1.0-glvnd-runtime-ubuntu20.04 + +LABEL maintainer="MIT Probabilistic Computing Project" + +# Find current Julia version on https://julialang.org/downloads/ +ARG JULIA_VERSION_SHORT="1.5" +ARG JULIA_VERSION_FULL="${JULIA_VERSION_SHORT}.1" +ENV JULIA_INSTALLATION_PATH=/opt/julia + +ENV DEBIAN_FRONTEND=noninteractive +ENV JULIA_INSTALLATION_PATH=/opt/julia + +RUN apt-get update -qq \ + && apt-get install -qq -y --no-install-recommends\ + build-essential \ + ca-certificates \ + curl \ + ffmpeg \ + git \ + graphviz \ + hdf5-tools \ + python3-dev \ + python3-pip \ + python3-tk \ + rsync \ + software-properties-common \ + wget \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* && \ + ln -s /usr/bin/python3 /usr/bin/python + +RUN wget https://julialang-s3.julialang.org/bin/linux/x64/${JULIA_VERSION_SHORT}/julia-${JULIA_VERSION_FULL}-linux-x86_64.tar.gz && \ + tar zxf julia-${JULIA_VERSION_FULL}-linux-x86_64.tar.gz && \ + mkdir -p "${JULIA_INSTALLATION_PATH}" && \ + mv julia-${JULIA_VERSION_FULL} "${JULIA_INSTALLATION_PATH}/" && \ + ln -fs "${JULIA_INSTALLATION_PATH}/julia-${JULIA_VERSION_FULL}/bin/julia" /usr/local/bin/ && \ + rm julia-${JULIA_VERSION_FULL}-linux-x86_64.tar.gz && \ + julia -e 'import Pkg; Pkg.add("IJulia")' + +RUN julia -e 'import Pkg; Pkg.add(["Gen"])' diff --git a/docker/Readme.md b/docker/Readme.md new file mode 100644 index 00000000..fea4b0e1 --- /dev/null +++ b/docker/Readme.md @@ -0,0 +1,41 @@ +# Gen Containerization + +## Quickstart + +### Docker Setup +Please follow the [official Docker installation instructions](https://docs.docker.com/engine/install/) to setup Docker on your target platform. If you would like to use GPU acceleration, please also install the [NVIDIA Container Toolkit / nvidia-docker](https://github.com/NVIDIA/nvidia-docker). + + +### Building Container +You can build Docker containers for Gen that either target CPU-only or GPU-enabled machines. +- Please run `docker build -f docker/GenCPU.dockerfile -t gen:cpu-ubuntu20.04 .` for the CPU image +- Please run `docker build -f docker/GenGPU.dockerfile -t gen:gpu-ubuntu20.04 .` if you want to use GPU acceleration +Both commands are supposed to be run from the main Gen.jl folder, not this subfolder. + +### Running Container +You can run `docker run -it gen:cpu-ubuntu20.04 bash` to run the CPU image and `docker run -it --gpus all gen:gpu-ubuntu20.04 bash` to run the GPU image. Afterwards, you can just execute `julia`, type `using Gen` and start developing with Gen. If you would like to remove the container, please add the flag `--rm` to your run command. + +## Known Issues + +### Run or Build Script Not Executable +If you get an error like +``` +bash: ./docker_build_gpu.sh: Permission denied +``` +Then please make the script executable via `chmod +x docker_build_gpu.sh` (analogous for CPU). + +### Known Issues with Docker on macOS +The Docker container might currently fail on macOS with the following error: +``` +julia> using Gen +[ Info: Precompiling Gen [ea4f424c-a589-11e8-07c0-fd5c91b9da4a] +ERROR: Failed to precompile Gen [ea4f424c-a589-11e8-07c0-fd5c91b9da4a] to /root/.julia/compiled/v1.4/Gen/OEZG1_t5nDi.ji. +Stacktrace: + [1] error(::String) at ./error.jl:33 + [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272 + [3] _require(::Base.PkgId) at ./loading.jl:1029 + [4] require(::Base.PkgId) at ./loading.jl:927 + [5] require(::Module, ::Symbol) at ./loading.jl:922 + ``` + + This can even happen when running inside a VM on macOS. While this bug is confirmed and reproducable, there is currently no solution for it, cmp. [issue 311](https://github.com/probcomp/Gen.jl/issues/311). diff --git a/docker/ubuntu1604 b/docker/ubuntu1604 deleted file mode 100644 index de1b49d4..00000000 --- a/docker/ubuntu1604 +++ /dev/null @@ -1,33 +0,0 @@ -FROM ubuntu:16.04 -MAINTAINER MIT Probabilistic Computing Project - -RUN apt-get update -qq && apt-get install -qq \ - build-essential \ - wget \ - ; # end of packages - -RUN mkdir /julia -RUN mkdir /julia/gpghome - -RUN cd /julia && \ - wget https://julialang.org/juliareleases.asc && \ - { echo a27705bf1e5a44d1905e669da0c990ac2d7ab7c13ec299e15bacdab5dcbb8d13 juliareleases.asc | sha256sum -c; } -RUN cd /julia && gpg --homedir gpghome --import juliareleases.asc - -ENV JULIA_TGZ=julia-0.7.0-linux-x86_64.tar.gz -ENV JULIA_URL=https://julialang-s3.julialang.org/bin/linux/x64/0.7 -RUN cd /julia && \ - wget "$JULIA_URL/$JULIA_TGZ" "$JULIA_URL/$JULIA_TGZ.asc" && \ - gpg --homedir gpghome --verify "$JULIA_TGZ.asc" "$JULIA_TGZ" -RUN cd /julia && \ - gunzip -c < "$JULIA_TGZ" | tar -x -f - --strip-components 1 -ENV PATH="$PATH:/julia/bin" - -ADD . /probcomp/Gen - -RUN julia -e 'using Pkg; Pkg.develop(PackageSpec(path="/probcomp/Gen"))' -RUN julia -e 'Pkg.test("Gen")' - -RUN julia -e 'Pkg.add("FunctionalCollections")' -RUN julia -e 'Pkg.add("Distributions")' -RUN julia -e 'include("/probcomp/Gen/examples/run_examples.jl")'