diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000000..2351104d47d4 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,24 @@ +# Docker for users + +We provide Dockerfiles in order to build containerized execution environment that ease the use of Ignite for computer vision and NLP tasks. + +## Installation + +- [main/Dockerfile.base](main/Dockerfile.base): latest stable PyTorch, Ignite with minimal dependencies + * `docker pull pytorchignite/base:latest` +- [main/Dockerfile.vision](main/Dockerfile.vision): base image with useful computer vision libraries + * `docker pull pytorchignite/vision:latest` +- [main/Dockerfile.nlp](main/Dockerfile.nlp): base image with useful NLP libraries + * `docker pull pytorchignite/nlp:latest` +- [main/Dockerfile.apex](main/Dockerfile.apex): multi-stage NVIDIA/apex build with latest Pytorch, Ignite image with minimal dependencies + * `docker pull pytorchignite/apex:latest` +- [main/Dockerfile.apex-vision](main/Dockerfile.nlp): base apex with useful computer vision libraries + * `docker pull pytorchignite/apex-vision:latest` +- [main/Dockerfile.apex-nlp](main/Dockerfile.nlp): base apex with useful NLP libraries + * `docker pull pytorchignite/apex-nlp:latest` + +## How to use + +```bash +docker run --rm -it -v $PWD:/workspace/project --network=host --shm-size 16G pytorchignite/base:latest +``` diff --git a/docker/main/Dockerfile.apex b/docker/main/Dockerfile.apex new file mode 100644 index 000000000000..4b55c4b5db62 --- /dev/null +++ b/docker/main/Dockerfile.apex @@ -0,0 +1,49 @@ +# Multi-stage build +# 1/Building apex with pytorch:1.6.0-cuda10.1-cudnn7-devel +FROM pytorch/pytorch:1.6.0-cuda10.1-cudnn7-devel AS apex-builder + +ARG ARG_TORCH_CUDA_ARCH_LIST="6.0;6.1;6.2;7.0;7.5" +ENV TORCH_CUDA_ARCH_LIST=$ARG_TORCH_CUDA_ARCH_LIST + +# Install git +RUN apt-get update && apt-get install -y --no-install-recommends git && \ + rm -rf /var/lib/apt/lists/* + +# Build apex +RUN echo "Setup NVIDIA Apex" && \ + tmp_apex_path="/tmp/apex" && \ + rm -rf $tmp_apex_path && \ + git clone https://github.com/NVIDIA/apex $tmp_apex_path && \ + cd $tmp_apex_path && \ + pip wheel --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" . + +# 2/ Build the runtime image +FROM pytorch/pytorch:latest + +COPY --from=apex-builder /tmp/apex/apex-0.1-cp37-cp37m-linux_x86_64.whl apex-0.1-cp37-cp37m-linux_x86_64.whl +RUN pip install --no-cache-dir apex-0.1-cp37-cp37m-linux_x86_64.whl && \ + rm apex-0.1-cp37-cp37m-linux_x86_64.whl + +# Install tzdata / git +RUN apt-get update && \ + ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ + apt-get install -y tzdata && \ + dpkg-reconfigure --frontend noninteractive tzdata && \ + apt-get -y install --no-install-recommends git && \ + rm -rf /var/lib/apt/lists/* + +# Ignite main dependencies +RUN pip install --upgrade --no-cache-dir pytorch-ignite \ + tensorboard \ + tqdm + +# Checkout Ignite examples only +RUN mkdir -p pytorch-ignite-examples && \ + cd pytorch-ignite-examples && \ + git init && \ + git config core.sparsecheckout true && \ + echo examples >> .git/info/sparse-checkout && \ + git remote add -f origin https://github.com/pytorch/ignite.git && \ + git pull origin master + +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/docker/main/Dockerfile.apex-nlp b/docker/main/Dockerfile.apex-nlp new file mode 100644 index 000000000000..02340e60d889 --- /dev/null +++ b/docker/main/Dockerfile.apex-nlp @@ -0,0 +1,10 @@ +# Dockerfile.apex-nlp +FROM pytorchignite/apex + +# Ignite NLP dependencies +RUN pip install --upgrade --no-cache-dir torchtext \ + transformers \ + spacy \ + nltk + +ENTRYPOINT ["/bin/bash"] diff --git a/docker/main/Dockerfile.apex-vision b/docker/main/Dockerfile.apex-vision new file mode 100644 index 000000000000..637b149b10ac --- /dev/null +++ b/docker/main/Dockerfile.apex-vision @@ -0,0 +1,21 @@ +# Dockerfile.apex-vision +FROM pytorchignite/apex + +# Install opencv dependencies +RUN apt-get update && \ + apt-get -y install --no-install-recommends libglib2.0 \ + libsm6 \ + libxext6 \ + libxrender-dev && \ + rm -rf /var/lib/apt/lists/* + +# Ignite vision dependencies +RUN pip install --upgrade --no-cache-dir albumentations \ + image-dataset-viz \ + numpy \ + opencv-python \ + py_config_runner \ + pillow \ + "trains>=0.15.0" + +ENTRYPOINT ["/bin/bash"] diff --git a/docker/main/Dockerfile.base b/docker/main/Dockerfile.base new file mode 100644 index 000000000000..758c3a27aee8 --- /dev/null +++ b/docker/main/Dockerfile.base @@ -0,0 +1,25 @@ +# Dockerfile.base +FROM pytorch/pytorch:latest + +# Install tzdata / git +RUN apt-get update && \ + ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ + apt-get install -y tzdata && \ + dpkg-reconfigure --frontend noninteractive tzdata && \ + apt-get -y install --no-install-recommends git && \ + rm -rf /var/lib/apt/lists/* + +# Ignite main dependencies +RUN pip install --upgrade --no-cache-dir pytorch-ignite \ + tensorboard \ + tqdm +# Checkout Ignite examples only +RUN mkdir -p pytorch-ignite-examples && \ + cd pytorch-ignite-examples && \ + git init && \ + git config core.sparsecheckout true && \ + echo examples >> .git/info/sparse-checkout && \ + git remote add -f origin https://github.com/pytorch/ignite.git && \ + git pull origin master + +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/docker/main/Dockerfile.nlp b/docker/main/Dockerfile.nlp new file mode 100644 index 000000000000..eabf299ae5cc --- /dev/null +++ b/docker/main/Dockerfile.nlp @@ -0,0 +1,10 @@ +# Dockerfile.nlp +FROM pytorchignite/base:latest + +# Ignite NLP dependencies +RUN pip install --upgrade --no-cache-dir torchtext \ + transformers \ + spacy \ + nltk + +ENTRYPOINT ["/bin/bash"] \ No newline at end of file diff --git a/docker/main/Dockerfile.vision b/docker/main/Dockerfile.vision new file mode 100644 index 000000000000..65131c087c12 --- /dev/null +++ b/docker/main/Dockerfile.vision @@ -0,0 +1,21 @@ +# Dockerfile.vision +FROM pytorchignite/base:latest + +# Install opencv dependencies +RUN apt-get update && \ + apt-get -y install --no-install-recommends libglib2.0 \ + libsm6 \ + libxext6 \ + libxrender-dev && \ + rm -rf /var/lib/apt/lists/* + +# Ignite vision dependencies +RUN pip install --upgrade --no-cache-dir albumentations \ + image-dataset-viz \ + numpy \ + opencv-python \ + py_config_runner \ + pillow \ + "trains>=0.15.0" + +ENTRYPOINT ["/bin/bash"] \ No newline at end of file