Skip to content

Commit 847adbc

Browse files
authored
refine Dockerfile to support both cpu and xpu platform (#981)
* refine Dockerfile to support both cpu and xpu Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * nice code Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * fix CI issue Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * rename Dockerfile.intel to Dockerfile.ipex Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * upgrade ipex to 2.5 version; replace extra-index-url Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> --------- Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
1 parent d01af16 commit 847adbc

File tree

3 files changed

+77
-57
lines changed

3 files changed

+77
-57
lines changed

.github/workflows/dockerfile_sanity.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ on:
55
branches:
66
- main
77
paths:
8-
- "docker/Dockerfile.intel"
9-
8+
- 'Dockerfile.ipex'
9+
1010
pull_request:
1111
branches:
1212
- main
1313
paths:
14-
- "docker/Dockerfile.intel"
14+
- 'Dockerfile.ipex'
1515

1616
jobs:
1717
build_and_run:
@@ -27,7 +27,7 @@ jobs:
2727
- name: Build and Run Docker Image
2828
run: |
2929
IMAGE_NAME="intel_image:latest"
30-
docker build -f docker/Dockerfile.intel -t $IMAGE_NAME .
30+
docker build -f Dockerfile.ipex -t $IMAGE_NAME .
3131
if [ $? -ne 0 ]; then
3232
echo "Docker image build failed."
3333
exit 1

Dockerfile.ipex

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
ARG PLATFORM=cpu
2+
3+
FROM ubuntu:22.04 as cpu
4+
WORKDIR /usr/src/
5+
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
6+
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
7+
ca-certificates \
8+
git \
9+
curl \
10+
vim \
11+
build-essential \
12+
ccache \
13+
libgoogle-perftools-dev \
14+
numactl \
15+
cmake \
16+
libjpeg-dev \
17+
pybind11-dev \
18+
libpng-dev \
19+
python3 \
20+
python3-pip \
21+
&& rm -rf /var/lib/apt/lists/*"
22+
RUN /usr/sbin/update-ccache-symlinks
23+
RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache
24+
25+
ARG IPEX_VERSION=2.5.0
26+
ARG PYTORCH_VERSION=2.5.1
27+
ARG TORCHVISION_VERSION=0.20.1+cpu
28+
ARG TORCHAUDIO_VERSION=2.5.1+cpu
29+
30+
RUN python3 -m pip install --no-cache-dir \
31+
torch==${PYTORCH_VERSION}+cpu \
32+
torchvision==${TORCHVISION_VERSION} \
33+
torchaudio==${TORCHAUDIO_VERSION} \
34+
--index-url https://download.pytorch.org/whl/cpu && \
35+
python3 -m pip install intel-openmp -f https://download.pytorch.org/whl/torch_stable.html && \
36+
python3 -m pip install intel-extension-for-pytorch==$IPEX_VERSION && \
37+
python3 -m pip install oneccl_bind_pt --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/cpu/cn/ && \
38+
python3 -m pip install --no-cache-dir py-libnuma
39+
40+
ARG KMP_BLOCKTIME=1
41+
ENV KMP_BLOCKTIME=${KMP_BLOCKTIME}
42+
ARG KMP_HW_SUBSET=1T
43+
ENV KMP_HW_SUBSET=${KMP_HW_SUBSET}
44+
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc.so"
45+
46+
FROM intel/intel-extension-for-pytorch:2.3.110-xpu as xpu
47+
WORKDIR /usr/src/
48+
49+
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
50+
sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
51+
ca-certificates \
52+
git \
53+
curl \
54+
vim \
55+
ccache \
56+
libgoogle-perftools-dev \
57+
numactl \
58+
libjpeg-dev \
59+
pybind11-dev \
60+
libpng-dev \
61+
&& rm -rf /var/lib/apt/lists/*"
62+
RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor | tee /usr/share/keyrings/intel-graphics.gpg > /dev/null
63+
64+
RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
65+
| gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list
66+
67+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt install -y intel-basekit xpu-smi cmake ninja-build pciutils
68+
69+
FROM ${PLATFORM}
70+
71+
COPY optimum optimum
72+
COPY Makefile setup.cfg setup.py pyproject.toml README.md ./
73+
RUN pip install .

docker/Dockerfile.intel

-53
This file was deleted.

0 commit comments

Comments
 (0)