Skip to content

Commit

Permalink
Dockerfile update (#821)
Browse files Browse the repository at this point in the history
* improve doc around supported tasks and accelertor options

* leave other accelerator options even if not yet implemented

* bump ipex/torch vs, fix syntax to supress build warnings/errors and install ipex from wheel instead of source

* simplified Dockerfile, remove build stages and conda

* rm proxies
  • Loading branch information
rbrugaro authored Jul 18, 2024
1 parent 31f49a2 commit d35ced8
Showing 1 changed file with 21 additions and 38 deletions.
59 changes: 21 additions & 38 deletions docker/Dockerfile.intel
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# https://docs.docker.com/develop/develop-images/build_enhancements/

ARG BASE_IMAGE=ubuntu:22.04
FROM ${BASE_IMAGE} AS dev-base
FROM ${BASE_IMAGE}

RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
ca-certificates \
git \
curl \
Expand All @@ -25,46 +25,29 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
libjpeg-dev \
pybind11-dev \
libpng-dev \
pybind11-dev \
&& rm -rf /var/lib/apt/lists/*
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*"
RUN /usr/sbin/update-ccache-symlinks
RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache
ENV PATH /opt/conda/bin:$PATH

FROM dev-base as conda
ARG PYTHON_VERSION=3.10
RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
chmod +x ~/miniconda.sh && \
~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda install -y python=${PYTHON_VERSION} conda-build pyyaml numpy ipython mkl mkl-include ninja cython typing pybind11 Pillow && \
/opt/conda/bin/conda clean -ya
ARG IPEX_VERSION=2.3.100
ARG PYTORCH_VERSION=2.3.1
ARG TORCHVISION_VERSION=0.18.1+cpu
ARG TORCHAUDIO_VERSION=2.3.1+cpu

FROM dev-base AS build
ARG IPEX_VERSION=v1.13.0
ARG PYTORCH_VERSION=v1.13.0
ARG TORCHVISION_VERSION=0.13.0+cpu
ARG TORCHAUDIO_VERSION=0.13.0+cpu
COPY --from=conda /opt/conda /opt/conda
RUN --mount=type=cache,target=/opt/ccache \
python -m pip install --no-cache-dir torch==${PYTORCH_VERSION}+cpu torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} -f https://download.pytorch.org/whl/torch_stable.html && \
git clone https://github.com/intel/intel-extension-for-pytorch && \
cd intel-extension-for-pytorch && \
git checkout ${IPEX_VERSION} && \
git submodule sync && \
git submodule update --init --recursive && \
python -m pip install --no-cache-dir -r requirements.txt && \
python setup.py bdist_wheel && \
python -m pip install --no-cache-dir dist/*.whl && \
cd .. && rm -rf intel-extension-for-pytorch
RUN python3 -m pip install --no-cache-dir \
torch==${PYTORCH_VERSION}+cpu \
torchvision==${TORCHVISION_VERSION} \
torchaudio==${TORCHAUDIO_VERSION} \
-f https://download.pytorch.org/whl/torch_stable.html && \
python3 -m pip install intel-extension-for-pytorch==$IPEX_VERSION && \
python3 -m pip install oneccl_bind_pt --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/us/

FROM dev-base as dev
COPY --from=build /opt/conda /opt/conda
ARG OMP_NUM_THREADS=1
ENV OMP_NUM_THREADS ${OMP_NUM_THREADS}
ENV OMP_NUM_THREADS=${OMP_NUM_THREADS}
ARG KMP_BLOCKTIME=1
ENV KMP_BLOCKTIME ${KMP_BLOCKTIME}
ENV KMP_BLOCKTIME=${KMP_BLOCKTIME}
ARG KMP_HW_SUBSET=1T
ENV KMP_HW_SUBSET ${KMP_HW_SUBSET}
ENV LD_PRELOAD "/opt/conda/lib/libiomp5.so /usr/lib/x86_64-linux-gnu/libtcmalloc.so"
ENV LD_LIBRARY_PATH "/opt/conda/lib/python3.8/site-packages/lib/"
ENV KMP_HW_SUBSET=${KMP_HW_SUBSET}
ENV LD_PRELOAD="/usr/local/lib/libiomp5.so /usr/lib/x86_64-linux-gnu/libtcmalloc.so"

0 comments on commit d35ced8

Please sign in to comment.