diff --git a/README.md b/README.md index 796d589..fba56d4 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,14 @@ If you know how to use docker, you know how to use NEST. Currently the following docker images are provided - nestsim/nest:latest (~1,07GB) + - nestsim/nest:latest_mpich (~???GB) - nestsim/nest:2.12.0 (~535MB) - nestsim/nest:2.14.0 (~537MB) - nestsim/nest:2.16.0 (~539MB) - nestsim/nest:2.18.0 (~543MB) - nestsim/nest:2.20.0 (~634MB) - nestsim/nest:3.0 (~1,07GB) (until now equal with 'latest') - + All are build with these environment variable: - 'WITH_MPI=ON' @@ -24,7 +25,7 @@ All are build with these environment variable: You can change this on top of every 'dockerfile'. - + ## Usage You can use the docker images direct out of docker hub like this: @@ -35,47 +36,47 @@ You can use the docker images direct out of docker hub like this: -v $(pwd):/opt/data \ -p 8080:8080 nestsim/nest: - + [] can be either 'notebook', 'nest-server', interactice' or '/bin/bash' - [] kind of docker image (e.g. 'latest', '2.12.0', '2.14.0', + [] kind of docker image (e.g. 'latest', '2.12.0', '2.14.0', '2.16.0', '2.18.0', '3.0') - + eg. docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` --name my_app \ -v $(pwd):/opt/data \ -p 8080:8080 nestsim/nest:latest notebook - + or for starting nest-server in background (only 'latest') docker run -d --rm -e LOCAL_USER_ID=`id -u $USER` -p 5000:5000 nestsim/nest:latest nest-server - + If you want to work with a container for a longer time, you should remove the '--rm': docker run -it -e LOCAL_USER_ID=`id -u $USER` --name my_app \ -v $(pwd):/opt/data \ -p 8080:8080 nestsim/nest: - + After you stop the container, it still exists ('docker ps -a'). To restart simply use: docker start -i my_app - + ### On Windows docker run -it --rm -v %cd%:/opt/data -p 8080:8080 nestsim/nest: - -In Powershell, '%cd%' might not work for the current directory. Then + +In Powershell, '%cd%' might not work for the current directory. Then you should explicitly specify a folder with existing write permissions. - + In any case, this will download the docker image with the pre-installed NEST master form docker hub and start it. After booting an URL is presented. -Click on it or copy it to your browser. Voilá jupyter notebook starts from +Click on it or copy it to your browser. Voilá jupyter notebook starts from the docker image. You can update the image with: docker pull nestsim/nest: - + ## Usage of the local build system - + You can clone this repository and use the shell script: sh run.sh [--help] [] [] @@ -105,17 +106,17 @@ Two little steps to get started ### 1 - Provisioning -This step is only necessary if you want to build the images directly +This step is only necessary if you want to build the images directly from the docker files. sh run.sh provision VERSION - -Be careful with the version 'all'. This really takes a long time. - -After every build of a NEST docker image, there are two more images - the one -with the name of the NEST version (e.g. 'nestsim/nest:master') and + +Be careful with the version 'all'. This really takes a long time. + +After every build of a NEST docker image, there are two more images - the one +with the name of the NEST version (e.g. 'nestsim/nest:master') and another without any name. The last one you can delete. -More information about this so called 'multi-stage build' here: +More information about this so called 'multi-stage build' here: ### 2 - Run @@ -123,13 +124,13 @@ More information about this so called 'multi-stage build' here: - with Jupyter Notebook (recommended) sh run.sh run notebook VERSION - - or - + + or + docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` --name my_app \ -v $(pwd):/opt/data \ -p 8080:8080 nestsim/nest:VERSION notebook - + (For VERSION see above) Open the displayed URL in your browser and have fun with Jupyter @@ -138,13 +139,13 @@ More information about this so called 'multi-stage build' here: - in interactive mode sh run.sh run interactive VERSION - - or - + + or + docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` --name my_app \ -v $(pwd):/opt/data \ -p 8080:8080 nestsim/nest:VERSION interactive - + (For VERSION see above) After the prompt 'Your python script:' enter the filename of the script @@ -154,13 +155,13 @@ More information about this so called 'multi-stage build' here: - as virtual image sh run.sh run virtual VERSION - - or - + + or + docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` --name my_app \ -v $(pwd):/opt/data \ -p 8080:8080 nestsim/nest:VERSION /bin/bash - + (For VERSION see above) You are logged in as user 'nest'. Enter 'python' and in the @@ -180,7 +181,7 @@ In the folder with your music scripts run: docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` \ -v $(pwd):/opt/data \ nestsim/nest:3.0 /bin/bash - + You are now on container's shell, but can use the programs on your local machine mpirun -np 2 music /opt/data/minimalmusicsetup.music diff --git a/run.sh b/run.sh index 8f4a270..b5c57e1 100755 --- a/run.sh +++ b/run.sh @@ -48,12 +48,12 @@ fi case $command in provision) echo - echo "Provisioning needs an argument: 'latest' '2.12.0', '2.14.0'," - echo "'2.16.0', '2.18.0', '2.20.0', '3.0' or 'all'." + echo "Provisioning needs an argument: 'latest', 'latest_mpich', '2.12.0'," + echo "'2.14.0', '2.16.0', '2.18.0', '2.20.0', '3.0' or 'all'." echo while test $# -gt 0; do case "$1" in - latest | 2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0 ) + latest | latest_mpich | 2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0 ) echo "Build the NEST image for NEST $1" echo docker build -t nestsim/nest:"$1" ./src/"$1" @@ -62,7 +62,7 @@ case $command in ;; all) echo "Build the NEST image for NEST 2.12.0, 2.14.0," - echo "2.16.0, 2.18.0, 2.20.0, 3.0 and latest" + echo "2.16.0, 2.18.0, 2.20.0, 3.0 latest_mpich and latest" echo docker build -t nestsim/nest:2.12.0 ./src/2.12.0 docker build -t nestsim/nest:2.14.0 ./src/2.14.0 @@ -70,6 +70,7 @@ case $command in docker build -t nestsim/nest:2.18.0 ./src/2.18.0 docker build -t nestsim/nest:2.20.0 ./src/2.20.0 docker build -t nestsim/nest:3.0 ./src/3.0 + docker build -t nestsim/nest:latest_mpich ./src/latest_mpich docker build -t nestsim/nest:latest ./src/latest echo echo "Finished!" @@ -91,14 +92,14 @@ case $command in echo " - 'virtual VERSION'" echo echo "VERSION is the version of NEST" - echo "(e.g. latest, 2.12.0, 2.14.0, 2.16.0, 2.18.0, 2.20.0, 3.0)" + echo "(e.g. latest, latest_mpich, 2.12.0, 2.14.0, 2.16.0, 2.18.0, 2.20.0, 3.0)" echo LOCALDIR="$(pwd)" while test $# -gt 1; do case "$1" in notebook) case "$2" in - latest | 2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0) + latest | latest_mpich | 2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0) echo "Run NEST-$2 with Jupyter Notebook". echo docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` --name my_app \ @@ -114,7 +115,7 @@ case $command in ;; interactive) case "$2" in - latest | 2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0) + latest | latest_mpich |2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0) echo "Run NEST-$2 in interactive mode." echo docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` --name my_app \ @@ -130,7 +131,7 @@ case $command in ;; virtual) case "$2" in - latest | 2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0) + latest | latest_mpich |2.12.0 | 2.14.0 | 2.16.0 | 2.18.0 | 2.20.0 | 3.0) echo "Run NEST-$2 like a virtual machine." echo docker run -it --rm -e LOCAL_USER_ID=`id -u $USER` --name my_app \ diff --git a/src/latest_mpich/Dockerfile b/src/latest_mpich/Dockerfile new file mode 100644 index 0000000..52463f8 --- /dev/null +++ b/src/latest_mpich/Dockerfile @@ -0,0 +1,169 @@ +FROM buildpack-deps:focal as buildermaster +LABEL maintainer="s.graber@fz-juelich.de" + +ARG WITH_MPI=ON +ARG WITH_OMP=ON +ARG WITH_GSL=ON +#ARG WITH_MUSIC=ON +ARG WITH_LIBNEUROSIM=OFF + +ENV TERM=xterm \ + TZ=Europe/Berlin \ + DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential libtool automake autotools-dev libreadline8 libreadline-dev freeglut3-dev \ + gosu \ + cmake \ + cython3 \ + jq \ + libboost-dev \ + libgomp1 \ + libgsl-dev \ + libltdl7 \ + libltdl-dev \ + libmusic1v5 \ + libmpich-dev \ + libomp-dev \ + libpcre3 \ + libpcre3-dev \ + libpython3.8 \ + llvm-dev \ + mpich \ + pep8 \ + python3-dev \ + python3-ipython \ + python3-jupyter-core \ + python3-matplotlib \ + python3-nose \ + python3-numpy \ + python3-pandas \ + python3-path \ + python3-pip \ + python3-scipy \ + python3-setuptools \ + python3-statsmodels \ + python3-tk \ + python-dev \ + vera++ \ + wget && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* && \ + # update-alternatives --remove-all python && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \ + update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10 + +# Install mpi4py +RUN pip install mpi4py + +# Install music +RUN wget https://github.com/INCF/MUSIC/archive/master.tar.gz && \ + tar -zxf master.tar.gz && \ + mkdir music-build music-install && \ + cd MUSIC-master && \ + sh ./autogen.sh && \ + cd ../music-build && \ + ../MUSIC-master/configure --prefix=/opt/music-install && \ + make && \ + make install && \ + cd / && \ + rm master.tar.gz + +# Install libneurosim +# RUN git clone https://github.com/INCF/libneurosim.git libneurosim && \ +# cd libneurosim && \ +# chmod +x autogen.sh && \ +# ./autogen.sh && \ +# chmod +x configure && \ +# ./configure --prefix=/opt/libneurosim-install --with-python=3 && \ +# make && \ +# make install + +# Install NEST +RUN git clone https://github.com/nest/nest-simulator.git && \ + cd nest-simulator && \ + git checkout master && \ + cd .. && \ + mkdir nest-build && \ + ls -l && \ + cd nest-build && \ + cmake -DCMAKE_INSTALL_PREFIX:PATH=/opt/nest/ \ + # -Dwith-optimize=ON \ + # -Dwith-warning=ON \ + -Dwith-ltdl=ON \ + -Dwith-gsl=$WITH_GSL \ + -Dwith-readline=ON \ + -Dwith-python=ON \ + -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.8.so \ + -DPYTHON_INCLUDE_DIR=/usr/include/python3.8 \ + -Dwith-mpi=$WITH_MPI \ + -Dwith-openmp=$WITH_OMP \ + -Dwith-libneurosim=$WITH_LIBNEUROSIM \ + -Dwith-music=/opt/music-install \ + ../nest-simulator && \ + make && \ + make install + + +############################################################################### + +FROM ubuntu:focal +LABEL maintainer="s.graber@fz-juelich.de" + +ENV TERM=xterm \ + TZ=Europe/Berlin \ + DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + curl \ + libpcre3 \ + libpcre3-dev \ + gosu \ + jupyter-notebook \ + less \ + libgomp1 \ + libgsl-dev \ + libltdl7 \ + libmpich-dev \ + libomp-dev \ + libpython3.8 \ + nano \ + mpich \ + openssh-client \ + openssh-server \ + python3-dev \ + python3-flask \ + python3-flask-cors \ + python3-restrictedpython \ + python3-matplotlib \ + python3-numpy \ + python3-pip \ + python3-scipy \ + python3-setuptools \ + python3-pandas \ + python3-sympy \ + python3-tk \ + wget && \ + apt-get autoremove -y && \ + rm -rf /var/lib/apt/lists/* && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \ + update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 10 && \ + pip install quantities lazyarray neo && \ + pip install uwsgi &&\ + pip install mpi4py &&\ + # wget https://github.com/NeuralEnsemble/PyNN/archive/nest-dev.tar.gz && \ + # tar -xzf nest-dev.tar.gz && \ + # cd PyNN-nest-dev && \ + # python3 setup.py install && \ + # cd .. && rm -rf PyNN-nest-dev && rm nest-dev.tar.gz + pip install --no-binary :all: PyNN + +COPY --from=buildermaster /opt/nest /opt/nest +COPY --from=buildermaster /opt/music-install /opt/music-install + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod +x /usr/local/bin/entrypoint.sh + +EXPOSE 5000 8080 +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/src/latest_mpich/entrypoint.sh b/src/latest_mpich/entrypoint.sh new file mode 100644 index 0000000..100746f --- /dev/null +++ b/src/latest_mpich/entrypoint.sh @@ -0,0 +1,54 @@ +#!/bin/bash +set -e +IP_ADDRESS=$(hostname --ip-address) +USER_ID=${LOCAL_USER_ID:-9001} + +if [[ ! $(id -u nest) = $USER_ID ]]; then + echo "UID : $USER_ID" + adduser --disabled-login --gecos 'NEST' --uid $USER_ID --home /home/nest nest + export HOME=/home/nest +fi + +echo '. /opt/nest/bin/nest_vars.sh' >> /home/nest/.bashrc + +# NEST environment +source /opt/nest/bin/nest_vars.sh + +# Running NEST to test and to copy the .nestrc into /home/nest +nest --help +chown nest:nest /home/nest/.nestrc + +export MUSIC_ROOT_DIR=/opt/music-install +export MUSIC_ROOT=${MUSIC_ROOT_DIR} +MUSIC_PATH=${MUSIC_ROOT_DIR} +export LD_LIBRARY_PATH=${MUSIC_PATH}/lib:$LD_LIBRARY_PATH +export PATH=${MUSIC_PATH}/bin:$PATH +export CPATH=${MUSIC_PATH}/include:$CPATH +export PYTHONPATH=${MUSIC_PATH}/lib/python3.8/site-packages:$PYTHONPATH + +if [[ ! -d /opt/data ]]; then + mkdir /opt/data + chown -R nest:nest /opt/data +fi + +if [[ "$1" = 'notebook' ]]; then + cd /opt/data + exec gosu nest jupyter-notebook --ip="${IP_ADDRESS}" --port=8080 --no-browser +fi + +if [[ "$1" = 'nest-server' ]]; then + cd /opt/data + NEST_SERVER_RESTRICTION_OFF=TRUE + exec gosu nest nest-server start -o -h 0.0.0.0 -p 5000 -u $UID +fi + +if [[ "$1" = 'interactive' ]]; then + read -p "Your python script: " name + echo Starting: $name + cd /opt/data + # Start + exec gosu nest python3 /opt/data/$name +fi + +cd /opt/data +exec gosu nest "$@"