2020-07-31 12:23:13 +00:00
|
|
|
# Existing images:
|
2020-09-17 18:30:39 +00:00
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.7 --build-arg PYTORCH_CHANNEL=pytorch-nightly --build-arg CUDA_VERSION=10.1
|
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.6 --build-arg PYTORCH_CHANNEL=pytorch --build-arg CUDA_VERSION=10.1
|
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.5 --build-arg PYTORCH_CHANNEL=pytorch --build-arg CUDA_VERSION=10.1
|
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.4 --build-arg PYTORCH_CHANNEL=pytorch --build-arg CUDA_VERSION=10.1
|
|
|
|
# --build-arg PYTHON_VERSION=3.7 --build-arg PYTORCH_VERSION=1.3 --build-arg PYTORCH_CHANNEL=pytorch --build-arg CUDA_VERSION=10.1
|
|
|
|
|
2020-07-31 12:23:13 +00:00
|
|
|
ARG CUDNN_VERSION=7
|
2020-09-17 18:30:39 +00:00
|
|
|
ARG CUDA_VERSION=10.1
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2020-09-17 18:30:39 +00:00
|
|
|
FROM nvidia/cuda:${CUDA_VERSION}-cudnn${CUDNN_VERSION}-devel
|
2020-09-22 23:41:35 +00:00
|
|
|
# FROM nvidia/cuda:${CUDA_VERSION}-devel
|
2020-09-17 18:30:39 +00:00
|
|
|
|
|
|
|
ARG PYTHON_VERSION=3.7
|
|
|
|
ARG PYTORCH_VERSION=1.6
|
|
|
|
ARG PYTORCH_CHANNEL=pytorch
|
|
|
|
ARG CONDA_VERSION=4.7.12
|
2020-07-31 12:23:13 +00:00
|
|
|
|
2020-08-02 12:14:53 +00:00
|
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
|
2020-07-31 12:23:13 +00:00
|
|
|
ENV PATH="$PATH:/root/.local/bin"
|
|
|
|
|
2020-09-17 18:30:39 +00:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
2020-09-22 23:41:35 +00:00
|
|
|
build-essential \
|
|
|
|
cmake \
|
|
|
|
git \
|
|
|
|
curl \
|
|
|
|
ca-certificates \
|
2020-08-02 12:14:53 +00:00
|
|
|
&& \
|
2020-09-17 18:30:39 +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/*
|
|
|
|
|
|
|
|
# add non-root user
|
|
|
|
RUN useradd --create-home --shell /bin/bash flash
|
2020-08-02 12:14:53 +00:00
|
|
|
|
2020-09-17 18:30:39 +00:00
|
|
|
USER flash
|
|
|
|
ENV CONDA_ENV=lightning
|
|
|
|
ENV WORKDIR=/home/flash
|
|
|
|
WORKDIR $WORKDIR
|
|
|
|
|
|
|
|
COPY --chown=flash environment.yml environment.yml
|
|
|
|
|
|
|
|
# install conda and python
|
|
|
|
RUN curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh && \
|
|
|
|
chmod +x ~/miniconda.sh && \
|
|
|
|
~/miniconda.sh -b -p ${WORKDIR}/miniconda && \
|
|
|
|
rm ~/miniconda.sh
|
|
|
|
|
|
|
|
# add conda to path
|
|
|
|
ENV PATH="${WORKDIR}/miniconda/bin:$PATH"
|
|
|
|
ENV LD_LIBRARY_PATH="${WORKDIR}/miniconda/lib:$LD_LIBRARY_PATH"
|
|
|
|
ENV CUDA_TOOLKIT_ROOT_DIR="/usr/local/cuda"
|
|
|
|
|
2020-09-22 23:41:35 +00:00
|
|
|
ENV HOROVOD_GPU_OPERATIONS=NCCL
|
|
|
|
ENV HOROVOD_WITH_PYTORCH=1
|
|
|
|
ENV HOROVOD_WITHOUT_TENSORFLOW=1
|
|
|
|
ENV HOROVOD_WITHOUT_MXNET=1
|
|
|
|
ENV HOROVOD_WITH_GLOO=1
|
|
|
|
ENV HOROVOD_WITHOUT_MPI=1
|
|
|
|
# TODO: uncomment in horovod next release, https://github.com/horovod/horovod/pull/2239
|
|
|
|
# ENV MAKEFLAGS="-j$(nproc)"
|
|
|
|
|
2020-09-17 18:30:39 +00:00
|
|
|
# conda init
|
|
|
|
RUN conda create -y --name $CONDA_ENV python=$PYTHON_VERSION pytorch=$PYTORCH_VERSION torchvision cudatoolkit=$CUDA_VERSION --channel=$PYTORCH_CHANNEL && \
|
|
|
|
conda init bash && \
|
|
|
|
# NOTE: this requires that the channel is presented in the yaml before packages
|
|
|
|
python -c "fname = 'environment.yml' ; req = open(fname).read().replace('pytorch', '${PYTORCH_CHANNEL}', 1) ; open(fname, 'w').write(req)" && \
|
2020-09-22 23:41:35 +00:00
|
|
|
python -c "fname = 'environment.yml' ; req = open(fname).readlines() ; open(fname, 'w').writelines([l for l in req if 'horovod' not in l])" && \
|
2020-09-17 18:30:39 +00:00
|
|
|
conda env update --file environment.yml && \
|
|
|
|
conda clean -ya && \
|
2020-09-22 23:41:35 +00:00
|
|
|
rm environment.yml
|
2020-09-17 18:30:39 +00:00
|
|
|
|
|
|
|
ENV PATH ${WORKDIR}/miniconda/envs/${CONDA_ENV}/bin:$PATH
|
|
|
|
ENV LD_LIBRARY_PATH="${WORKDIR}/miniconda/envs/${CONDA_ENV}/lib:$LD_LIBRARY_PATH"
|
|
|
|
# if you want this environment to be the default one, uncomment the following line:
|
|
|
|
ENV CONDA_DEFAULT_ENV=${CONDA_ENV}
|
|
|
|
|
2020-09-22 23:41:35 +00:00
|
|
|
COPY --chown=flash ./requirements/extra.txt requirements-extra.txt
|
|
|
|
COPY --chown=flash ./requirements/test.txt requirements-tests.txt
|
|
|
|
COPY --chown=flash ./requirements/examples.txt requirements-examples.txt
|
2020-09-17 18:30:39 +00:00
|
|
|
|
|
|
|
RUN \
|
2020-09-22 23:41:35 +00:00
|
|
|
# Disable cache
|
|
|
|
pip config set global.cache-dir false && \
|
|
|
|
#echo ". ${WORKDIR}/miniconda/etc/profile.d/conda.sh" >> ~/.bashrc && \
|
|
|
|
#echo "conda activate ${CONDA_ENV}" >> ~/.bashrc && \
|
|
|
|
#source ~/.bashrc && \
|
|
|
|
# filter only Horovod
|
|
|
|
python -c "fname = 'requirements-extra.txt' ; req = open(fname).readlines() ; open(fname, 'w').writelines([l for l in req if 'horovod' in l])" && \
|
2020-09-17 18:30:39 +00:00
|
|
|
# Install all requirements
|
2020-09-22 23:41:35 +00:00
|
|
|
pip install --global-option="--quiet" -r requirements-extra.txt && \
|
2020-09-17 18:30:39 +00:00
|
|
|
pip install -r requirements-tests.txt --upgrade-strategy only-if-needed && \
|
|
|
|
pip install -r requirements-examples.txt --upgrade-strategy only-if-needed && \
|
|
|
|
rm requirements* && \
|
|
|
|
# Show what we have
|
2020-08-15 19:39:44 +00:00
|
|
|
pip --version && \
|
2020-09-17 18:30:39 +00:00
|
|
|
conda info && \
|
|
|
|
conda list && \
|
2020-07-31 12:23:13 +00:00
|
|
|
pip list
|
2020-09-17 18:30:39 +00:00
|
|
|
|
2020-09-25 13:58:01 +00:00
|
|
|
CMD ["/bin/bash"]
|