Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Containerization support #12

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 2d_cnn/deploy_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

srcdir=$(dirname ${BASH_SOURCE[0]})
config_file=$1
cp "${srcdir}/config.yaml" $(pwd)/"${config_file}"
23 changes: 23 additions & 0 deletions 2d_cnn/deploy_local_2D_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

srcdir=$(dirname ${BASH_SOURCE[0]})
config_file=$1
export CUDA_VISIBLE_DEVICES=
for i in $(seq 1 1 $(nvidia-smi --list-gpus | wc -l))
do
if [ $i -eq 1 ]
then
export CUDA_VISIBLE_DEVICES=$(expr $i - 1)
else
export CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES,$(expr $i - 1)
fi
done
echo $CUDA_VISIBLE_DEVICES

snakemake \
--snakefile "${srcdir}/snakefile.py" \
--config config="${config_file}" \
--forceall \
--printshellcmds \
--cores $(nvidia-smi --list-gpus | wc -l) \
--resources gpu=$(nvidia-smi --list-gpus | wc -l)
5 changes: 5 additions & 0 deletions 3d_cnn/deploy_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

srcdir=$(dirname ${BASH_SOURCE[0]})
config_file=$1
cp "${srcdir}/config.yaml" $(pwd)/"${config_file}"
24 changes: 24 additions & 0 deletions 3d_cnn/deploy_local_3D_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

export srcdir="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
config_file=$1
export CUDA_VISIBLE_DEVICES=
for i in $(seq 1 1 $(nvidia-smi --list-gpus | wc -l))
do
if [ $i -eq 1 ]
then
export CUDA_VISIBLE_DEVICES=$(expr $i - 1)
else
export CUDA_VISIBLE_DEVICES=$CUDA_VISIBLE_DEVICES,$(expr $i - 1)
fi
done
echo $CUDA_VISIBLE_DEVICES
export PYTHONPATH=${srcdir}/src
echo PYTHONPATH=$PYTHONPATH

snakemake \
--snakefile "${srcdir}/snakefile" \
--config config="${config_file}" gpu=$CUDA_VISIBLE_DEVICES \
--printshellcmds \
--cores $(nvidia-smi --list-gpus | wc -l) \
--resources gpu=$(nvidia-smi --list-gpus | wc -l)
19 changes: 11 additions & 8 deletions 3d_cnn/environment.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
name: 3d-unet
channels:
- pytorch
- bioconda
- anaconda
- conda-forge
- anaconda
- default
dependencies:
- python=3.7
- jupyter
- imageio
- pytorch
- torchvision
- scikit-learn
- scikit-image
- scipy
- numpy
- tensorboardX
- tqdm
- pandas
- pyaml
- pip
- pip:
- h5py==2.10.0
- mrcfile==1.1.2
- monai
- h5py==2.10.0
- mrcfile==1.1.2
- monai
- pytorch==1.12.1
- torchvision==0.13.1
- cudatoolkit=11.6
- tensorboardx
- crc32c
- snakemake==5.13.0
33 changes: 33 additions & 0 deletions Dockerfile-2d_cnn
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM nvidia/cuda:10.0-devel-ubuntu18.04

COPY DeePiCt /app/DeePiCt
COPY deploy_local_2D_container.sh /app/DeePiCt/2d_cnn
WORKDIR /app/DeePiCt

# Install necessary packages
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update -y && apt-get install -y dialog apt-utils && \
apt-get install -y build-essential git wget software-properties-common && \
apt-get update && rm -rf /var/lib/apt/lists/*

# Install miniconda
ENV PATH="/usr/local/miniconda3/bin:${PATH}"
ARG PATH="/usr/local/miniconda3/bin:${PATH}"
RUN cd /tmp \
&& wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda3.sh\
&& bash Miniconda3.sh -b -p /usr/local/miniconda3 \
&& rm -f Miniconda3.sh


# Create environment
RUN conda init bash && \
conda install -c conda-forge mamba --yes && \
mamba env create -f /app/DeePiCt/2d_cnn/envs/keras-env.yaml

RUN cd 2d_cnn && \
ln -s deploy_local_2D_container.sh deepict2D && \
ln -s deploy_config.sh deepict2D_config

ENV PATH="${PATH}:/app/DeePiCt/2d_cnn"
ARG PATH="${PATH}:/app/DeePiCt/2d_cnn"
35 changes: 35 additions & 0 deletions Dockerfile-3d_cnn
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM nvidia/cuda:11.6.2-devel-ubuntu20.04

COPY DeePiCt /app/DeePiCt
COPY environment.yaml /app/DeePiCt/3d_cnn
COPY deploy_config.sh /app/DeePiCt/3d_cnn
COPY deploy_local_3D_container.sh /app/DeePiCt/3d_cnn
WORKDIR /app/DeePiCt

# Install necessary packages
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update -y && apt-get install -y dialog apt-utils && \
apt-get install -y build-essential git wget software-properties-common && \
apt-get update && rm -rf /var/lib/apt/lists/*

# Install miniconda
ENV PATH="/usr/local/miniconda3/bin:${PATH}"
ARG PATH="/usr/local/miniconda3/bin:${PATH}"
RUN cd /tmp \
&& wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda3.sh\
&& bash Miniconda3.sh -b -p /usr/local/miniconda3 \
&& rm -f Miniconda3.sh


# Create environment
RUN conda init bash && \
conda install -c conda-forge mamba --yes && \
mamba env create -f /app/DeePiCt/3d_cnn/environment.yaml

RUN cd 3d_cnn && \
ln -s deploy_local_3D_container.sh deepict3D && \
ln -s deploy_config.sh deepict3D_config

ENV PATH="${PATH}:/app/DeePiCt/3d_cnn"
ARG PATH="${PATH}:/app/DeePiCt/3d_cnn"