Skip to content

Commit 819a98a

Browse files
committed
Sync with main @ 631274f
2 parents 9d1fd03 + 631274f commit 819a98a

File tree

1 file changed

+98
-12
lines changed

1 file changed

+98
-12
lines changed

Dockerfile.ppc64le.ubi

Lines changed: 98 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
ARG BASE_UBI_IMAGE_TAG=9.5-1741599792
2+
23
###############################################################
34
# base stage with basic dependencies
45
###############################################################
6+
57
FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS base-builder
8+
69
ARG PYTHON_VERSION=3.12
710
ARG OPENBLAS_VERSION=0.3.29
11+
812
# Set Environment Variables for venv, cargo & openblas
913
ENV VIRTUAL_ENV=/opt/vllm
1014
ENV PATH=${VIRTUAL_ENV}/bin:/root/.cargo/bin:$PATH
1115
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
1216
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib
17+
1318
# install gcc-13, python, rust, openblas
14-
# Note: A symlink for libatomic.so is created for gcc-13 (linker fails to find to find libatomic otherwise - reqd. for sentencepiece)
19+
# Note: A symlink for libatomic.so is created for gcc-13 (linker fails to find libatomic otherwise - reqd. for sentencepiece)
1520
# Note: A dummy file 'control' is created in /tmp/ to artificially create dependencies between stages when building stages in parallel
1621
# when `--jobs=<N>` is passed with podman build command
1722
RUN microdnf install -y dnf \
@@ -22,7 +27,7 @@ RUN microdnf install -y dnf \
2227
&& dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream/`arch`/os \
2328
&& dnf config-manager --set-enabled crb \
2429
&& dnf install -y \
25-
git tar gcc-toolset-13 numactl-devel lapack-devel \
30+
git tar gcc-toolset-13 automake libtool numactl-devel lapack-devel \
2631
pkgconfig openssl-devel xsimd zeromq-devel kmod \
2732
libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
2833
freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
@@ -36,17 +41,22 @@ RUN microdnf install -y dnf \
3641
&& curl -sL https://ftp2.osuosl.org/pub/ppc64el/openblas/latest/Openblas_${OPENBLAS_VERSION}_ppc64le.tar.gz | tar xvf - -C /usr/local \
3742
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
3843
&& cd /tmp && touch control
44+
45+
3946
###############################################################
4047
# Stage to build torch family
4148
###############################################################
49+
4250
FROM base-builder AS torch-builder
51+
4352
# build cache without torch dependent packages
4453
# sentencepiece has linker issues otherwise
4554
RUN --mount=type=cache,target=/root/.cache/uv \
4655
--mount=type=bind,src=requirements-common.txt,dst=/requirements-common.txt,ro \
4756
source /opt/rh/gcc-toolset-13/enable && \
4857
sed -e 's/.*opencv.*//g; s/.*outlines.*//g; s/.*tensors.*//g' requirements-common.txt | uv pip install -r /dev/stdin && \
4958
uv pip list
59+
5060
ARG MAX_JOBS
5161
ARG TORCH_VERSION=2.5.1
5262
ARG _GLIBCXX_USE_CXX11_ABI=1
@@ -59,6 +69,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
5969
rm -f dist/torch*+git*whl && \
6070
MAX_JOBS=${MAX_JOBS:-$(nproc)} \
6171
PYTORCH_BUILD_VERSION=${TORCH_VERSION} PYTORCH_BUILD_NUMBER=1 uv build --wheel --out-dir /torchwheels/
72+
6273
ARG TORCHVISION_VERSION=0.20.1
6374
ARG TORCHVISION_USE_NVJPEG=0
6475
ARG TORCHVISION_USE_FFMPEG=0
@@ -69,6 +80,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
6980
MAX_JOBS=${MAX_JOBS:-$(nproc)} \
7081
BUILD_VERSION=${TORCHVISION_VERSION} \
7182
uv build --wheel --out-dir /torchwheels/ --no-build-isolation
83+
7284
ARG TORCHAUDIO_VERSION=2.5.1
7385
ARG BUILD_SOX=1
7486
ARG BUILD_KALDI=1
@@ -84,17 +96,22 @@ RUN --mount=type=cache,target=/root/.cache/uv \
8496
MAX_JOBS=${MAX_JOBS:-$(nproc)} \
8597
BUILD_VERSION=${TORCHAUDIO_VERSION} \
8698
uv build --wheel --out-dir /torchwheels/ --no-build-isolation
99+
87100
# build cache with torch dependent packages
88101
RUN --mount=type=cache,target=/root/.cache/uv \
89102
--mount=type=bind,src=requirements-common.txt,dst=/requirements-common.txt,ro \
90103
source /opt/rh/gcc-toolset-13/enable && \
91104
grep "outlines" requirements-common.txt | uv pip install -r /dev/stdin && \
92105
grep "tensors" requirements-common.txt | uv pip install -r /dev/stdin && \
93106
uv pip list
107+
108+
94109
###############################################################
95110
# Stage to build pyarrow
96111
###############################################################
112+
97113
FROM base-builder AS arrow-builder
114+
98115
ARG MAX_JOBS
99116
ARG PYARROW_PARALLEL
100117
ARG PYARROW_VERSION=19.0.1
@@ -118,10 +135,14 @@ RUN --mount=type=cache,target=/root/.cache/uv \
118135
python setup.py build_ext \
119136
--build-type=release --bundle-arrow-cpp \
120137
bdist_wheel --dist-dir /arrowwheels/
138+
139+
121140
###############################################################
122141
# Stage to build opencv
123142
###############################################################
143+
124144
FROM base-builder AS cv-builder
145+
125146
ARG MAX_JOBS
126147
ARG OPENCV_VERSION=84
127148
ARG ENABLE_HEADLESS=1
@@ -131,6 +152,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
131152
cd opencv-python && \
132153
sed -i 's/"setuptools==59.2.0",/"setuptools<70.0",/g' pyproject.toml && \
133154
python -m build --wheel --installer=uv --outdir /opencvwheels/
155+
134156
# build opencv dependent packages
135157
RUN --mount=type=cache,target=/root/.cache/uv \
136158
--mount=type=bind,src=requirements-common.txt,dst=/requirements-common.txt,ro \
@@ -139,18 +161,24 @@ RUN --mount=type=cache,target=/root/.cache/uv \
139161
uv pip list | grep opencv && \
140162
grep "opencv" requirements-common.txt | uv pip install -r /dev/stdin --no-build-isolation && \
141163
uv pip list
164+
165+
142166
###############################################################
143167
# Stage to build vllm - this stage builds and installs
144168
# vllm, tensorizer and vllm-tgis-adapter and builds uv cache
145169
# for transitive dependencies - eg. grpcio
146170
###############################################################
171+
147172
FROM base-builder AS vllmcache-builder
173+
148174
COPY --from=torch-builder /tmp/control /dev/null
149175
COPY --from=arrow-builder /tmp/control /dev/null
150176
COPY --from=cv-builder /tmp/control /dev/null
177+
151178
ARG VLLM_TGIS_ADAPTER_VERSION=0.6.3
152179
ARG VLLM_TARGET_DEVICE=cpu
153180
ARG GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
181+
154182
# this step installs vllm & tgis adapter and populates uv cache
155183
# with all the transitive dependencies
156184
RUN --mount=type=cache,target=/root/.cache/uv \
@@ -166,48 +194,97 @@ RUN --mount=type=cache,target=/root/.cache/uv \
166194
cd /src/ && \
167195
uv build --wheel --out-dir /vllmwheel/ --no-build-isolation && \
168196
uv pip install "$(echo /vllmwheel/*.whl)[tensorizer]" vllm-tgis-adapter==${VLLM_TGIS_ADAPTER_VERSION}
197+
198+
199+
###############################################################
200+
# Stage to build numactl
201+
###############################################################
202+
203+
FROM base-builder AS numa-builder
204+
205+
# Note: Building numactl with gcc-11. Compiling with gcc-13 in this builder stage will
206+
# trigger recompilation with gcc-11 (and require libtool) in the final stage where we do not have gcc-13
207+
ARG MAX_JOBS
208+
ARG NUMACTL_VERSION=2.0.19
209+
RUN git clone --recursive https://github.com/numactl/numactl.git -b v${NUMACTL_VERSION} \
210+
&& cd numactl \
211+
&& autoreconf -i && ./configure \
212+
&& make -j ${MAX_JOBS:-$(nproc)}
213+
214+
###############################################################
215+
# Stage to build lapack
216+
###############################################################
217+
218+
FROM base-builder AS lapack-builder
219+
220+
ARG MAX_JOBS
221+
ARG LAPACK_VERSION=3.12.1
222+
RUN git clone --recursive https://github.com/Reference-LAPACK/lapack.git -b v${LAPACK_VERSION} \
223+
&& cd lapack && source /opt/rh/gcc-toolset-13/enable \
224+
&& cmake -B build -S . \
225+
&& cmake --build build -j ${MAX_JOBS:-$(nproc)}
226+
227+
169228
###############################################################
170229
# FINAL VLLM IMAGE STAGE #
171230
###############################################################
231+
172232
FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS vllm-openai
233+
173234
ARG PYTHON_VERSION=3.12
174235
ARG OPENBLAS_VERSION=0.3.29
236+
175237
# Set Environment Variables for venv & openblas
176238
ENV VIRTUAL_ENV=/opt/vllm
177239
ENV PATH=${VIRTUAL_ENV}/bin:$PATH
178240
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
179241
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib
180-
# install gcc-13, python, openblas
181-
RUN rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
242+
243+
# create artificial dependencies between stages for independent stages to build in parallel
244+
COPY --from=torch-builder /tmp/control /dev/null
245+
COPY --from=arrow-builder /tmp/control /dev/null
246+
COPY --from=cv-builder /tmp/control /dev/null
247+
COPY --from=vllmcache-builder /tmp/control /dev/null
248+
COPY --from=numa-builder /tmp/control /dev/null
249+
COPY --from=lapack-builder /tmp/control /dev/null
250+
251+
# install gcc-11, python, openblas, numactl, lapack
252+
RUN --mount=type=cache,target=/root/.cache/uv \
253+
--mount=type=bind,from=numa-builder,source=/numactl/,target=/numactl/,rw \
254+
--mount=type=bind,from=lapack-builder,source=/lapack/,target=/lapack/,rw \
255+
rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm && \
182256
microdnf install --nodocs -y \
183-
tar findutils openssl numactl lapack \
184-
pkgconfig xsimd g++ libsndfile \
257+
tar findutils openssl \
258+
pkgconfig xsimd g++ gcc-fortran libsndfile \
185259
libtiff libjpeg openjpeg2 zlib zeromq \
186260
freetype lcms2 libwebp tcl tk utf8proc \
187261
harfbuzz fribidi libraqm libimagequant libxcb \
188262
python${PYTHON_VERSION}-devel python${PYTHON_VERSION}-pip \
189263
&& microdnf clean all \
190264
&& python${PYTHON_VERSION} -m venv ${VIRTUAL_ENV} \
191265
&& python -m pip install -U pip uv --no-cache \
192-
&& curl -sL https://ftp2.osuosl.org/pub/ppc64el/openblas/latest/Openblas_${OPENBLAS_VERSION}_ppc64le.tar.gz | tar xvf - -C /usr/local
193-
# create artificial dependencies between stages for independent stages to build in parallel
194-
COPY --from=torch-builder /tmp/control /dev/null
195-
COPY --from=arrow-builder /tmp/control /dev/null
196-
COPY --from=cv-builder /tmp/control /dev/null
197-
COPY --from=vllmcache-builder /tmp/control /dev/null
266+
&& curl -sL https://ftp2.osuosl.org/pub/ppc64el/openblas/latest/Openblas_${OPENBLAS_VERSION}_ppc64le.tar.gz | tar xvf - -C /usr/local \
267+
&& make -C /numactl install \
268+
&& uv pip install cmake \
269+
&& cmake --install /lapack/build \
270+
&& uv pip uninstall cmake
271+
198272
# consume previously built wheels
199273
RUN --mount=type=cache,target=/root/.cache/uv \
200274
--mount=type=bind,from=torch-builder,source=/torchwheels/,target=/torchwheels/,ro \
201275
--mount=type=bind,from=arrow-builder,source=/arrowwheels/,target=/arrowwheels/,ro \
202276
--mount=type=bind,from=cv-builder,source=/opencvwheels/,target=/opencvwheels/,ro \
203277
--mount=type=bind,from=vllmcache-builder,source=/vllmwheel/,target=/vllmwheel/,ro \
204278
HOME=/root uv pip install /opencvwheels/*.whl /arrowwheels/*.whl /torchwheels/*.whl /vllmwheel/*.whl
279+
205280
WORKDIR /home/vllm
281+
206282
# setup non-root user for OpenShift
207283
RUN umask 002 && \
208284
useradd --uid 2000 --gid 0 vllm && \
209285
mkdir -p /home/vllm && \
210286
chmod g+rwx /home/vllm
287+
211288
ENV HF_HUB_OFFLINE=0 \
212289
HOME=/home/vllm \
213290
# Allow requested max length to exceed what is extracted from the
@@ -218,22 +295,31 @@ ENV HF_HUB_OFFLINE=0 \
218295
VLLM_WORKER_MULTIPROC_METHOD=fork \
219296
VLLM_NO_USAGE_STATS=1 \
220297
OUTLINES_CACHE_DIR=/tmp/outlines
298+
221299
COPY LICENSE /licenses/vllm.md
222300
COPY examples/*.jinja /app/data/template/
301+
223302
USER 2000
303+
224304
ENTRYPOINT ["python", "-m", "vllm.entrypoints.openai.api_server"]
305+
225306
FROM vllm-openai as vllm-grpc-adapter
307+
226308
USER root
309+
227310
ARG VLLM_TGIS_ADAPTER_VERSION=0.6.3
228311
RUN --mount=type=cache,target=/root/.cache/uv \
229312
--mount=type=bind,from=vllmcache-builder,source=/vllmwheel/,target=/vllmwheel/,ro \
230313
HOME=/root uv pip install "$(echo /vllmwheel/*.whl)[tensorizer]" vllm-tgis-adapter==${VLLM_TGIS_ADAPTER_VERSION}
314+
231315
ENV GRPC_PORT=8033 \
232316
PORT=8000 \
233317
# As an optimization, vLLM disables logprobs when using spec decoding by
234318
# default, but this would be unexpected to users of a hosted model that
235319
# happens to have spec decoding
236320
# see: https://github.com/vllm-project/vllm/pull/6485
237321
DISABLE_LOGPROBS_DURING_SPEC_DECODING=false
322+
238323
USER 2000
324+
239325
ENTRYPOINT ["python", "-m", "vllm_tgis_adapter", "--uvicorn-log-level=warning"]

0 commit comments

Comments
 (0)