From 71dc0e8800bda5c39de2f66b143d84b427be5024 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 27 Nov 2023 15:23:36 +0000 Subject: [PATCH 1/2] auto OMP_NUM_THREADS = cpu_count//2 --- jupyterhub/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jupyterhub/Dockerfile b/jupyterhub/Dockerfile index 8a95806c..c51dd997 100644 --- a/jupyterhub/Dockerfile +++ b/jupyterhub/Dockerfile @@ -55,6 +55,8 @@ ENV SIRF_PATH "/opt/SIRF-SuperBuild/sources/SIRF" #Suppress output from Gadgetron which gives some problems on notebooks (QUIERO) ENV GADGETRON_LOG_MASK "" RUN echo $PATH +USER root +RUN echo "export OMP_NUM_THREADS=\$(python -c 'import multiprocessing as mc; print(mc.cpu_count() // 2)')" > /usr/local/bin/before-notebook.d/omp_num_threads.sh # switch back to USER jovyan From 987a066e62117416e930f86295cd70a9d7b014a8 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 27 Nov 2023 15:27:16 +0000 Subject: [PATCH 2/2] add docker-stacks submodule, cleanup build --- .gitmodules | 3 +++ jupyterhub/Dockerfile | 15 ++++++++------- jupyterhub/build_docker_stacks.sh | 10 ++++++---- jupyterhub/docker-stacks | 1 + 4 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 .gitmodules mode change 100644 => 100755 jupyterhub/build_docker_stacks.sh create mode 160000 jupyterhub/docker-stacks diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..95ebb758 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "jupyterhub/docker-stacks"] + path = jupyterhub/docker-stacks + url = https://github.com/jupyter/docker-stacks diff --git a/jupyterhub/Dockerfile b/jupyterhub/Dockerfile index c51dd997..40ef092e 100644 --- a/jupyterhub/Dockerfile +++ b/jupyterhub/Dockerfile @@ -1,10 +1,11 @@ +# syntax=docker/dockerfile:1 ARG BASE_IMAGE=nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04 # paskino/jupyter datascience-notebook-cuda11 FROM ${BASE_IMAGE} as base # Make sure the image has the same libraries as the standard SIRF docker image # Add to the docker image the appropriate stuff -user root +USER root COPY --chown=jovyan:users docker/build_essential-ubuntu.sh docker/build_gadgetron-ubuntu.sh docker/build_system-ubuntu.sh docker/install-sirf-exercises-dep.py ./scripts/ RUN bash ./scripts/build_essential-ubuntu.sh &&\ bash ./scripts/build_gadgetron-ubuntu.sh &&\ @@ -14,10 +15,10 @@ RUN bash ./scripts/build_essential-ubuntu.sh &&\ # https://docs.docker.com/develop/develop-images/multistage-build/#use-an-external-image-as-a-stage # not documented in https://docs.docker.com/engine/reference/builder/#copy # FROM --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf -COPY --from=synerbi/sirf:sirf-core /opt/SIRF-SuperBuild/INSTALL/ /opt/SIRF-SuperBuild/INSTALL -COPY --from=synerbi/sirf:sirf-core /opt/SIRF-SuperBuild/sources/SIRF/ /opt/SIRF-SuperBuild/sources/SIRF/ +COPY --from=synerbi/sirf:latest --link /opt/SIRF-SuperBuild/INSTALL/ /opt/SIRF-SuperBuild/INSTALL +COPY --from=synerbi/sirf:latest --link /opt/SIRF-SuperBuild/sources/SIRF/ /opt/SIRF-SuperBuild/sources/SIRF/ -from base as jup +FROM base AS jup # remove the SIRF-Exercises and CIL-Demos that get installed by user_service-ubuntu.sh USER jovyan ARG NB_USER="jovyan" @@ -44,7 +45,7 @@ RUN mamba env update -n base -f docker/requirements.yml &&\ # Switch back to jovyan to avoid accidental container runs as root # From https://github.com/paskino/SIRF-SuperBuild/blob/301c2274621e4729cadbd2a1705d8c4d9e3b7e50/docker/Dockerfile#L212-L219 # Set environment variables for SIRF -USER jovyan +USER jovyan COPY docker/.bashrc /home/jovyan ENV PATH "/opt/conda/bin:/opt/SIRF-SuperBuild/INSTALL/bin:$PATH" ENV LD_LIBRARY_PATH "/opt/SIRF-SuperBuild/INSTALL/lib:/opt/SIRF-SuperBuild/INSTALL/lib64:$LD_LIBRARY_PATH" @@ -58,7 +59,7 @@ RUN echo $PATH USER root RUN echo "export OMP_NUM_THREADS=\$(python -c 'import multiprocessing as mc; print(mc.cpu_count() // 2)')" > /usr/local/bin/before-notebook.d/omp_num_threads.sh -# switch back to +# switch back to USER jovyan -#/opt/SIRF-SuperBuild/INSTALL/lib:/opt/SIRF-SuperBuild/INSTALL/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64::/opt/conda/lib \ No newline at end of file +#/opt/SIRF-SuperBuild/INSTALL/lib:/opt/SIRF-SuperBuild/INSTALL/lib64:/usr/local/nvidia/lib:/usr/local/nvidia/lib64::/opt/conda/lib diff --git a/jupyterhub/build_docker_stacks.sh b/jupyterhub/build_docker_stacks.sh old mode 100644 new mode 100755 index 171f34b2..4a5cac2a --- a/jupyterhub/build_docker_stacks.sh +++ b/jupyterhub/build_docker_stacks.sh @@ -1,9 +1,10 @@ -# /bin/bash +#!/usr/bin/env bash +set -exuo pipefail -set -ex -pushd ../../docker-stacks/images/docker-stacks-foundation +git submodule update --init --recursive +pushd $(dirname "$0")/docker-stacks/images/docker-stacks-foundation # docker-stacks-foundations -docker build --build-arg PYTHON_VERSION=3.9 --build-arg ROOT_CONTAINER=nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu22.04 -t paskino/jupyter:docker-stacks-foundation-cuda11-cudnn8-runtime-ubuntu22.04 . +docker build --build-arg PYTHON_VERSION=3.9 --build-arg BASE_CONTAINER=nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu22.04 -t paskino/jupyter:docker-stacks-foundation-cuda11-cudnn8-runtime-ubuntu22.04 . # base notebook cd ../base-notebook @@ -26,3 +27,4 @@ docker build --build-arg BASE_CONTAINER=paskino/jupyter:scipy-notebook-cuda11-cu popd +docker build --build-arg BASE_IMAGE=paskino/jupyter:datascience-notebook-cuda11-cudnn8-runtime-ubuntu22.04 -t paskino/jupyter:sirf -f jupyterhub/Dockerfile . diff --git a/jupyterhub/docker-stacks b/jupyterhub/docker-stacks new file mode 160000 index 00000000..d91bb62b --- /dev/null +++ b/jupyterhub/docker-stacks @@ -0,0 +1 @@ +Subproject commit d91bb62be0cb525529e6028d9dfcb53d20775fe5