Improvement of Docker image build for IBM Power using prebuilt wheels from IBM published devpi index (#46017)
Signed-off-by: vivek sharma <vivsharm@redhat.com> Signed-off-by: puneetsharma21 <puneet.sharma21@ibm.com> Signed-off-by: Puneet Sharma <puneet.sharma21@ibm.com> Co-authored-by: vivek sharma <vivsharm@redhat.com> Co-authored-by: Puneet Sharma <puneet.sharma21@ibm.com> Co-authored-by: depthfirst-app[bot] <184448029+depthfirst-app[bot]@users.noreply.github.com>
Vivek Sharma committed
Jul 8, 2026 at 18:31 UTC
9f2b3b093cf5f1ce5af8081f72294e0846139801
2 files changed
+355
-307
build_vllm_ppc64le.sh
new
+241
@@ -0,0 +1,241 @@
1
+#!/bin/bash
2
+set -eoux pipefail
3
+
4
+########################################
5
+# Resolve repo root (IMPORTANT)
6
+########################################
7
+REPO_ROOT="$(pwd)"
8
+
9
+cd "$REPO_ROOT"
10
+
11
+########################################
12
+# DevPI configuration
13
+########################################
14
+
15
+IBM_DEVPI_URL=${IBM_DEVPI_URL:-"https://wheels.developerfirst.ibm.com/ppc64le/linux/+simple/"}
16
+RHOAI_INDEX_URL=${RHOAI_INDEX_URL:-"https://console.redhat.com/api/pypi/public-rhai/rhoai/3.4/cpu-ubi9/simple/"}
17
+
18
+########################################
19
+# wheel dir
20
+########################################
21
+
22
+WHEEL_DIR=${WHEEL_DIR:-"/tmp/wheels"}
23
+mkdir -p "$WHEEL_DIR"
24
+
25
+########################################
26
+# Helpers
27
+########################################
28
+try_install_from_devpi() {
29
+ local pkg=$1
30
+ uv pip install \
31
+ --extra-index-url "${IBM_DEVPI_URL}" \
32
+ --index-strategy unsafe-best-match \
33
+ --no-build-isolation \
34
+ "${pkg}"
35
+}
36
+
37
+########################################
38
+# Package Versions
39
+########################################
40
+cd "$REPO_ROOT"
41
+TORCH_VERSION=${TORCH_VERSION:-$(grep -E '^torch==.+==\s*"ppc64le"' requirements/cpu.txt | grep -Eo '\b[0-9\.]+\b' || true)}
42
+TORCH_VERSION=${TORCH_VERSION:-2.11.0}
43
+
44
+TORCHVISION_VERSION=${TORCHVISION_VERSION:-0.26.0}
45
+TORCHAUDIO_VERSION=${TORCHAUDIO_VERSION:-${TORCH_VERSION}}
46
+
47
+export TORCH_VERSION
48
+export TORCHVISION_VERSION
49
+export TORCHAUDIO_VERSION
50
+export OPENCV_VERSION=${OPENCV_VERSION:-4.13.0.92}
51
+export XGRAMMAR_VERSION=${XGRAMMAR_VERSION:-0.2.1}
52
+
53
+########################################
54
+# install system dependencies
55
+########################################
56
+
57
+rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm || true
58
+
59
+microdnf install -y \
60
+ python3.12 python3.12-devel python3.12-pip gcc \
61
+ git jq gcc-toolset-14 gcc-toolset-14-libatomic-devel \
62
+ automake libtool clang-devel openssl-devel \
63
+ harfbuzz-devel kmod lcms2-devel libimagequant-devel libjpeg-turbo-devel \
64
+ llvm15-devel libraqm-devel libtiff-devel libwebp-devel libxcb-devel \
65
+ ninja-build openjpeg2-devel pkgconfig \
66
+ tcl-devel tk-devel xsimd-devel zeromq-devel zlib-devel patchelf file openblas openblas-devel protobuf numactl numactl-devel openmpi openmpi-devel
67
+
68
+rpm -ivh --nodeps \
69
+ https://mirror.stream.centos.org/9-stream/CRB/ppc64le/os/Packages/protobuf-lite-devel-3.14.0-17.el9.ppc64le.rpm
70
+
71
+rpm -ivh --nodeps \
72
+ https://mirror.stream.centos.org/9-stream/CRB/ppc64le/os/Packages/protobuf-devel-3.14.0-17.el9.ppc64le.rpm
73
+
74
+rpm -ivh --nodeps \
75
+ https://mirror.stream.centos.org/9-stream/CRB/ppc64le/os/Packages/protobuf-compiler-3.14.0-17.el9.ppc64le.rpm
76
+
77
+########################################
78
+# Python 3.12 virtual environment
79
+########################################
80
+
81
+python3.12 -m venv /opt/vllm
82
+source /opt/vllm/bin/activate
83
+
84
+export PATH=/opt/vllm/bin:$PATH
85
+
86
+python --version
87
+
88
+########################################
89
+# install build tools (stable uv)
90
+########################################
91
+
92
+pip install -U pip setuptools-rust
93
+pip install uv
94
+pip install "setuptools<70" build wheel cmake auditwheel
95
+uv pip install "setuptools<70" cython meson-python pybind11 "sympy>=1.13.3" --no-build-isolation
96
+
97
+########################################
98
+# Rust
99
+########################################
100
+
101
+curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
102
+source /root/.cargo/env
103
+
104
+########################################
105
+# Compiler env
106
+########################################
107
+
108
+source /opt/rh/gcc-toolset-14/enable
109
+
110
+export PATH=/usr/lib64/llvm15/bin:$PATH
111
+export LLVM_CONFIG=/usr/lib64/llvm15/bin/llvm-config
112
+export CMAKE_ARGS="-DPython3_EXECUTABLE=python"
113
+
114
+export MAX_JOBS=${MAX_JOBS:-$(nproc)}
115
+export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
116
+
117
+########################################
118
+# Install Packages From Devpi
119
+########################################
120
+uv pip install numpy==2.3.5 pillow==12.2.0 --extra-index-url "$IBM_DEVPI_URL"
121
+try_install_from_devpi "opencv-python-headless==${OPENCV_VERSION}"
122
+try_install_from_devpi "torch==${TORCH_VERSION}"
123
+try_install_from_devpi "torchvision==${TORCHVISION_VERSION}"
124
+
125
+########################################
126
+# torch audio
127
+########################################
128
+
129
+TEMP_BUILD_DIR=$(mktemp -d)
130
+cd "${TEMP_BUILD_DIR}"
131
+export BUILD_SOX=1 BUILD_KALDI=1 BUILD_RNNT=1 USE_FFMPEG=0 USE_ROCM=0 USE_CUDA=0
132
+export TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_FFMPEG=1
133
+git clone --recursive https://github.com/pytorch/audio.git -b v${TORCHAUDIO_VERSION}
134
+cd audio
135
+#patching
136
+sed -i '
137
+s|_CSRC_DIR / "_torchaudio.cpp"|str(_CSRC_DIR / "_torchaudio.cpp")|;
138
+s|_CSRC_DIR / "utils.cpp"|str(_CSRC_DIR / "utils.cpp")|;
139
+s|sources=\[_CSRC_DIR / s for s in sources\]|sources=[str(_CSRC_DIR / s) for s in sources]|;
140
+' tools/setup_helpers/extension.py
141
+MAX_JOBS=${MAX_JOBS:-$(nproc)} \
142
+BUILD_VERSION=${TORCHAUDIO_VERSION} \
143
+uv build --wheel --out-dir "${WHEEL_DIR}" --no-build-isolation
144
+uv pip install "${WHEEL_DIR}"/torchaudio*.whl
145
+cd "${REPO_ROOT}"
146
+rm -rf "${TEMP_BUILD_DIR}"
147
+
148
+########################################
149
+# Xgrammar
150
+########################################
151
+uv pip install \
152
+ "scikit-build-core==0.11.6" \
153
+ "pyproject-metadata<0.8" \
154
+ pathspec \
155
+ packaging \
156
+ distro \
157
+ "setuptools<70" \
158
+ setuptools_scm \
159
+ cmake \
160
+ ninja \
161
+ pybind11 \
162
+ nanobind
163
+uv pip install apache-tvm-ffi==0.1.12 \
164
+ --no-build-isolation \
165
+ --no-cache
166
+
167
+TEMP_BUILD_DIR=$(mktemp -d)
168
+
169
+pushd "${TEMP_BUILD_DIR}"
170
+
171
+export CFLAGS="-fno-lto -mcpu=power9"
172
+export CXXFLAGS="-fno-lto -mcpu=power9"
173
+export LDFLAGS="-fno-lto"
174
+export PATH=/opt/vllm/bin:$PATH
175
+
176
+export Python_EXECUTABLE=/opt/vllm/bin/python3
177
+export Python3_EXECUTABLE=/opt/vllm/bin/python3
178
+export PYTHON_EXECUTABLE=/opt/vllm/bin/python3
179
+
180
+export Python_ROOT_DIR=/opt/vllm
181
+export Python3_ROOT_DIR=/opt/vllm
182
+
183
+git clone \
184
+ --recursive \
185
+ https://github.com/mlc-ai/xgrammar \
186
+ -b "v${XGRAMMAR_VERSION}"
187
+
188
+cd xgrammar
189
+
190
+cp cmake/config.cmake .
191
+export PYTHONPATH=/opt/vllm/lib64/python3.12/site-packages:/opt/vllm/lib/python3.12/site-packages:${PYTHONPATH:-}
192
+
193
+uv build \
194
+ --wheel \
195
+ --out-dir "${WHEEL_DIR}" \
196
+ --no-build-isolation
197
+
198
+uv pip install "${WHEEL_DIR}"/xgrammar*.whl -v
199
+
200
+popd
201
+
202
+rm -rf "${TEMP_BUILD_DIR}"
203
+cd "${REPO_ROOT}"
204
+
205
+########################################
206
+# RHOAI Binary Downloads
207
+########################################
208
+pip download \
209
+ --index-url "${RHOAI_INDEX_URL}" \
210
+ --only-binary=:all: \
211
+ --no-deps \
212
+ llvmlite==0.47.0 \
213
+ -d "${WHEEL_DIR}"
214
+
215
+pip download \
216
+ --index-url "${RHOAI_INDEX_URL}" \
217
+ --only-binary=:all: \
218
+ --no-deps \
219
+ Numba==0.65.0 \
220
+ -d "${WHEEL_DIR}"
221
+
222
+########################################
223
+# install built wheels
224
+########################################
225
+uv pip install setuptools_scm maturin setuptools-rust ninja scikit-build-core pybind11 nanobind \
226
+ --no-build-isolation
227
+uv pip install "${WHEEL_DIR}"/*.whl
228
+
229
+########################################
230
+# install remaining deps
231
+########################################
232
+
233
+sed -i.bak -e 's/.*torch.*//g' pyproject.toml requirements/*.txt
234
+
235
+uv pip install "setuptools>=78.1.1" --no-build-isolation
236
+
237
+export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig
238
+
239
+uv pip install -r requirements/common.txt \
240
+ -r requirements/cpu.txt \
241
+ -r requirements/build/cpu.txt --index-strategy unsafe-best-match
docker/Dockerfile.ppc64le
+114
-307
@@ -1,275 +1,80 @@
1
+# Base UBI image
2
ARG BASE_UBI_IMAGE_TAG=9.6-1754584681
3
4
###############################################################
4
-# Stage to build openblas
5
+# BUILDER STAGE #
6
###############################################################
7
7
-FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS openblas-builder
8
-
9
-ARG MAX_JOBS
10
-ARG OPENBLAS_VERSION=0.3.30
11
-RUN microdnf install -y dnf && dnf install -y gcc-toolset-14 make wget unzip \
12
- && source /opt/rh/gcc-toolset-14/enable \
13
- && wget https://github.com/OpenMathLib/OpenBLAS/releases/download/v$OPENBLAS_VERSION/OpenBLAS-$OPENBLAS_VERSION.zip \
14
- && unzip OpenBLAS-$OPENBLAS_VERSION.zip \
15
- && cd OpenBLAS-$OPENBLAS_VERSION \
16
- && make -j${MAX_JOBS} TARGET=POWER9 BINARY=64 USE_OPENMP=1 USE_THREAD=1 NUM_THREADS=120 DYNAMIC_ARCH=1 INTERFACE64=0 \
17
- && cd /tmp && touch control
18
-
19
-
20
-###############################################################
21
-# base stage with dependencies coming from centos mirrors
22
-###############################################################
23
-FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS centos-deps-builder
24
-RUN microdnf install -y dnf && \
25
- dnf install -y https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os/Packages/centos-gpg-keys-9.0-26.el9.noarch.rpm \
26
- https://mirror.stream.centos.org/9-stream/BaseOS/`arch`/os/Packages/centos-stream-repos-9.0-26.el9.noarch.rpm \
27
- https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
28
- dnf config-manager --set-enabled crb
29
-
30
-RUN dnf install -y openjpeg2-devel lcms2-devel tcl-devel tk-devel fribidi-devel yajl-devel && \
31
- dnf remove -y centos-gpg-keys-9.0-24.el9.noarch centos-stream-repos-9.0-26.el9.noarch
32
-
33
-
34
-###############################################################
35
-# base stage with basic dependencies
36
-###############################################################
37
-
38
-FROM centos-deps-builder AS base-builder
8
+FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS builder-base
9
10
+ARG VLLM_VERSION="0.22.1"
11
ARG PYTHON_VERSION=3.12
41
-ARG OPENBLAS_VERSION=0.3.30
42
-
43
-# Set Environment Variables for venv, cargo & openblas
44
-ENV VIRTUAL_ENV=/opt/vllm
45
-ENV PATH=${VIRTUAL_ENV}/bin:/root/.cargo/bin:$PATH
46
-ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
47
-ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib
48
-ENV UV_LINK_MODE=copy
12
+ARG VLLM_TARGET_DEVICE=cpu
13
50
-# install gcc-13, python, rust, openblas
51
-# Note: A symlink for libatomic.so is created for gcc-13 (linker fails to find libatomic otherwise - reqd. for sentencepiece)
52
-# Note: A dummy file 'control' is created in /tmp/ to artificially create dependencies between stages when building stages in parallel
53
-# when `--jobs=<N>` is passed with podman build command
54
-
55
-COPY --from=openblas-builder /tmp/control /dev/null
56
-
57
-RUN --mount=type=bind,from=openblas-builder,source=/OpenBLAS-$OPENBLAS_VERSION/,target=/openblas/,rw \
58
- dnf install -y openssl-devel \
59
- && dnf install -y \
60
- git tar gcc-toolset-14 automake libtool \
61
- pkgconfig xsimd zeromq-devel kmod findutils protobuf* \
62
- libtiff-devel libjpeg-devel zlib-devel freetype-devel libwebp-devel \
63
- harfbuzz-devel libraqm-devel libimagequant-devel libxcb-devel \
64
- python${PYTHON_VERSION}-devel python${PYTHON_VERSION}-pip clang-devel \
65
- && dnf clean all \
66
- && PREFIX=/usr/local make -C /openblas install \
67
- && ln -sf /usr/lib64/libatomic.so.1 /usr/lib64/libatomic.so \
14
+USER root
15
+WORKDIR /root
16
+
17
+ENV HOME=/root \
18
+ WHEEL_DIR=/wheelsdir \
19
+ VIRTUAL_ENV=/opt/vllm \
20
+ GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 \
21
+ CARGO_HOME=/root/.cargo \
22
+ RUSTUP_HOME=/root/.rustup \
23
+ UV_CACHE_DIR=$HOME/.cache/uv \
24
+ PATH=/root/.cargo/bin:/root/.rustup/bin:${VIRTUAL_ENV}/bin:$PATH
25
+
26
+RUN echo "DEBUG: VLLM_VERSION=${VLLM_VERSION}"
27
+RUN --mount=type=cache,target=/var/cache/dnf \
28
+ microdnf install -y \
29
+ python${PYTHON_VERSION}-devel python${PYTHON_VERSION}-pip \
30
&& python${PYTHON_VERSION} -m venv ${VIRTUAL_ENV} \
69
- && python -m pip install -U pip uv \
70
- && uv pip install wheel build "setuptools<70" setuptools_scm setuptools_rust meson-python 'cmake<4' ninja cython scikit_build_core scikit_build \
71
- && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
72
- && cd /tmp && touch control
73
-
74
-
75
-###############################################################
76
-# Stage to build torch family
77
-###############################################################
31
+ && python${PYTHON_VERSION} -m pip install -U pip uv --no-cache
32
79
-FROM base-builder AS torch-builder
33
+# Important: Copy only bare minimum required for the script to run
34
+COPY requirements/ requirements/
35
+COPY pyproject.toml ./
36
81
-ARG MAX_JOBS
82
-ARG TORCH_VERSION=2.7.0
83
-ARG _GLIBCXX_USE_CXX11_ABI=1
84
-ARG OPENBLAS_VERSION=0.3.30
37
+# The script is expected to install whatever python dependencies are missing
38
+# as well as whatever system libraries need to be installed from source
39
+COPY build_vllm_*.sh ./
40
41
RUN --mount=type=cache,target=/root/.cache/uv \
87
- source /opt/rh/gcc-toolset-14/enable && \
88
- git clone --recursive https://github.com/pytorch/pytorch.git -b v${TORCH_VERSION} && \
89
- cd pytorch && \
90
- uv pip install -r requirements.txt && \
91
- python setup.py develop && \
92
- rm -f dist/torch*+git*whl && \
93
- MAX_JOBS=${MAX_JOBS:-$(nproc)} \
94
- PYTORCH_BUILD_VERSION=${TORCH_VERSION} PYTORCH_BUILD_NUMBER=1 uv build --wheel --out-dir /torchwheels/
95
-
96
-ARG TORCHVISION_VERSION=0.22.0
97
-ARG TORCHVISION_USE_NVJPEG=0
98
-ARG TORCHVISION_USE_FFMPEG=0
99
-RUN --mount=type=cache,target=/root/.cache/uv \
100
- source /opt/rh/gcc-toolset-14/enable && \
101
- git clone --recursive https://github.com/pytorch/vision.git -b v${TORCHVISION_VERSION} && \
102
- cd vision && \
103
- MAX_JOBS=${MAX_JOBS:-$(nproc)} \
104
- BUILD_VERSION=${TORCHVISION_VERSION} \
105
- uv build --wheel --out-dir /torchwheels/ --no-build-isolation
106
-
107
-ARG TORCHAUDIO_VERSION=2.7.0
108
-ARG BUILD_SOX=1
109
-ARG BUILD_KALDI=1
110
-ARG BUILD_RNNT=1
111
-ARG USE_FFMPEG=0
112
-ARG USE_ROCM=0
113
-ARG USE_CUDA=0
114
-ARG TORCHAUDIO_TEST_ALLOW_SKIP_IF_NO_FFMPEG=1
115
-RUN --mount=type=cache,target=/root/.cache/uv \
116
- source /opt/rh/gcc-toolset-14/enable && \
117
- git clone --recursive https://github.com/pytorch/audio.git -b v${TORCHAUDIO_VERSION} && \
118
- cd audio && \
119
- MAX_JOBS=${MAX_JOBS:-$(nproc)} \
120
- BUILD_VERSION=${TORCHAUDIO_VERSION} \
121
- uv build --wheel --out-dir /torchwheels/ --no-build-isolation
122
-
123
-###############################################################
124
-# Stage to build pyarrow
125
-###############################################################
42
+ sh ./build_vllm_$(uname -m).sh
43
127
-FROM base-builder AS arrow-builder
44
+# copy vllm source code to build cache
45
+COPY . .
46
129
-ARG MAX_JOBS
130
-ARG PYARROW_PARALLEL
131
-ARG PYARROW_VERSION=21.0.0
47
RUN --mount=type=cache,target=/root/.cache/uv \
48
source /opt/rh/gcc-toolset-14/enable && \
134
- git clone --recursive https://github.com/apache/arrow.git -b apache-arrow-${PYARROW_VERSION} && \
135
- cd arrow/cpp && \
136
- mkdir build && cd build && \
137
- cmake -DCMAKE_BUILD_TYPE=release \
138
- -DCMAKE_INSTALL_PREFIX=/usr/local \
139
- -DARROW_PYTHON=ON \
140
- -DARROW_BUILD_TESTS=OFF \
141
- -DARROW_JEMALLOC=ON \
142
- -DARROW_BUILD_STATIC="OFF" \
143
- -DARROW_PARQUET=ON \
144
- .. && \
145
- make install -j ${MAX_JOBS:-$(nproc)} && \
146
- cd ../../python/ && \
147
- uv pip install -v -r requirements-build.txt && uv pip install numpy==2.1.3 && \
148
- PYARROW_PARALLEL=${PYARROW_PARALLEL:-$(nproc)} \
149
- python setup.py build_ext \
150
- --build-type=release --bundle-arrow-cpp \
151
- bdist_wheel --dist-dir /arrowwheels/
152
-
153
-###############################################################
154
-# Stage to build opencv
155
-###############################################################
49
+ pip install -U uv
50
157
-FROM base-builder AS cv-builder
158
-
159
-ARG MAX_JOBS
160
-ARG OPENCV_VERSION=86
161
-# patch for version 4.11.0.86
162
-ARG OPENCV_PATCH=97f3f39
163
-ARG ENABLE_HEADLESS=1
51
+# build & install vLLM so that all transitive dependencies are build/downloaded into the uv cache
52
RUN --mount=type=cache,target=/root/.cache/uv \
53
source /opt/rh/gcc-toolset-14/enable && \
166
- git clone --recursive https://github.com/opencv/opencv-python.git -b ${OPENCV_VERSION} && \
167
- cd opencv-python && \
168
- sed -i -E -e 's/"setuptools.+",/"setuptools",/g' pyproject.toml && \
169
- cd opencv && git cherry-pick --no-commit $OPENCV_PATCH && cd .. && \
170
- uv pip install scikit-build && \
171
- python -m build --wheel --installer=uv --outdir /opencvwheels/
172
-
173
-###############################################################
174
-# Stage to build numactl
175
-###############################################################
176
-
177
-FROM base-builder AS numa-builder
178
-
179
-# Note: Building numactl with gcc-11. Compiling with gcc-13 in this builder stage will
180
-# trigger recompilation with gcc-11 (and require libtool) in the final stage where we do not have gcc-13
181
-ARG MAX_JOBS
182
-ARG NUMACTL_VERSION=2.0.19
183
-RUN git clone --recursive https://github.com/numactl/numactl.git -b v${NUMACTL_VERSION} \
184
- && cd numactl \
185
- && autoreconf -i && ./configure \
186
- && make -j ${MAX_JOBS:-$(nproc)}
187
-
188
-
189
-###############################################################
190
-# Stage to build numba
191
-###############################################################
192
-
193
-FROM base-builder AS numba-builder
194
-
195
-ARG MAX_JOBS
196
-ARG NUMBA_VERSION=0.61.2
197
-
198
-# Clone all required dependencies
199
-RUN dnf install ninja-build llvm15 llvm15-devel -y && source /opt/rh/gcc-toolset-14/enable && export PATH=$PATH:/usr/lib64/llvm15/bin && \
200
- git clone --recursive https://github.com/numba/numba.git -b ${NUMBA_VERSION} && \
201
- cd ./numba && \
202
- if ! grep '#include "dynamic_annotations.h"' numba/_dispatcher.cpp; then \
203
- sed -i '/#include "internal\/pycore_atomic.h"/i\#include "dynamic_annotations.h"' numba/_dispatcher.cpp; \
204
- fi && python -m build --wheel --installer=uv --outdir /numbawheels/
205
-
206
-###############################################################
207
-# Stage to build vllm - this stage builds and installs
208
-# vllm, tensorizer and vllm-tgis-adapter and builds uv cache
209
-# for transitive dependencies - eg. grpcio
210
-###############################################################
211
-
212
-FROM base-builder AS vllmcache-builder
213
-
214
-ENV LLVM_CONFIG=/usr/lib64/llvm15/bin/llvm-config
215
-ENV PATH=/usr/lib64/llvm15/bin:$PATH
216
-
217
-COPY --from=torch-builder /tmp/control /dev/null
218
-COPY --from=arrow-builder /tmp/control /dev/null
219
-COPY --from=cv-builder /tmp/control /dev/null
220
-COPY --from=numa-builder /tmp/control /dev/null
221
-COPY --from=numba-builder /tmp/control /dev/null
222
-
223
-ARG VLLM_TARGET_DEVICE=cpu
224
-ARG GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
225
-
226
-# this step installs vllm and populates uv cache
227
-# with all the transitive dependencies
228
-RUN --mount=type=cache,target=/root/.cache/uv \
229
- dnf install llvm15 llvm15-devel -y && \
230
- rpm -ivh --nodeps https://mirror.stream.centos.org/9-stream/CRB/ppc64le/os/Packages/protobuf-lite-devel-3.14.0-16.el9.ppc64le.rpm && \
231
- source /opt/rh/gcc-toolset-14/enable && \
232
- git clone https://github.com/huggingface/xet-core.git && cd xet-core/hf_xet/ && \
233
- uv pip install maturin && \
234
- uv build --wheel --out-dir /hf_wheels/
235
-
236
-ENV CXXFLAGS="-fno-lto -Wno-error=free-nonheap-object" \
237
- CFLAGS="-fno-lto"
238
-RUN --mount=type=cache,target=/root/.cache/uv \
239
- --mount=type=bind,from=torch-builder,source=/torchwheels/,target=/torchwheels/,ro \
240
- --mount=type=bind,from=arrow-builder,source=/arrowwheels/,target=/arrowwheels/,ro \
241
- --mount=type=bind,from=cv-builder,source=/opencvwheels/,target=/opencvwheels/,ro \
242
- --mount=type=bind,from=numa-builder,source=/numactl/,target=/numactl/,rw \
243
- --mount=type=bind,from=numba-builder,source=/numbawheels/,target=/numbawheels/,ro \
244
- --mount=type=bind,src=.,dst=/src/,rw \
245
- source /opt/rh/gcc-toolset-14/enable && \
246
- export PATH=$PATH:/usr/lib64/llvm15/bin && \
247
- uv pip install /opencvwheels/*.whl /arrowwheels/*.whl /torchwheels/*.whl /numbawheels/*.whl && \
248
- sed -i -e 's/.*torch.*//g' /src/pyproject.toml /src/requirements/*.txt && \
249
- sed -i -e 's/.*sentencepiece.*//g' /src/pyproject.toml /src/requirements/*.txt && \
250
- uv pip install sentencepiece==0.2.0 pandas pythran nanobind pybind11 /hf_wheels/*.whl && \
251
- make -C /numactl install && \
252
- # sentencepiece.pc is in some pkgconfig inside uv cache
253
- export PKG_CONFIG_PATH=$(find / -type d -name "pkgconfig" 2>/dev/null | tr '\n' ':') && \
254
- nanobind_DIR=$(uv pip show nanobind | grep Location | sed 's/^Location: //;s/$/\/nanobind\/cmake/') && uv pip install -r /src/requirements/common.txt -r /src/requirements/cpu.txt -r /src/requirements/build/cuda.txt --no-build-isolation && \
255
- cd /src/ && \
256
- uv build --wheel --out-dir /vllmwheel/ --no-build-isolation && \
257
- uv pip install /vllmwheel/*.whl
258
-
259
-
260
-###############################################################
261
-# Stage to build lapack
262
-###############################################################
263
-
264
-FROM base-builder AS lapack-builder
265
-
266
-ARG MAX_JOBS
267
-ARG LAPACK_VERSION=3.12.1
268
-RUN git clone --recursive https://github.com/Reference-LAPACK/lapack.git -b v${LAPACK_VERSION} \
269
- && cd lapack && source /opt/rh/gcc-toolset-14/enable \
270
- && cmake -B build -S . \
271
- && cmake --build build -j ${MAX_JOBS:-$(nproc)}
272
-
54
+ export PATH=/opt/rh/gcc-toolset-14/root/usr/bin:$PATH && \
55
+ export CC=/opt/rh/gcc-toolset-14/root/usr/bin/gcc && \
56
+ export CXX=/opt/rh/gcc-toolset-14/root/usr/bin/g++ && \
57
+ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig:$PKG_CONFIG_PATH && \
58
+ export CMAKE_PREFIX_PATH=/usr/local:/usr:$CMAKE_PREFIX_PATH && \
59
+ export Protobuf_PROTOC_EXECUTABLE=/usr/bin/protoc && \
60
+ export CFLAGS="-mcpu=power10 -mtune=power10" && \
61
+ export CXXFLAGS="-mcpu=power10 -mtune=power10" && \
62
+ export DNNL_ARCH_OPT_FLAGS="-mcpu=power10 -mtune=power10" && \
63
+ export C_INCLUDE_PATH=/usr/local/include:$C_INCLUDE_PATH && \
64
+ export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH && \
65
+ uv pip install 'setuptools>=78.1.1' && \
66
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/OpenBLAS/lib/:/usr/local/lib64:/usr/local/lib && \
67
+ export LIBGOMP=/opt/rh/gcc-toolset-14/root/usr/lib/gcc/ppc64le-redhat-linux/14/libgomp.so && \
68
+
69
+ export CMAKE_LIBRARY_PATH=$(dirname $LIBGOMP):${CMAKE_LIBRARY_PATH} && \
70
+ export LIBRARY_PATH=$(dirname $LIBGOMP):${LIBRARY_PATH} && \
71
+ export LD_LIBRARY_PATH=$(dirname $LIBGOMP):${LD_LIBRARY_PATH} && \
72
+
73
+ echo "LIBGOMP=${LIBGOMP}" && \
74
+ find /root/.cache/uv -name "*.whl" && \
75
+ SETUPTOOLS_SCM_PRETEND_VERSION="$VLLM_VERSION" uv build \
76
+ --wheel --out-dir ${WHEEL_DIR} --no-build-isolation && \
77
+ uv pip install "$(echo ${WHEEL_DIR}/vllm*.whl)[tensorizer]" --refresh
78
79
###############################################################
80
# FINAL VLLM IMAGE STAGE #
@@ -278,72 +83,74 @@ RUN git clone --recursive https://github.com/Reference-LAPACK/lapack.git -b v${L
83
FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS vllm-openai
84
85
ARG PYTHON_VERSION=3.12
281
-ARG OPENBLAS_VERSION=0.3.30
86
+ENV VLLM_NO_USAGE_STATS=1
87
88
# Set Environment Variables for venv & openblas
89
ENV VIRTUAL_ENV=/opt/vllm
285
-ENV PATH=${VIRTUAL_ENV}/bin:$PATH
286
-ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
287
-ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib
90
+ENV PCP_DIR=/opt/rh/gcc-toolset-14/root
91
+ENV PATH=${VIRTUAL_ENV}/bin:${PCP_DIR}/usr/bin:/usr/local/bin:$PATH
92
+ENV PKG_CONFIG_PATH=${PCP_DIR}/usr/lib64/pkgconfig:/usr/local/lib/pkgconfig/
93
+ENV C_INCLUDE_PATH="/usr/local/include:$C_INCLUDE_PATH"
94
+ENV LD_LIBRARY_PATH=${PCP_DIR}/usr/lib64:${PCP_DIR}/usr/lib:${VIRTUAL_ENV}/lib64/python${PYTHON_VERSION}/site-packages/torch/lib:/usr/local/lib:$LD_LIBRARY_PATH:/usr/local/lib64:/usr/lib64:/usr/lib
95
ENV UV_LINK_MODE=copy
289
-ENV OMP_NUM_THREADS=16
290
-
291
-# create artificial dependencies between stages for independent stages to build in parallel
292
-COPY --from=torch-builder /tmp/control /dev/null
293
-COPY --from=arrow-builder /tmp/control /dev/null
294
-COPY --from=cv-builder /tmp/control /dev/null
295
-COPY --from=vllmcache-builder /tmp/control /dev/null
296
-COPY --from=numa-builder /tmp/control /dev/null
297
-COPY --from=lapack-builder /tmp/control /dev/null
298
-COPY --from=openblas-builder /tmp/control /dev/null
299
-COPY --from=numba-builder /tmp/control /dev/null
300
-
301
-# install gcc-11, python, openblas, numactl, lapack
96
+ARG VLLM_VERSION="0.22.1"
97
+ARG UV_EXTRA_INDEX_URL="https://wheels.developerfirst.ibm.com/ppc64le/linux/+simple/"
98
+ENV UV_EXTRA_INDEX_URL=${UV_EXTRA_INDEX_URL}
99
+ENV UV_INDEX_STRATEGY=first-match
100
+
101
+
102
RUN --mount=type=cache,target=/root/.cache/uv \
303
- --mount=type=bind,from=numa-builder,source=/numactl/,target=/numactl/,rw \
304
- --mount=type=bind,from=lapack-builder,source=/lapack/,target=/lapack/,rw \
305
- --mount=type=bind,from=openblas-builder,source=/OpenBLAS-$OPENBLAS_VERSION/,target=/openblas/,rw \
103
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
104
microdnf install --nodocs -y \
308
- libomp libicu tar findutils openssl llvm15 llvm15-devel \
309
- pkgconfig xsimd g++ gcc-fortran libsndfile \
105
+ libomp libicu tar autoconf automake libtool findutils openssl numactl numactl-devel \
106
+ pkgconfig xsimd gcc-toolset-14 libsndfile \
107
libtiff libjpeg openjpeg2 zlib zeromq \
108
freetype lcms2 libwebp tcl tk utf8proc \
312
- harfbuzz fribidi libraqm libimagequant libxcb util-linux \
109
+ harfbuzz fribidi libraqm libimagequant libxcb util-linux gperftools-libs \
110
python${PYTHON_VERSION}-devel python${PYTHON_VERSION}-pip \
314
- && export PATH=$PATH:/usr/lib64/llvm15/bin && microdnf clean all \
315
- && python${PYTHON_VERSION} -m venv ${VIRTUAL_ENV} \
316
- && python -m pip install -U pip uv --no-cache \
317
- && make -C /numactl install \
318
- && PREFIX=/usr/local make -C /openblas install \
319
- && uv pip install 'cmake<4' \
320
- && cmake --install /lapack/build \
321
- && uv pip uninstall cmake
322
-
323
-# consume previously built wheels (including vllm)
324
-RUN --mount=type=cache,target=/root/.cache/uv \
325
- --mount=type=bind,from=torch-builder,source=/torchwheels/,target=/torchwheels/,ro \
326
- --mount=type=bind,from=arrow-builder,source=/arrowwheels/,target=/arrowwheels/,ro \
327
- --mount=type=bind,from=cv-builder,source=/opencvwheels/,target=/opencvwheels/,ro \
328
- --mount=type=bind,from=vllmcache-builder,source=/hf_wheels/,target=/hf_wheels/,ro \
329
- --mount=type=bind,from=vllmcache-builder,source=/vllmwheel/,target=/vllmwheel/,ro \
330
- --mount=type=bind,from=numba-builder,source=/numbawheels/,target=/numbawheels/,ro \
331
- export PKG_CONFIG_PATH=$(find / -type d -name "pkgconfig" 2>/dev/null | tr '\n' ':') && uv pip install sentencepiece==0.2.0 && \
332
- HOME=/root uv pip install /opencvwheels/*.whl /arrowwheels/*.whl /torchwheels/*.whl /numbawheels/*.whl /hf_wheels/*.whl /vllmwheel/*.whl
333
-
334
-
335
-COPY ./ /workspace/vllm
336
-WORKDIR /workspace/vllm
337
-ARG GIT_REPO_CHECK=0
338
-RUN --mount=type=bind,source=.git,target=.git \
339
- if [ "$GIT_REPO_CHECK" != 0 ]; then bash tools/check_repo.sh; fi
340
-
341
-# install development dependencies (for testing)
342
-RUN --mount=type=cache,target=/root/.cache/uv \
343
- uv pip install -e tests/vllm_test_utils
111
+ && source /opt/rh/gcc-toolset-14/enable \
112
+ && microdnf update -y \
113
+ && microdnf clean all
114
345
-WORKDIR /workspace/
115
+# The `lscpu` command was added as a requirement in part of https://github.com/vllm-project/vllm/pull/21032, so installing it.
116
+RUN microdnf install --nodocs -y util-linux && \
117
+ microdnf clean all
118
347
-RUN ln -s /workspace/vllm/tests && ln -s /workspace/vllm/examples && ln -s /workspace/vllm/benchmarks
119
+COPY --from=builder-base /usr/lib64/libprotobuf.so.25 /usr/lib64/
120
+COPY --from=builder-base /usr/lib64/libprotobuf.so.25.0.0 /usr/lib64/
121
+
122
+# Use builder venv in final stage instead of wheel reinstallation
123
+COPY --from=builder-base /opt/vllm /opt/vllm
124
+
125
+ENV LD_PRELOAD=/usr/lib64/libtcmalloc.so.4
126
+
127
+WORKDIR /home/vllm
128
+
129
+# setup non-root user for OpenShift
130
+RUN umask 002 && \
131
+ useradd --uid 2000 --gid 0 vllm && \
132
+ mkdir -p /home/vllm && \
133
+ chmod g+rwx /home/vllm
134
+
135
+ENV HOME=/home/vllm
136
+
137
+# Add labels to document build configuration
138
+LABEL org.opencontainers.image.title="vLLM CPU"
139
+LABEL org.opencontainers.image.description="vLLM inference engine for CPU platforms"
140
+LABEL org.opencontainers.image.vendor="vLLM Project"
141
+LABEL org.opencontainers.image.source="https://github.com/vllm-project/vllm"
142
+
143
+# Build configuration labels
144
+ARG TARGETARCH
145
+ARG VLLM_CPU_PPC64LE
146
+ARG PYTHON_VERSION
147
+
148
+LABEL ai.vllm.build.target-arch="${TARGETARCH}"
149
+LABEL ai.vllm.build.cpu-ppc64le="${VLLM_CPU_PPC64LE:-false}"
150
+LABEL ai.vllm.build.python-version="${PYTHON_VERSION:-3.12}"
151
+
152
+USER 2000
153
154
ENTRYPOINT ["vllm", "serve"]
155
+
156
+