Skip to content

Instantly share code, notes, and snippets.

@lukoshkin
Last active May 7, 2024 00:41
Show Gist options
  • Save lukoshkin/034dc718fdf2baff5ab216e487bbd831 to your computer and use it in GitHub Desktop.
Save lukoshkin/034dc718fdf2baff5ab216e487bbd831 to your computer and use it in GitHub Desktop.
Recipe of a docker image with Open-MPI 3.1.4 and mpi4py
FROM ubuntu:18.04
ENV USER mpitest
ENV HOME /home/$USER
ENV MPI_DIR=/opt/ompi
ENV PATH="$MPI_DIR/bin:$HOME/.local/bin:$PATH"
ENV LD_LIBRARY_PATH="$MPI_DIR/lib:$LD_LIBRARY_PATH"
WORKDIR $HOME
RUN apt-get -q update \
&& apt-get install -y \
python3 python3-dev python3-pip \
gcc gfortran binutils \
&& pip3 install --upgrade pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
ADD https://download.open-mpi.org/release/open-mpi/v3.1/openmpi-3.1.4.tar.bz2 .
RUN tar xf openmpi-3.1.4.tar.bz2 \
&& cd openmpi-3.1.4 \
&& ./configure --prefix=$MPI_DIR \
&& make -j4 all \
&& make install \
&& cd .. && rm -rf \
openmpi-3.1.4 openmpi-3.1.4.tar.bz2 /tmp/*
RUN groupadd -r mpitest \
&& useradd -r -g mpitest $USER \
&& chown -R mpitest:mpitest $HOME
USER $USER
RUN pip3 install --user -U setuptools \
&& pip3 install --user mpi4py
@omsrisagar
Copy link

Thank you, it helped a lot. I was not able to install open-mpi on docker using other approaches like installing libopenmpi-dev & openmpi-bin or mpich equivalents libmpich-dev & mpich. Your approach of installing from sources worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment