Skip to content

Commit

Permalink
Simplified first run process + docs [needs test]
Browse files Browse the repository at this point in the history
  • Loading branch information
surajpaib committed Aug 29, 2021
1 parent 5ca0379 commit 84e4dea
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 100 deletions.
26 changes: 12 additions & 14 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
ARG CUDA="10.2"
ARG CUDNN="7"

# TODO: conda installs its own version of cuda
FROM nvidia/cuda:${CUDA}-cudnn${CUDNN}-devel-ubuntu18.04
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04

ENV CUDA_PATH /usr/local/cuda
ENV CUDA_ROOT /usr/local/cuda/bin
Expand Down Expand Up @@ -38,26 +34,28 @@ ENV PATH "/home/runner/miniconda3/bin:$PATH:$CUDA_ROOT"
RUN conda update -n base conda -yq
RUN conda install python=3.8
RUN conda install numpy pyyaml mkl mkl-include setuptools cmake cffi typing boost
RUN conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
RUN conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
RUN conda install scipy pandas scikit-learn scikit-image -yq
RUN conda install cython tqdm jupyter sqlalchemy -yq

RUN git clone https://github.com/NVIDIA/apex \
&& cd apex \
&& pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./ \
&& cd ..

RUN python -m pip install opencv-python simpleitk h5py -q
RUN python -m pip install tb-nightly wandb -q
RUN python -m pip install monai memcnn -q
RUN python -m pip install omegaconf loguru -q


USER root

# Create runner for input and output
RUN mkdir /runner && chmod 777 /runner
RUN mkdir /runner/ganslate && chmod 777 /runner/ganslate
RUN mkdir /runner/datasets && chmod 777 /runner/datasets
# Create folders for input and output
RUN mkdir /ganslate && chmod 777 /ganslate
RUN mkdir /data && chmod 777 /data
USER runner

# Copy files into the docker
COPY [".", "/runner"]

WORKDIR /runner
WORKDIR /ganslate

ENTRYPOINT $0 $@
30 changes: 21 additions & 9 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,47 @@
# Installation

You can begin the install by cloning the repo,
```
git clone https://github.com/Maastro-CDS-Imaging-Group/ganslate.git
```

Once the repo is fetched, you can either use a docker-based install or a conda-based install on your local system.

!!! note
You can get to the repository root level after cloning,
```
cd ganslate
```


## Docker
*Supported operating systems: Linux, [Windows with WSL](https://docs.nvidia.com/cuda/wsl-user-guide/index.html)*

Dockerized setup is the easiest way to get started with the framework. If you do not have docker installed, you can follow instructions [here](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)


Here is a step-by-step walkthrough of how to install the framework with docker,

1. The docker image can be built using,
First, you can build the docker image by running the following commands at the repository root level

```console
cd docker/
docker build -t ganslate:latest .
```

2. Once the docker image is built, it can be run using,
Once the docker image is built, it can be run using,

```console
docker run --gpus all -it \
--shm-size=24gb --volume=<data_dir>:/data --volume=<code_dir>:/code \
--shm-size=24gb --volume=<data_dir>:/data --volume=<repo_dir>:/ganslate \
--name=ganslate ganslate:latest /bin/bash
```



The docker container [mounts volumes from the host system](https://docs.docker.com/storage/volumes/) to allow easier persistence of data.

`<data_dir>` must be replaced with the full path of a directory where your data is located. It can also point to an empty directory during setup (Data can be moved into this directory later as docker mounts the directory to the container).
`<data_dir>` must be replaced with the full path of a directory where your data is located.
`<repo_dir>` must be replaced with the path to the `ganslate` repository was cloned.

`<code_dir>` must be replaced with the path to the `ganslate` repository.
!!! note
`<data_dir>` can initially point to an empty directory to simplify setup. Data can be moved into this directory later as docker mounts the directory to the container.

## Conda

Expand Down
24 changes: 10 additions & 14 deletions docs/tutorials/horse2zebra.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
# Your First Run (horse2zebra)


## For Docker Install
If you haven't already, please follow the installation using [Docker](../installation.md#docker)


For both types of install, running the basic horse2zebra example is similar.
#### Data download
The horse2zebra dataset can be downloaded to the `<data_dir>` in the host system using instructions below,
The horse2zebra dataset can be downloaded using instructions below,
1. Open a terminal inside the cloned repository and run,

```console
cd projects/horse2zebra
bash download_cyclegan_dataset.sh horse2zebra <data_dir>
bash download_cyclegan_dataset.sh horse2zebra .
```

### Training
Next, the following commands are to be run in the docker container shell

![docker_commands](../imgs/your_first_run_docker.png)
!!! note
The horse2zebra dataset will be downloaded at the root-level of the ganslate directory. This can be changed by providing a <data_dir> to the command `bash download_cyclegan_dataset.sh horse2zebra <data_dir>. However, the yaml files need to be manually changed. For non-advanced users, it is best to stick to the default location

Run the training using,
### Training
Next, you can run the training using the command below,

```console
cd /code
python tools/train.py config=projects/horse2zebra/experiments/default_docker.yaml
python tools/train.py config=projects/horse2zebra/experiments/default.yaml
```

NOTE: If you have more than one GPU, then you can either run the training in distributed mode or [set CUDA_VISIBLE_DEVICES environment variable](https://developer.nvidia.com/blog/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/) to use only single GPUs.
!!! note
If you have more than one GPU, then you can either run the training in distributed mode or [set CUDA_VISIBLE_DEVICES environment variable](https://developer.nvidia.com/blog/cuda-pro-tip-control-gpu-visibility-cuda_visible_devices/) to use only single GPUs.
63 changes: 0 additions & 63 deletions projects/horse2zebra/experiments/default_docker.yaml

This file was deleted.

0 comments on commit 84e4dea

Please sign in to comment.