From 6f591c24e8d3e3fb0a13cbfaf1e77b6b1af9928e Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Sat, 6 Sep 2025 16:39:35 +0000 Subject: [PATCH 1/3] upload intel cpu dockerfile Signed-off-by: jiqing-feng --- docker/transformers-intel-cpu/Dockerfile | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docker/transformers-intel-cpu/Dockerfile diff --git a/docker/transformers-intel-cpu/Dockerfile b/docker/transformers-intel-cpu/Dockerfile new file mode 100644 index 000000000000..49f52bac22a1 --- /dev/null +++ b/docker/transformers-intel-cpu/Dockerfile @@ -0,0 +1,34 @@ +FROM intel/deep-learning-essentials:2025.1.3-0-devel-ubuntu24.04 AS base +SHELL ["/bin/bash", "-c"] + +ARG PYTHON_VERSION=3.12 +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y software-properties-common && \ + add-apt-repository -y ppa:deadsnakes/ppa && \ + apt-get update + +RUN apt-get update && apt-get -y install apt-utils build-essential ca-certificates \ + clinfo curl git git-lfs vim numactl python3-dev wget google-perftools \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# Use virtual env because Ubuntu:24 does not allowed pip on original python +RUN curl -LsSf https://astral.sh/uv/install.sh | sh +ENV PATH="/root/.local/bin:$PATH" +ENV VIRTUAL_ENV="/opt/venv" +ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python +RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV} +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +RUN pip install torch torchvision torchaudio torchcodec --index-url https://download.pytorch.org/whl/cpu --no-cache-dir +RUN pip install -U datasets transformers accelerate intel-openmp + +ENV LD_PRELOAD=${LD_PRELOAD}:/opt/venv/lib/libiomp5.so:/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 +ENV KMP_AFFINITY=granularity=fine,compact,1,0 + +RUN touch /entrypoint.sh && chmod +x /entrypoint.sh +RUN echo "#!/bin/bash" >> /entrypoint.sh && echo "/bin/bash" >> /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] From 8f64506a96dc9a058adee9bd35ed5c37a10fbc64 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Thu, 11 Sep 2025 09:12:40 +0000 Subject: [PATCH 2/3] update cpu dockerfile Signed-off-by: jiqing-feng --- docker/transformers-intel-cpu/Dockerfile | 46 +++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/docker/transformers-intel-cpu/Dockerfile b/docker/transformers-intel-cpu/Dockerfile index 49f52bac22a1..754e7031798e 100644 --- a/docker/transformers-intel-cpu/Dockerfile +++ b/docker/transformers-intel-cpu/Dockerfile @@ -9,8 +9,29 @@ RUN apt-get update && \ add-apt-repository -y ppa:deadsnakes/ppa && \ apt-get update -RUN apt-get update && apt-get -y install apt-utils build-essential ca-certificates \ - clinfo curl git git-lfs vim numactl python3-dev wget google-perftools \ +RUN apt-get update && \ + apt-get -y install \ + apt-utils \ + build-essential \ + ca-certificates \ + clinfo \ + curl \ + git \ + git-lfs \ + vim \ + numactl \ + gnupg2 \ + gpg-agent \ + python3-dev \ + python3-opencv \ + unzip \ + ffmpeg \ + tesseract-ocr \ + espeak-ng \ + wget \ + ncurses-term \ + google-perftools \ + libjemalloc-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -22,13 +43,28 @@ ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV} ENV PATH="$VIRTUAL_ENV/bin:$PATH" +RUN pip install --upgrade pip wheel RUN pip install torch torchvision torchaudio torchcodec --index-url https://download.pytorch.org/whl/cpu --no-cache-dir -RUN pip install -U datasets transformers accelerate intel-openmp +RUN pip install av pyctcdecode pytesseract decord galore-torch fire scipy scikit-learn sentencepiece sentence_transformers sacremoses nltk rouge_score librosa soundfile mpi4py pytorch_msssim +RUN pip install onnx optimum onnxruntime +RUN pip install autoawq +RUN pip install gptqmodel --no-build-isolation +RUN pip install -U datasets timm transformers accelerate peft diffusers opencv-python kenlm evaluate +RUN pip install -U intel-openmp + +# install bitsandbytes +RUN git clone https://github.com/bitsandbytes-foundation/bitsandbytes.git && cd bitsandbytes/ && \ + cmake -DCOMPUTE_BACKEND=cpu -S . && make && pip install . && cd ../ + +# CPU don't need triton +RUN pip uninstall triton -y ENV LD_PRELOAD=${LD_PRELOAD}:/opt/venv/lib/libiomp5.so:/usr/lib/x86_64-linux-gnu/libtcmalloc.so.4 ENV KMP_AFFINITY=granularity=fine,compact,1,0 -RUN touch /entrypoint.sh && chmod +x /entrypoint.sh -RUN echo "#!/bin/bash" >> /entrypoint.sh && echo "/bin/bash" >> /entrypoint.sh +RUN touch /entrypoint.sh +RUN chmod +x /entrypoint.sh +RUN echo "#!/bin/bash" >> /entrypoint.sh +RUN echo "/bin/bash" >> /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] From 5b581b300f6983663437867668b82bc9f49f7d98 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Thu, 11 Sep 2025 09:14:50 +0000 Subject: [PATCH 3/3] update label name Signed-off-by: jiqing-feng --- docker/transformers-intel-cpu/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/transformers-intel-cpu/Dockerfile b/docker/transformers-intel-cpu/Dockerfile index 754e7031798e..3270b8582420 100644 --- a/docker/transformers-intel-cpu/Dockerfile +++ b/docker/transformers-intel-cpu/Dockerfile @@ -1,4 +1,5 @@ FROM intel/deep-learning-essentials:2025.1.3-0-devel-ubuntu24.04 AS base +LABEL maintainer="Hugging Face" SHELL ["/bin/bash", "-c"] ARG PYTHON_VERSION=3.12