-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split up container into different parts for modularity
- Loading branch information
1 parent
dc1b0e6
commit 3ecdbb2
Showing
5 changed files
with
366 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,74 @@ | ||
# bring in the micromamba image so we can copy files from it | ||
FROM mambaorg/micromamba:1.5.8 as micromamba | ||
|
||
# This is the image we are going add micromaba to: | ||
FROM cp2k/cp2k:2023.2_openmpi_generic_psmp | ||
|
||
USER root | ||
|
||
# if your image defaults to a non-root user, then you may want to make the | ||
# next 3 ARG commands match the values in your image. You can get the values | ||
# by running: docker run --rm -it my/image id -a | ||
ARG MAMBA_USER=mambauser | ||
ARG MAMBA_USER_ID=57439 | ||
ARG MAMBA_USER_GID=57439 | ||
ENV MAMBA_USER=$MAMBA_USER | ||
ENV MAMBA_ROOT_PREFIX="/opt/conda" | ||
ENV MAMBA_EXE="/bin/micromamba" | ||
|
||
COPY --from=micromamba "$MAMBA_EXE" "$MAMBA_EXE" | ||
COPY --from=micromamba /usr/local/bin/_activate_current_env.sh /usr/local/bin/_activate_current_env.sh | ||
COPY --from=micromamba /usr/local/bin/_dockerfile_shell.sh /usr/local/bin/_dockerfile_shell.sh | ||
COPY --from=micromamba /usr/local/bin/_entrypoint.sh /usr/local/bin/_entrypoint.sh | ||
COPY --from=micromamba /usr/local/bin/_dockerfile_initialize_user_accounts.sh /usr/local/bin/_dockerfile_initialize_user_accounts.sh | ||
COPY --from=micromamba /usr/local/bin/_dockerfile_setup_root_prefix.sh /usr/local/bin/_dockerfile_setup_root_prefix.sh | ||
|
||
RUN apt-get update | ||
RUN apt-get install ca-certificates git -y | ||
RUN update-ca-certificates | ||
|
||
RUN /usr/local/bin/_dockerfile_initialize_user_accounts.sh && \ | ||
/usr/local/bin/_dockerfile_setup_root_prefix.sh | ||
|
||
# modify entrypoint to also activate cp2k, but do not set up the included (lib)torch | ||
RUN head -n -1 /usr/local/bin/_entrypoint.sh > /usr/local/bin/entry.sh | ||
RUN sed '/torch/Id' /opt/cp2k/tools/toolchain/install/setup > /opt/cp2k/tools/toolchain/install/setup_notorch | ||
RUN echo "source /opt/cp2k/tools/toolchain/install/setup_notorch\n" >> /usr/local/bin/entry.sh | ||
RUN echo "export PATH=\"/opt/cp2k/exe/local:\${PATH}\"\n" >> /usr/local/bin/entry.sh | ||
|
||
RUN echo "exec \"\$@\"" >> /usr/local/bin/entry.sh | ||
RUN chmod +x /usr/local/bin/entry.sh | ||
|
||
USER $MAMBA_USER | ||
|
||
SHELL ["/usr/local/bin/_dockerfile_shell.sh"] | ||
|
||
ENTRYPOINT ["/usr/local/bin/entry.sh"] | ||
# Optional: if you want to customize the ENTRYPOINT and have a conda | ||
# environment activated, then do this: | ||
# ENTRYPOINT ["/usr/local/bin/_entrypoint.sh", "my_entrypoint_program"] | ||
|
||
# You can modify the CMD statement as needed.... | ||
CMD ["/bin/bash"] | ||
|
||
RUN micromamba install -n base --yes -c conda-forge \ | ||
python=3.10 pip ndcctools py-plumed && \ | ||
micromamba clean -af --yes | ||
ARG MAMBA_DOCKERFILE_ACTIVATE=1 # (otherwise python will not be found) | ||
|
||
RUN pip install --no-cache-dir wandb plotly plumed | ||
RUN pip install --no-cache-dir git+https://github.com/lab-cosmo/i-pi.git@feat/socket_prefix | ||
FROM ubuntu:22.04 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Etc/UTC | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
python3.10 \ | ||
python3.10-venv \ | ||
python3.10-dev \ | ||
build-essential \ | ||
cmake \ | ||
wget \ | ||
git \ | ||
zlib1g-dev \ | ||
libssl-dev \ | ||
libcurl4-openssl-dev \ | ||
libgsl-dev \ | ||
perl \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN python3.10 -m venv /opt/venv \ | ||
&& /opt/venv/bin/pip install --upgrade pip | ||
|
||
# Install PLUMED | ||
ARG PLUMED_VERSION | ||
RUN wget https://github.com/plumed/plumed2/archive/refs/tags/v${PLUMED_VERSION}.tar.gz \ | ||
&& tar -xzf v${PLUMED_VERSION}.tar.gz \ | ||
&& cd plumed2-${PLUMED_VERSION} \ | ||
&& ./configure --prefix=/usr/local/plumed \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm -rf plumed2-${PLUMED_VERSION} v${PLUMED_VERSION}.tar.gz | ||
|
||
# Ensure cctools can find the Python environment | ||
ENV PYTHONPATH="/opt/venv/lib/python3.10/site-packages:$PYTHONPATH" | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
# Install cctools | ||
ARG CCTOOLS_VERSION | ||
RUN wget https://github.com/cooperative-computing-lab/cctools/archive/refs/tags/release/${CCTOOLS_VERSION}.tar.gz \ | ||
&& tar -xzf ${CCTOOLS_VERSION}.tar.gz \ | ||
&& cd cctools-release-${CCTOOLS_VERSION} \ | ||
&& ./configure --prefix=/usr/local/cctools \ | ||
&& make -j$(nproc) \ | ||
&& make install \ | ||
&& cd .. \ | ||
&& rm -rf cctools-release-${CCTOOLS_VERSION} ${CCTOOLS_VERSION}.tar.gz | ||
|
||
# Set environment variables for PLUMED and cctools | ||
ENV PATH="/usr/local/plumed/bin:/usr/local/cctools/bin:$PATH" | ||
ENV LD_LIBRARY_PATH="/usr/local/plumed/lib:/usr/local/cctools/lib:$LD_LIBRARY_PATH" | ||
|
||
# Create entrypoint script | ||
RUN echo '#!/bin/bash\nsource /opt/venv/bin/activate\nexec "$@"' > /usr/local/bin/entrypoint.sh | ||
RUN chmod +x /usr/local/bin/entrypoint.sh | ||
|
||
ARG PSIFLOW_VERSION | ||
ARG PARSL_VERSION | ||
ARG GPU_LIBRARY | ||
RUN pip install --no-cache-dir torch==2.1 --index-url https://download.pytorch.org/whl/${GPU_LIBRARY} | ||
RUN pip install --no-cache-dir git+https://github.com/acesuit/[email protected] | ||
ARG GIT_COMMIT_SHA | ||
RUN pip install --no-cache-dir git+https://github.com/molmod/psiflow.git@ipi | ||
|
||
|
||
# install GPAW with MPI from cp2k | ||
#USER root | ||
#RUN git clone https://gitlab.com/libxc/libxc.git && \ | ||
#cd libxc && \ | ||
#apt install autogen autoconf libtool && \ | ||
#autoreconf -i && \ | ||
#./configure && \ | ||
#make && \ | ||
#make check && \ | ||
#make install | ||
USER root | ||
RUN apt install libxc-dev -y | ||
USER $MAMBA_USER | ||
RUN source /opt/cp2k/tools/toolchain/install/setup && \ | ||
export C_INCLUDE_PATH=$CPATH && \ | ||
export LIBRARY_PATH=$LD_LIBRARY_PATH && \ | ||
echo "C INCLUDE PATH" $C_INCLUDE_PATH && \ | ||
pip install gpaw | ||
USER root | ||
RUN mkdir /opt/gpaw-data | ||
RUN yes | gpaw install-data /opt/gpaw-data || true | ||
ENV GPAW_SETUP_PATH=/opt/gpaw-data | ||
USER $MAMBA_USER | ||
|
||
#RUN echo "export GPAW_SETUP_PATH=\"/opt/gpaw-data\n" >> /usr/local/bin/entry.sh | ||
|
||
#ENV C_INCLUDE_PATH=$CPATH | ||
#RUN echo "export C_INCLUDE_PATH=\${CPATH}\"\n" >> /usr/local/bin/entry.sh | ||
#RUN /usr/local/bin/entry.sh | ||
#RUN echo "source /opt/cp2k/tools/toolchain/install/setup_notorch\n" >> /usr/local/bin/entry_gpaw.sh | ||
#RUN echo "source /opt/cp2k/tools/toolchain/install/setup_notorch\n" >> /usr/local/bin/entry_gpaw.sh | ||
RUN /bin/bash -c -o pipefail \ | ||
"source /opt/venv/bin/activate && \ | ||
pip install --no-cache-dir wandb plotly plumed && \ | ||
pip install --no-cache-dir git+https://github.com/lab-cosmo/i-pi.git@feat/socket_prefix && \ | ||
pip install --no-cache-dir git+https://github.com/molmod/psiflow.git@${PSIFLOW_VERSION} && \ | ||
pip install --no-cache-dir torch==2.1 --index-url https://download.pytorch.org/whl/${GPU_LIBRARY} && \ | ||
pip install --no-cache-dir git+https://github.com/acesuit/[email protected]" | ||
|
||
# Set entrypoint | ||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
|
||
# Default command | ||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# | ||
# This file was created by generate_docker_files.py | ||
# | ||
# Usage: docker build -f ./2023.2_openmpi_generic_psmp.Dockerfile -t cp2k/cp2k:2023.2_openmpi_generic_psmp . | ||
|
||
# Stage 1: build step | ||
FROM ubuntu:22.04 AS build | ||
|
||
|
||
# Install packages required for the CP2K toolchain build | ||
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \ | ||
g++ gcc gfortran openssh-client python3 \ | ||
bzip2 ca-certificates git make patch pkg-config unzip wget zlib1g-dev | ||
|
||
# Download CP2K | ||
RUN git clone --recursive -b support/v2023.2 https://github.com/cp2k/cp2k.git /opt/cp2k | ||
|
||
# Build CP2K toolchain for target CPU generic | ||
WORKDIR /opt/cp2k/tools/toolchain | ||
RUN /bin/bash -c -o pipefail \ | ||
"./install_cp2k_toolchain.sh -j 8 \ | ||
--install-all \ | ||
--enable-cuda=no \ | ||
--target-cpu=generic \ | ||
--with-cusolvermp=no \ | ||
--with-gcc=system \ | ||
--with-openmpi=install \ | ||
--with-libtorch=no" | ||
|
||
# Build CP2K for target CPU generic | ||
WORKDIR /opt/cp2k | ||
RUN /bin/bash -c -o pipefail \ | ||
"cp ./tools/toolchain/install/arch/local.psmp ./arch/; \ | ||
source ./tools/toolchain/install/setup; \ | ||
make -j 8 ARCH=local VERSION=psmp" | ||
|
||
# Collect components for installation and remove symbolic links | ||
RUN /bin/bash -c -o pipefail \ | ||
"mkdir -p /toolchain/install /toolchain/scripts; \ | ||
for libdir in \$(ldd ./exe/local/cp2k.psmp | \ | ||
grep /opt/cp2k/tools/toolchain/install | \ | ||
awk '{print \$3}' | cut -d/ -f7 | \ | ||
sort | uniq) setup; do \ | ||
cp -ar /opt/cp2k/tools/toolchain/install/\${libdir} /toolchain/install; \ | ||
done; \ | ||
cp /opt/cp2k/tools/toolchain/scripts/tool_kit.sh /toolchain/scripts; \ | ||
unlink ./exe/local/cp2k.popt; \ | ||
unlink ./exe/local/cp2k_shell.psmp" | ||
|
||
# Stage 2: install step | ||
FROM ubuntu:22.04 AS install | ||
|
||
# Install required packages | ||
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \ | ||
g++ gcc gfortran openssh-client python3 && rm -rf /var/lib/apt/lists/* | ||
|
||
# Install CP2K binaries | ||
COPY --from=build /opt/cp2k/exe/local/ /opt/cp2k/exe/local/ | ||
|
||
# Install CP2K regression tests | ||
COPY --from=build /opt/cp2k/tests/ /opt/cp2k/tests/ | ||
COPY --from=build /opt/cp2k/tools/regtesting/ /opt/cp2k/tools/regtesting/ | ||
COPY --from=build /opt/cp2k/src/grid/sample_tasks/ /opt/cp2k/src/grid/sample_tasks/ | ||
|
||
# Install CP2K database files | ||
COPY --from=build /opt/cp2k/data/ /opt/cp2k/data/ | ||
|
||
# Install shared libraries required by the CP2K binaries | ||
COPY --from=build /toolchain/ /opt/cp2k/tools/toolchain/ | ||
|
||
# Create links to CP2K binaries | ||
RUN /bin/bash -c -o pipefail \ | ||
"for binary in cp2k dumpdcd graph xyz2dcd; do \ | ||
ln -sf /opt/cp2k/exe/local/\${binary}.psmp \ | ||
/usr/local/bin/\${binary}; \ | ||
done; \ | ||
ln -sf /opt/cp2k/exe/local/cp2k.psmp \ | ||
/usr/local/bin/cp2k_shell; \ | ||
ln -sf /opt/cp2k/exe/local/cp2k.psmp \ | ||
/usr/local/bin/cp2k.popt" | ||
|
||
# Create entrypoint script file | ||
RUN printf "#!/bin/bash\n\ | ||
ulimit -c 0 -s unlimited\n\ | ||
\ | ||
export OMPI_ALLOW_RUN_AS_ROOT=1\n\ | ||
export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1\n\ | ||
export OMPI_MCA_btl_vader_single_copy_mechanism=none\n\ | ||
export OMP_STACKSIZE=16M\n\ | ||
export PATH=/opt/cp2k/exe/local:\${PATH}\n\ | ||
source /opt/cp2k/tools/toolchain/install/setup\n\ | ||
\"\$@\"" \ | ||
>/usr/local/bin/entrypoint.sh && chmod 755 /usr/local/bin/entrypoint.sh | ||
|
||
# Create shortcut for regression test | ||
RUN printf "/opt/cp2k/tools/regtesting/do_regtest.py --mpiexec \"mpiexec --bind-to none\" --maxtasks 8 --workbasedir /mnt \$* local psmp" \ | ||
>/usr/local/bin/run_tests && chmod 755 /usr/local/bin/run_tests | ||
|
||
# Define entrypoint | ||
WORKDIR /mnt | ||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] | ||
CMD ["cp2k", "--help"] | ||
|
||
# Label docker image | ||
LABEL author="CP2K Developers" \ | ||
cp2k_version="2023.2" \ | ||
dockerfile_generator_version="0.2" | ||
|
||
# EOF | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
FROM ubuntu:22.04 | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Etc/UTC | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
python3.10 \ | ||
python3.10-venv \ | ||
python3.10-dev \ | ||
build-essential \ | ||
autoconf \ | ||
automake \ | ||
libtool \ | ||
make \ | ||
cmake \ | ||
wget \ | ||
git \ | ||
libopenblas-dev \ | ||
libfftw3-dev \ | ||
libopenmpi-dev \ | ||
openmpi-bin \ | ||
libscalapack-mpi-dev \ | ||
libelpa-dev \ | ||
libomp-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN python3.10 -m venv /opt/venv \ | ||
&& /opt/venv/bin/pip install --upgrade pip | ||
|
||
RUN /bin/bash -c -o pipefail \ | ||
"source /opt/venv/bin/activate && \ | ||
pip install --no-cache-dir numpy && \ | ||
pip install --no-cache-dir git+https://gitlab.com/ase/ase" | ||
|
||
# install libxc | ||
RUN cd /opt && \ | ||
wget https://gitlab.com/libxc/libxc/-/archive/6.2.2/libxc-6.2.2.tar.bz2 -O libxc-6.2.2.tar.bz2 && \ | ||
tar -xvf libxc-6.2.2.tar.bz2 && \ | ||
cd libxc-6.2.2 && \ | ||
autoreconf -i && \ | ||
./configure --prefix=/usr/local CFLAGS="-fPIC" && \ | ||
make -j$(nproc) && \ | ||
make install && \ | ||
ldconfig | ||
|
||
# install GPAW | ||
WORKDIR /opt/gpaw | ||
ENV GPAW_CONFIG=/opt/gpaw/siteconfig.py | ||
RUN echo "scalapack = True" >> siteconfig.py \ | ||
&& echo "fftw = True" >> siteconfig.py \ | ||
&& echo "elpa = True" >> siteconfig.py \ | ||
&& echo "libraries = ['openblas', 'fftw3', 'scalapack-openmpi', 'elpa', 'omp5']" >> siteconfig.py \ | ||
&& echo "library_dirs = ['/usr/lib', '/usr/local/lib']" >> siteconfig.py \ | ||
&& echo "extra_link_args = ['/usr/local/lib/libxc.a']" >> siteconfig.py \ | ||
&& echo "include_dirs = ['/usr/include', '/usr/local/include', '/usr/include/elpa']" >> siteconfig.py | ||
RUN /bin/bash -c -o pipefail "source /opt/venv/bin/activate && pip install --no-cache-dir gpaw dftd3" | ||
RUN mkdir /opt/gpaw-data | ||
RUN /bin/bash -c -o pipefail "source /opt/venv/bin/activate && yes | gpaw install-data /opt/gpaw-data" || true | ||
|
||
ARG PSIFLOW_VERSION | ||
RUN /bin/bash -c -o pipefail \ | ||
"source /opt/venv/bin/activate && pip install --no-cache-dir git+https://github.com/molmod/psiflow.git@${PSIFLOW_VERSION}" | ||
RUN ln -s /opt/venv/lib/python3.10/site-packages/psiflow/reference/gpaw_.py /opt/run_gpaw.py | ||
|
||
# Create entrypoint script | ||
RUN echo '#!/bin/bash' >> /opt/entry.sh && \ | ||
echo 'source /opt/venv/bin/activate' >> /opt/entry.sh && \ | ||
echo 'export LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"' >> /opt/entry.sh && \ | ||
echo 'export GPAW_SETUP_PATH="/opt/gpaw-data/gpaw-setups-24.1.0"' >> /opt/entry.sh && \ | ||
echo '"$@"' >> /opt/entry.sh | ||
RUN chmod +x /opt/entry.sh | ||
|
||
# libxc needed at runtime | ||
ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}" | ||
ENTRYPOINT ["/opt/entry.sh"] | ||
|
||
|
||
# Default command | ||
CMD ["bash"] |
Oops, something went wrong.