From 53b68850f6ac58a1cdb60141c0a6f733d8310981 Mon Sep 17 00:00:00 2001 From: "Liu, Kaixuan" Date: Thu, 31 Oct 2024 14:25:02 -0400 Subject: [PATCH 1/2] refine Dockerfile to support both cpu and xpu Signed-off-by: Liu, Kaixuan --- docker/Dockerfile.intel => Dockerfile.intel | 44 +++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-) rename docker/Dockerfile.intel => Dockerfile.intel (50%) diff --git a/docker/Dockerfile.intel b/Dockerfile.intel similarity index 50% rename from docker/Dockerfile.intel rename to Dockerfile.intel index ad4ff63e8..326d36563 100644 --- a/docker/Dockerfile.intel +++ b/Dockerfile.intel @@ -1,16 +1,9 @@ -# syntax = docker/dockerfile:1 -# based onhttps://github.com/pytorch/pytorch/blob/master/Dockerfile -# -# NOTE: To build this you will need a docker version >= 19.03 and DOCKER_BUILDKIT=1 -# -# If you do not use buildkit you are not going to have a good time -# -# For reference: -# https://docs.docker.com/develop/develop-images/build_enhancements/ - -ARG BASE_IMAGE=ubuntu:22.04 -FROM ${BASE_IMAGE} +ARG PLATFORM=cpu +FROM ubuntu:22.04 as cpu +WORKDIR /usr/src/ +COPY optimum optimum +COPY Makefile setup.cfg setup.py pyproject.toml README.md ./ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ ca-certificates \ @@ -51,3 +44,30 @@ ENV KMP_BLOCKTIME=${KMP_BLOCKTIME} ARG KMP_HW_SUBSET=1T ENV KMP_HW_SUBSET=${KMP_HW_SUBSET} ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc.so" + +RUN pip install . + +FROM intel/intel-extension-for-pytorch:2.3.110-xpu as xpu +WORKDIR /usr/src/ +COPY optimum optimum +COPY Makefile setup.cfg setup.py pyproject.toml README.md ./ +RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ + sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ + ca-certificates \ + git \ + curl \ + vim \ + ccache \ + libgoogle-perftools-dev \ + numactl \ + libjpeg-dev \ + pybind11-dev \ + libpng-dev \ + && rm -rf /var/lib/apt/lists/*" +RUN wget -qO - https://repositories.intel.com/gpu/intel-graphics.key | gpg --dearmor | tee /usr/share/keyrings/intel-graphics.gpg > /dev/null + +RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ +| 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 + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt install -y intel-basekit xpu-smi cmake ninja-build pciutils +RUN pip install . From 11ff39d2fb32bd726b66b88ecf07fc3d6f78448d Mon Sep 17 00:00:00 2001 From: "Liu, Kaixuan" Date: Wed, 13 Nov 2024 05:15:54 -0500 Subject: [PATCH 2/2] nice code Signed-off-by: Liu, Kaixuan --- Dockerfile.intel | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile.intel b/Dockerfile.intel index 326d36563..60e206e3b 100644 --- a/Dockerfile.intel +++ b/Dockerfile.intel @@ -2,8 +2,6 @@ ARG PLATFORM=cpu FROM ubuntu:22.04 as cpu WORKDIR /usr/src/ -COPY optimum optimum -COPY Makefile setup.cfg setup.py pyproject.toml README.md ./ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ ca-certificates \ @@ -45,12 +43,9 @@ ARG KMP_HW_SUBSET=1T ENV KMP_HW_SUBSET=${KMP_HW_SUBSET} ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc.so" -RUN pip install . - FROM intel/intel-extension-for-pytorch:2.3.110-xpu as xpu WORKDIR /usr/src/ -COPY optimum optimum -COPY Makefile setup.cfg setup.py pyproject.toml README.md ./ + RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \ ca-certificates \ @@ -70,4 +65,9 @@ RUN wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRO | 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 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt install -y intel-basekit xpu-smi cmake ninja-build pciutils -RUN pip install . + +FROM ${PLATFORM} + +COPY optimum optimum +COPY Makefile setup.cfg setup.py pyproject.toml README.md ./ +RUN pip install . \ No newline at end of file