Bootstrap: docker
From: nvidia/cuda:11.4.2-cudnn8-devel-ubuntu18.04
Stage: spython-base

%post

export SINGULARITY_BINDPATH=$SINGULARITY_BINDPATH,$(echo /usr/bin/ | sed -e 's/ /,/g')

MLNX_ARCH=ubuntu18.04-x86_64
MLNX_VERSION=5.2-1.0.4.0

# Python 3.7 is supported by Ubuntu Bionic out of the box
python=3.7
PYTHON_VERSION=${python}

# Set default shell to /bin/bash
#SHELL ["/bin/bash", "-cu"]

TZ="Europe/London"

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
build-essential \
cmake \
g++-7 \
git \
curl \
vim \
wget \
ca-certificates \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
python${PYTHON_VERSION}-distutils \
libpython-stdlib \
python \
udev \
automake \
gfortran \
autotools-dev \
chrpath \
pkg-config \
libnl-3-dev \
tcl \
pciutils \
tk \
libnl-route-3-dev \
libltdl-dev \
bison \
autoconf \
flex \
graphviz \
libssl1.0.0 \
kmod \
debhelper \
libgfortran4 \
ethtool \
swig \
lsof \
libnl-route-3-200 \
m4 \
libnl-3-200 \
dpatch \
libnuma-dev \
iputils-ping \
iproute2 \
apt-utils

ln -sf /usr/bin/python${PYTHON_VERSION} /usr/bin/python

curl -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py

wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-${MLNX_VERSION}/MLNX_OFED_LINUX-${MLNX_VERSION}-${MLNX_ARCH}.tgz && \
tar -xzvf MLNX_OFED_LINUX-${MLNX_VERSION}-${MLNX_ARCH}.tgz --no-same-owner && \
cd  MLNX_OFED_LINUX-${MLNX_VERSION}-${MLNX_ARCH} && \
./mlnxofedinstall --user-space-only --without-fw-update --skip-repo --force && \
cd .. && \
rm -rf MLNX_OFED-LINUX-${MLNX_VERSION}-${MLNX_ARCH} && \
rm -rf *.tgz

# Install Open MPI version 4.1
wget https://www.open-mpi.org/software/ompi/v4.1/downloads/openmpi-4.1.0.tar.gz && \
tar zxf openmpi-4.1.0.tar.gz && \
cd openmpi-4.1.0 && \
./configure --enable-mpirun-prefix-by-default \
            --enable-shared \
            --without-verbs && \
make -j $(nproc) all && \
make install && \
ldconfig && \
rm -rf /tmp/openmpi

cd /
pip --no-cache-dir --disable-pip-version-check install mpi4py

LD_LIBRARY_PATH=/usr/local/lib/:/usr/local/lib/openmpi:$LD_LIBRARY_PATH

%environment

%runscript
