From 0d988ddbc0465e3f29d4e568fc3a225e831922a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Iser?= Date: Wed, 26 Aug 2020 10:33:24 +0200 Subject: [PATCH 1/3] Dockerfiles for CPU and GPU --- resources/docker/README.md | 71 +++++++++++++++++++++++++++ resources/docker/linux-cpu.Dockerfile | 32 ++++++++++++ resources/docker/linux-gpu.Dockerfile | 36 ++++++++++++++ 3 files changed, 139 insertions(+) create mode 100644 resources/docker/README.md create mode 100644 resources/docker/linux-cpu.Dockerfile create mode 100644 resources/docker/linux-gpu.Dockerfile diff --git a/resources/docker/README.md b/resources/docker/README.md new file mode 100644 index 000000000..573181fea --- /dev/null +++ b/resources/docker/README.md @@ -0,0 +1,71 @@ +# Docker files for Mitsuba 2 + +Here are Docker files for running Mitsuba 2 either CPU only, or also with GPU support. + +**Attention!** For GPU and CUDA/OptiX to work, you need to have new Nvidia drivers with builtin OptiX libraries, and also updated Docker and Nvidia Docker that provide proper mounting of OptiX libraries. You do **not** need to install OptiX SDK, it is **not** necessary for Mitsuba 2! Only the updated Nvidia drivers and Docker are needed. + +## Building the images + +Building the CPU only version: + +``` +docker build -t mitsuba2:cpu -f linux-cpu.Dockerfile . +``` + +Building the CPU/GPU version: + +``` +docker build -t mitsuba2:gpu -f linux-gpu.Dockerfile . +``` + +The images will be tagged as `mitsuba2:cpu` or `mitsuba2:gpu`. + +## Starting the containers + +Running the CPU image: + +``` +cd /path/to/mitsuba2 +docker run -it -p 45678:8888 -v $(pwd):/mitsuba2 -u $(id -u):$(id -g) mitsuba2:cpu bash +``` + +This will mount the Mitsuba 2 root directory to `/mitsuba2` inside the container and map port `8888` (used for Jupyter) from the container to port `45678` in the host machine. + +Running the GPU image: + +``` +cd /path/to/mitsuba2 +docker run --runtime=nvidia --gpus all -it -p 45678:8888 -v $(pwd):/mitsuba2 -u $(id -u):$(id -g) mitsuba2:gpu bash +``` + +This will do the same as above, and also mount all available GPUs to the container. + +## Compiling Mitsuba 2 + +Works the same as described in Mitsuba 2 documentation: + +``` +cd /mitsuba2 +mkdir build +cd build +cmake -GNinja .. +ninja +``` + +## Running Mitsuba 2 + +``` +cd /mitsuba2 +source setpath.sh +mitsuba2 --help +``` + +## Running Jupyter + +``` +cd /mitsuba2 +source setpath.sh +jupyter notebook --port 8888 --ip 0.0.0.0 +``` + +And then you can connect to the Jupyter notebook via `localhost:45678` in your web browser. \ No newline at end of file diff --git a/resources/docker/linux-cpu.Dockerfile b/resources/docker/linux-cpu.Dockerfile new file mode 100644 index 000000000..7bb6602a3 --- /dev/null +++ b/resources/docker/linux-cpu.Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:18.04 + +# Install build tools, including Clang and libc++ (Clang's C++ library) +RUN apt-get update && apt-get install -y \ + clang-9 \ + cmake \ + libc++-9-dev \ + libc++abi-9-dev \ + libjpeg-dev \ + libpng-dev \ + libxcursor-dev \ + libxinerama-dev \ + libxrandr-dev \ + libz-dev \ + ninja-build \ + python3-dev \ + python3-distutils \ + python3-setuptools \ + python3-pip + +# Install basic Python tools +RUN pip3 install jupyterlab numpy matplotlib ipywidgets + +# create /.local so that Python and Jupyter are happy +RUN mkdir /.local && chmod a+rwx /.local + +# Set C/C++ compilers to Clang +ENV CC=clang-9 +ENV CXX=clang++-9 + +WORKDIR /mitsuba2 +CMD ["/bin/bash"] diff --git a/resources/docker/linux-gpu.Dockerfile b/resources/docker/linux-gpu.Dockerfile new file mode 100644 index 000000000..c9763beee --- /dev/null +++ b/resources/docker/linux-gpu.Dockerfile @@ -0,0 +1,36 @@ +# Start from CUDA 10.2 development image +FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 + +ENV NVIDIA_VISIBLE_DEVICES all +ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,graphics + +# Install build tools, including Clang and libc++ (Clang's C++ library) +RUN apt-get update && apt-get install -y \ + clang-9 \ + cmake \ + libc++-9-dev \ + libc++abi-9-dev \ + libjpeg-dev \ + libpng-dev \ + libxcursor-dev \ + libxinerama-dev \ + libxrandr-dev \ + libz-dev \ + ninja-build \ + python3-dev \ + python3-distutils \ + python3-setuptools \ + python3-pip + +# Install basic Python tools +RUN pip3 install jupyterlab numpy matplotlib ipywidgets + +# create /.local so that Python and Jupyter are happy +RUN mkdir /.local && chmod a+rwx /.local + +# Set C/C++ compilers to Clang +ENV CC=clang-9 +ENV CXX=clang++-9 + +WORKDIR /mitsuba2 +CMD ["/bin/bash"] From bedea982333cf8ec529188a4d33cb51258dae693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Iser?= Date: Wed, 26 Aug 2020 10:39:02 +0200 Subject: [PATCH 2/3] Docker readme update --- resources/docker/README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/resources/docker/README.md b/resources/docker/README.md index 573181fea..308abeaf9 100644 --- a/resources/docker/README.md +++ b/resources/docker/README.md @@ -2,19 +2,21 @@ Here are Docker files for running Mitsuba 2 either CPU only, or also with GPU support. -**Attention!** For GPU and CUDA/OptiX to work, you need to have new Nvidia drivers with builtin OptiX libraries, and also updated Docker and Nvidia Docker that provide proper mounting of OptiX libraries. You do **not** need to install OptiX SDK, it is **not** necessary for Mitsuba 2! Only the updated Nvidia drivers and Docker are needed. +**Attention!** For GPU and CUDA/OptiX to work, you need to have new Nvidia drivers with builtin OptiX libraries, and also updated Docker and Nvidia Docker that provide proper mounting of OptiX libraries. You do **not** need to install OptiX SDK, it is **not** necessary for new versions of Mitsuba 2! Only the updated Nvidia drivers and Docker are needed. ## Building the images Building the CPU only version: ``` +cd /path/to/mitsuba2/resources/docker docker build -t mitsuba2:cpu -f linux-cpu.Dockerfile . ``` Building the CPU/GPU version: ``` +cd /path/to/mitsuba2/resources/docker docker build -t mitsuba2:gpu -f linux-gpu.Dockerfile . ``` @@ -38,11 +40,13 @@ cd /path/to/mitsuba2 docker run --runtime=nvidia --gpus all -it -p 45678:8888 -v $(pwd):/mitsuba2 -u $(id -u):$(id -g) mitsuba2:gpu bash ``` -This will do the same as above, and also mount all available GPUs to the container. +This will do the same as above, and also mount all available GPUs to the container. You can try running `nvidia-smi` inside the container to verify the GPUs have been mounted correctly. ## Compiling Mitsuba 2 -Works the same as described in Mitsuba 2 documentation: +Works the same as described in Mitsuba 2 documentation. + +Note: Do not forget to modify `mitsuba.conf` if you want to add GPU variants. ``` cd /mitsuba2 @@ -57,7 +61,7 @@ ninja ``` cd /mitsuba2 source setpath.sh -mitsuba2 --help +mitsuba --help ``` ## Running Jupyter From 0f9bf7286ca3e919cc41cbc3499629a90f47584e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Iser?= Date: Wed, 26 Aug 2020 16:10:57 +0200 Subject: [PATCH 3/3] Add pytest to Dockerfiles Co-authored-by: Tobias Rittig --- resources/docker/linux-cpu.Dockerfile | 2 +- resources/docker/linux-gpu.Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/docker/linux-cpu.Dockerfile b/resources/docker/linux-cpu.Dockerfile index 7bb6602a3..68e35ac8f 100644 --- a/resources/docker/linux-cpu.Dockerfile +++ b/resources/docker/linux-cpu.Dockerfile @@ -19,7 +19,7 @@ RUN apt-get update && apt-get install -y \ python3-pip # Install basic Python tools -RUN pip3 install jupyterlab numpy matplotlib ipywidgets +RUN pip3 install jupyterlab numpy matplotlib ipywidgets pytest # create /.local so that Python and Jupyter are happy RUN mkdir /.local && chmod a+rwx /.local diff --git a/resources/docker/linux-gpu.Dockerfile b/resources/docker/linux-gpu.Dockerfile index c9763beee..68a333d46 100644 --- a/resources/docker/linux-gpu.Dockerfile +++ b/resources/docker/linux-gpu.Dockerfile @@ -23,7 +23,7 @@ RUN apt-get update && apt-get install -y \ python3-pip # Install basic Python tools -RUN pip3 install jupyterlab numpy matplotlib ipywidgets +RUN pip3 install jupyterlab numpy matplotlib ipywidgets pytest # create /.local so that Python and Jupyter are happy RUN mkdir /.local && chmod a+rwx /.local