2020-10-02 09:26:21 +00:00
|
|
|
# Copyright The PyTorch Lightning team.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2020-07-31 12:23:13 +00:00
|
|
|
# Existing images:
|
2020-10-26 10:47:09 +00:00
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.7 --build-arg CUDA_VERSION=10.2
|
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.6 --build-arg CUDA_VERSION=10.2
|
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.5 --build-arg CUDA_VERSION=10.2
|
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.4 --build-arg CUDA_VERSION=10.1
|
2020-09-17 18:30:39 +00:00
|
|
|
|
2020-10-26 10:47:09 +00:00
|
|
|
ARG CUDNN_VERSION=8
|
|
|
|
ARG CUDA_VERSION=10.2
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2020-10-06 03:18:14 +00:00
|
|
|
# FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu20.04
|
2020-10-26 10:47:09 +00:00
|
|
|
FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-devel-ubuntu18.04
|
2020-10-06 03:18:14 +00:00
|
|
|
# FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu18.04
|
2020-09-17 18:30:39 +00:00
|
|
|
|
|
|
|
ARG PYTHON_VERSION=3.7
|
|
|
|
ARG PYTORCH_VERSION=1.6
|
2020-11-09 14:48:24 +00:00
|
|
|
ARG CMAKE_VERSION=3.18.4
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2020-08-02 12:14:53 +00:00
|
|
|
SHELL ["/bin/bash", "-c"]
|
2020-10-26 10:47:09 +00:00
|
|
|
# https://techoverflow.net/2019/05/18/how-to-fix-configuring-tzdata-interactive-input-when-building-docker-images/
|
2021-01-29 12:27:18 +00:00
|
|
|
ENV \
|
|
|
|
DEBIAN_FRONTEND=noninteractive \
|
|
|
|
TZ=Europe/Prague \
|
|
|
|
PATH="$PATH:/root/.local/bin" \
|
|
|
|
CUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda"
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2020-11-09 14:48:24 +00:00
|
|
|
RUN apt-get update -qq && \
|
2020-10-26 10:47:09 +00:00
|
|
|
apt-get install -y --no-install-recommends \
|
2020-09-22 23:41:35 +00:00
|
|
|
build-essential \
|
2020-10-26 10:47:09 +00:00
|
|
|
pkg-config \
|
2020-09-22 23:41:35 +00:00
|
|
|
cmake \
|
|
|
|
git \
|
2020-10-26 10:47:09 +00:00
|
|
|
wget \
|
2021-01-08 15:36:49 +00:00
|
|
|
curl \
|
|
|
|
unzip \
|
2020-09-22 23:41:35 +00:00
|
|
|
ca-certificates \
|
2020-10-26 10:47:09 +00:00
|
|
|
software-properties-common \
|
|
|
|
&& \
|
|
|
|
|
|
|
|
# Install python
|
|
|
|
add-apt-repository ppa:deadsnakes/ppa && \
|
|
|
|
apt-get install -y \
|
|
|
|
python${PYTHON_VERSION} \
|
|
|
|
python${PYTHON_VERSION}-distutils \
|
|
|
|
python${PYTHON_VERSION}-dev \
|
2020-08-02 12:14:53 +00:00
|
|
|
&& \
|
2020-10-26 10:47:09 +00:00
|
|
|
|
|
|
|
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
|
|
|
|
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1 && \
|
|
|
|
|
2020-09-30 12:33:22 +00:00
|
|
|
# Cleaning
|
2020-08-02 12:14:53 +00:00
|
|
|
apt-get autoremove -y && \
|
|
|
|
apt-get clean && \
|
|
|
|
rm -rf /root/.cache && \
|
2020-09-17 18:30:39 +00:00
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2021-01-29 12:27:18 +00:00
|
|
|
ENV \
|
|
|
|
HOROVOD_GPU_OPERATIONS=NCCL \
|
|
|
|
HOROVOD_WITH_PYTORCH=1 \
|
|
|
|
HOROVOD_WITHOUT_TENSORFLOW=1 \
|
|
|
|
HOROVOD_WITHOUT_MXNET=1 \
|
|
|
|
HOROVOD_WITH_GLOO=1 \
|
|
|
|
HOROVOD_WITHOUT_MPI=1 \
|
|
|
|
# MAKEFLAGS="-j$(nproc)" \
|
|
|
|
MAKEFLAGS="-j1" \
|
|
|
|
TORCH_CUDA_ARCH_LIST="3.7;5.0;6.0;7.0;7.5"
|
2020-09-26 17:30:25 +00:00
|
|
|
|
2020-10-26 10:47:09 +00:00
|
|
|
COPY ./requirements.txt requirements.txt
|
|
|
|
COPY ./requirements/ ./requirements/
|
2020-09-22 23:41:35 +00:00
|
|
|
|
2020-09-17 18:30:39 +00:00
|
|
|
# conda init
|
|
|
|
RUN \
|
2020-10-26 10:47:09 +00:00
|
|
|
wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate && \
|
|
|
|
python${PYTHON_VERSION} get-pip.py && \
|
|
|
|
rm get-pip.py && \
|
|
|
|
|
2020-09-30 12:33:22 +00:00
|
|
|
# Disable cache
|
|
|
|
pip config set global.cache-dir false && \
|
2020-10-26 10:47:09 +00:00
|
|
|
# eventualy use pre-release
|
|
|
|
#pip install "torch==${PYTORCH_VERSION}.*" --pre && \
|
|
|
|
# set particular PyTorch version
|
|
|
|
python -c "import re ; fname = 'requirements.txt' ; req = re.sub(r'torch[>=]+[\d\.]+', 'torch==${PYTORCH_VERSION}.*', open(fname).read()) ; open(fname, 'w').write(req)" && \
|
|
|
|
# Install all requirements
|
2020-11-12 14:03:43 +00:00
|
|
|
# todo: find a way how to install nightly PT version
|
|
|
|
# --pre --extra-index-url https://download.pytorch.org/whl/nightly/cu${cuda_ver[0]}${cuda_ver[1]}/torch_nightly.html
|
2021-01-25 22:10:56 +00:00
|
|
|
pip install -r requirements/devel.txt --no-cache-dir && \
|
2020-10-26 10:47:09 +00:00
|
|
|
rm -rf requirements*
|
|
|
|
|
2020-11-12 14:03:43 +00:00
|
|
|
RUN \
|
|
|
|
# install DALI, needed for examples
|
|
|
|
pip install --extra-index-url https://developer.download.nvidia.com/compute/redist nvidia-dali-cuda${CUDA_VERSION%%.*}0
|
|
|
|
|
2020-10-26 10:47:09 +00:00
|
|
|
RUN \
|
2020-10-02 09:26:21 +00:00
|
|
|
# install NVIDIA AMP
|
|
|
|
git clone https://github.com/NVIDIA/apex && \
|
2020-10-26 10:47:09 +00:00
|
|
|
pip install --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./apex && \
|
|
|
|
rm -rf apex
|
2020-09-30 12:33:22 +00:00
|
|
|
|
|
|
|
RUN \
|
2020-09-17 18:30:39 +00:00
|
|
|
# Show what we have
|
2020-08-15 19:39:44 +00:00
|
|
|
pip --version && \
|
2020-09-30 12:33:22 +00:00
|
|
|
pip list && \
|
2020-11-09 14:48:24 +00:00
|
|
|
python -c 'from nvidia.dali.pipeline import Pipeline' && \
|
2020-10-02 09:26:21 +00:00
|
|
|
python -c "import sys; assert sys.version[:3] == '$PYTHON_VERSION', sys.version" && \
|
2020-11-09 14:48:24 +00:00
|
|
|
python -c "import torch; assert torch.__version__[:3] == '$PYTORCH_VERSION', torch.__version__"
|