diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..b5d7153 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,53 @@ +FROM doduo1.umcn.nl/uokbaseimage/base:tf2.10-pt1.12 + +USER root +WORKDIR /home/user/ + +# install pyvips +RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub + +# download & unpack vips +RUN wget -q https://github.com/libvips/libvips/releases/download/v8.13.0/vips-8.13.0.tar.gz && \ + sudo -S apt-get update && \ + sudo -S apt-get install -y libjpeg-turbo8-dev && \ + sudo -S apt-get install -y libgtk2.0-dev && \ + sudo -S apt-get install -y libgsf-1-dev && \ + sudo -S apt-get install -y libtiff5-dev && \ + sudo -S apt-get install -y libopenslide-dev && \ + tar xf vips-8.13.0.tar.gz > /dev/null 2>&1 + +# sepcify workdir +WORKDIR /home/user/vips-8.13.0/ + +# make and install vips +RUN ./configure && \ + make && \ + sudo -S make install && \ + cd .. && \ + sudo -S ldconfig && \ + sudo -S pip3.9 install pyvips + +WORKDIR /home/user/ +RUN rm vips-8.13.0.tar.gz + +# install ASAP +COPY ASAP*.deb . +RUN apt-get update && \ + apt-get install --assume-yes /home/user/ASAP-2.1-Ubuntu2004.deb && \ + ldconfig && \ + SITE_PACKAGES=`python3 -c "import sysconfig; print(sysconfig.get_paths()['purelib'])"` && \ + printf "/opt/ASAP/bin/\n" > "${SITE_PACKAGES}/asap.pth" && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN rm ASAP*.deb + +USER user + +# clone dino repo and install requirements +RUN git clone https://github.com/computationalpathologygroup/dino.git +RUN pip3 install -r dino/requirements.txt` + +#### Configure entrypoint +COPY run.sh . +ENTRYPOINT ["/bin/bash", "/home/user/run.sh"] \ No newline at end of file diff --git a/docker/requirements.txt b/docker/requirements.txt deleted file mode 100644 index 79f84ab..0000000 --- a/docker/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -numpy -pandas -pillow -gdown -einops -matplotlib -torch -torchvision -tqdm -hydra-core==1.2.0 -opencv-python==4.4.0.46 \ No newline at end of file diff --git a/docker/run.sh b/docker/run.sh new file mode 100644 index 0000000..489f47f --- /dev/null +++ b/docker/run.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +#help +display_help() +{ + echo "DINO by @clementgrisi" + echo + echo "Syntax: docker run dino [-p level] [-c filename] [-w wandb_api_key]" + echo "options:" + echo "-p starts self-supervised pre-training at given level (can be either 'patch' or 'region')" + echo "-c specify config filename" + echo "-w specify wandb API key" + echo +} + +#main +while getopts ":t:p:c:h" opt; do + case $opt in + h) + display_help + exit 1 + ;; + p) + level="$OPTARG" + ;; + c) + config="$OPTARG" + ;; + w) + key="$OPTARG" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + exit 1 + ;; + esac +done + +if [[ -n $key ]]; then + export WANDB_API_KEY=$key +fi + +if [[ -n $level ]]; then + case $level in + patch) + python3 -m torch.distributed.run --standalone --nproc_per_node=gpu dino/patch.py --config-name "$config" + ;; + region) + python3 -m torch.distributed.run --standalone --nproc_per_node=gpu dino/region.py --config-name "$config" + ;; + *) + echo "Invalid level option. Please use 'patch' or 'region'" + esac +else + echo "No flag specified. Please use -p flag." +fi \ No newline at end of file