Created
May 31, 2021 01:42
-
-
Save russellsmithies/f91a5f62f9219447a147dab7357a3188 to your computer and use it in GitHub Desktop.
ont-bonito Singularity definition
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
BootStrap: docker | |
From: nvidia/cuda:11.2.0-cudnn8-devel-ubuntu20.04 | |
%post | |
export LC_ALL=C.UTF-8 | |
export LANG=C.UTF-8 | |
echo 'export LC_ALL=C.UTF-8' >> $SINGULARITY_ROOTFS/$SINGULARITY_ENVIRONMENT | |
echo 'export LANG=C.UTF-8' >> $SINGULARITY_ROOTFS/$SINGULARITY_ENVIRONMENT | |
export MAKEFLAGS="-j 8 " | |
### Avoid useless deb packages | |
echo 'APT::Install-Recommends "0";' > /etc/apt/apt.conf.d/10norecommends | |
echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/10norecommends | |
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections | |
apt update | |
apt install -y nano wget build-essential git autoconf automake build-essential \ | |
bzip2 ca-certificates libglib2.0-dev libxext6 libsm6 libxrender1 libhdf5-dev | |
# install miniconda | |
CONDA_DIR=/opt/conda | |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /miniconda.sh | |
sh /miniconda.sh -b -p $CONDA_DIR | |
rm /miniconda.sh | |
# make non-activate conda commands available | |
export PATH=$CONDA_DIR/bin:$PATH | |
conda update -n base -c defaults conda | |
APP=ont-bonito | |
VER=0.3.8 | |
ENV_NAME=${APP}_${VER}_singularity | |
ENV_BIN_DIR=$CONDA_DIR/envs/$ENV_NAME/bin | |
conda create --no-default-packages --name $ENV_NAME | |
conda install --name $ENV_NAME numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses fastrlock | |
conda install --name $ENV_NAME -c pytorch magma-cuda112 | |
conda install --name $ENV_NAME -c conda-forge cudatoolkit=11.2.2 | |
conda install --name $ENV_NAME -c intel cython | |
export PATH=$ENV_BIN_DIR:$PATH | |
# build cupy from src, otherwise install cupy-cuda112 | |
cd / | |
git clone --recursive https://github.com/cupy/cupy.git | |
cd cupy | |
$ENV_BIN_DIR/python setup.py install | |
# build seqdist with new cupy | |
cd / | |
git clone https://github.com/davidcpage/seqdist.git | |
cd seqdist | |
perl -npi -e 's/cupy-cuda102/cupy/' settings.ini | |
$ENV_BIN_DIR/python setup.py install | |
cd / | |
# build pytorch for CUDA 11.2, takes about 80 minutes :-( | |
git clone --recursive https://github.com/pytorch/pytorch | |
cd pytorch | |
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"} | |
$ENV_BIN_DIR/python setup.py install | |
# build ont-bonito with our new versions for CUDA 11.2 | |
cd / | |
git clone -b v${VER} https://github.com/nanoporetech/bonito.git | |
cd bonito | |
# remove these requirements as we already have them installed with good versions | |
perl -npi -e 's/torch==1.8.0//' requirements.txt | |
perl -npi -e 's/seqdist==0.0.3//' requirements.txt | |
perl -npi -e 's/numpy<=1.18.5//' requirements.txt | |
$ENV_BIN_DIR/pip3 install -r requirements.txt | |
$ENV_BIN_DIR/python setup.py install | |
# cleanup src dirs | |
cd / | |
rm -rf /cupy | |
rm -rf /seqdist | |
rm -rf /pytorch | |
# Finally have a cleanup of conda to save space in the containerq | |
conda clean -afy \ | |
&& find /opt/conda/ -follow -type f -name '*.a' -delete \ | |
&& find /opt/conda/ -follow -type f -name '*.pyc' -delete \ | |
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete | |
# And set the env to auto-start when you exec a command | |
mkdir -p $SINGULARITY_ROOTFS/.singularity.d/env | |
echo "source /opt/conda/etc/profile.d/conda.sh" >> $SINGULARITY_ROOTFS/$SINGULARITY_ENVIRONMENT | |
echo "conda activate $ENV_NAME" >> $SINGULARITY_ROOTFS/$SINGULARITY_ENVIRONMENT | |
%environment | |
%runscript | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment