"Fossies" - the Fresh Open Source Software Archive

Member "pytorch-1.8.2/Dockerfile" (23 Jul 2021, 2877 Bytes) of package /linux/misc/pytorch-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "Dockerfile": 1.11.0_vs_1.12.0.

    1 # syntax = docker/dockerfile:experimental
    2 #
    3 # NOTE: To build this you will need a docker version > 18.06 with
    4 #       experimental enabled and DOCKER_BUILDKIT=1
    5 #
    6 #       If you do not use buildkit you are not going to have a good time
    7 #
    8 #       For reference: 
    9 #           https://docs.docker.com/develop/develop-images/build_enhancements/
   10 ARG BASE_IMAGE=ubuntu:18.04
   11 ARG PYTHON_VERSION=3.8
   12 
   13 FROM ${BASE_IMAGE} as dev-base
   14 RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
   15     apt-get update && apt-get install -y --no-install-recommends \
   16         build-essential \
   17         ca-certificates \
   18         ccache \
   19         cmake \
   20         curl \
   21         git \
   22         libjpeg-dev \
   23         libpng-dev && \
   24     rm -rf /var/lib/apt/lists/*
   25 RUN /usr/sbin/update-ccache-symlinks
   26 RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache
   27 ENV PATH /opt/conda/bin:$PATH
   28 
   29 FROM dev-base as conda
   30 ARG PYTHON_VERSION=3.8
   31 RUN curl -fsSL -v -o ~/miniconda.sh -O  https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh  && \
   32     chmod +x ~/miniconda.sh && \
   33     ~/miniconda.sh -b -p /opt/conda && \
   34     rm ~/miniconda.sh && \
   35     /opt/conda/bin/conda install -y python=${PYTHON_VERSION} conda-build pyyaml numpy ipython&& \
   36     /opt/conda/bin/conda clean -ya
   37 
   38 FROM dev-base as submodule-update
   39 WORKDIR /opt/pytorch
   40 COPY . .
   41 RUN git submodule update --init --recursive
   42 
   43 FROM conda as build
   44 WORKDIR /opt/pytorch
   45 COPY --from=conda /opt/conda /opt/conda
   46 COPY --from=submodule-update /opt/pytorch /opt/pytorch
   47 RUN --mount=type=cache,target=/opt/ccache \
   48     TORCH_CUDA_ARCH_LIST="3.5 5.2 6.0 6.1 7.0+PTX 8.0" TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
   49     CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" \
   50     python setup.py install
   51 
   52 FROM conda as conda-installs
   53 ARG PYTHON_VERSION=3.8
   54 ARG CUDA_VERSION=11.0
   55 ARG INSTALL_CHANNEL=pytorch-nightly
   56 ENV CONDA_OVERRIDE_CUDA=${CUDA_VERSION}
   57 RUN /opt/conda/bin/conda install -c "${INSTALL_CHANNEL}" -y python=${PYTHON_VERSION} pytorch torchvision torchtext "cudatoolkit=${CUDA_VERSION}" && \
   58     /opt/conda/bin/conda clean -ya
   59 RUN /opt/conda/bin/pip install torchelastic
   60 
   61 FROM ${BASE_IMAGE} as official
   62 ARG PYTORCH_VERSION
   63 LABEL com.nvidia.volumes.needed="nvidia_driver"
   64 RUN --mount=type=cache,id=apt-final,target=/var/cache/apt \
   65     apt-get update && apt-get install -y --no-install-recommends \
   66         ca-certificates \
   67         libjpeg-dev \
   68         libpng-dev && \
   69     rm -rf /var/lib/apt/lists/*
   70 COPY --from=conda-installs /opt/conda /opt/conda
   71 ENV PATH /opt/conda/bin:$PATH
   72 ENV NVIDIA_VISIBLE_DEVICES all
   73 ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
   74 ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
   75 ENV PYTORCH_VERSION ${PYTORCH_VERSION}
   76 WORKDIR /workspace
   77 
   78 FROM official as dev
   79 # Should override the already installed version from the official-image stage
   80 COPY --from=build /opt/conda /opt/conda