1
1
ARG BASE_UBI_IMAGE_TAG=9.5-1741599792
2
+
2
3
###############################################################
3
4
# base stage with basic dependencies
4
5
###############################################################
6
+
5
7
FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS base-builder
8
+
6
9
ARG PYTHON_VERSION=3.12
7
10
ARG OPENBLAS_VERSION=0.3.29
11
+
8
12
# Set Environment Variables for venv, cargo & openblas
9
13
ENV VIRTUAL_ENV=/opt/vllm
10
14
ENV PATH=${VIRTUAL_ENV}/bin:/root/.cargo/bin:$PATH
11
15
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
12
16
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib
17
+
13
18
# 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)
15
20
# Note: A dummy file 'control' is created in /tmp/ to artificially create dependencies between stages when building stages in parallel
16
21
# when `--jobs=<N>` is passed with podman build command
17
22
RUN microdnf install -y dnf \
@@ -22,7 +27,7 @@ RUN microdnf install -y dnf \
22
27
&& dnf config-manager --add-repo https://mirror.stream.centos.org/9-stream/AppStream/`arch`/os \
23
28
&& dnf config-manager --set-enabled crb \
24
29
&& 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 \
26
31
pkgconfig openssl-devel xsimd zeromq-devel kmod \
27
32
libtiff-devel libjpeg-devel openjpeg2-devel zlib-devel \
28
33
freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel \
@@ -36,17 +41,22 @@ RUN microdnf install -y dnf \
36
41
&& curl -sL https://ftp2.osuosl.org/pub/ppc64el/openblas/latest/Openblas_${OPENBLAS_VERSION}_ppc64le.tar.gz | tar xvf - -C /usr/local \
37
42
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
38
43
&& cd /tmp && touch control
44
+
45
+
39
46
###############################################################
40
47
# Stage to build torch family
41
48
###############################################################
49
+
42
50
FROM base-builder AS torch-builder
51
+
43
52
# build cache without torch dependent packages
44
53
# sentencepiece has linker issues otherwise
45
54
RUN --mount=type=cache,target=/root/.cache/uv \
46
55
--mount=type=bind,src=requirements-common.txt,dst=/requirements-common.txt,ro \
47
56
source /opt/rh/gcc-toolset-13/enable && \
48
57
sed -e 's/.*opencv.*//g; s/.*outlines.*//g; s/.*tensors.*//g' requirements-common.txt | uv pip install -r /dev/stdin && \
49
58
uv pip list
59
+
50
60
ARG MAX_JOBS
51
61
ARG TORCH_VERSION=2.5.1
52
62
ARG _GLIBCXX_USE_CXX11_ABI=1
@@ -59,6 +69,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
59
69
rm -f dist/torch*+git*whl && \
60
70
MAX_JOBS=${MAX_JOBS:-$(nproc)} \
61
71
PYTORCH_BUILD_VERSION=${TORCH_VERSION} PYTORCH_BUILD_NUMBER=1 uv build --wheel --out-dir /torchwheels/
72
+
62
73
ARG TORCHVISION_VERSION=0.20.1
63
74
ARG TORCHVISION_USE_NVJPEG=0
64
75
ARG TORCHVISION_USE_FFMPEG=0
@@ -69,6 +80,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
69
80
MAX_JOBS=${MAX_JOBS:-$(nproc)} \
70
81
BUILD_VERSION=${TORCHVISION_VERSION} \
71
82
uv build --wheel --out-dir /torchwheels/ --no-build-isolation
83
+
72
84
ARG TORCHAUDIO_VERSION=2.5.1
73
85
ARG BUILD_SOX=1
74
86
ARG BUILD_KALDI=1
@@ -84,17 +96,22 @@ RUN --mount=type=cache,target=/root/.cache/uv \
84
96
MAX_JOBS=${MAX_JOBS:-$(nproc)} \
85
97
BUILD_VERSION=${TORCHAUDIO_VERSION} \
86
98
uv build --wheel --out-dir /torchwheels/ --no-build-isolation
99
+
87
100
# build cache with torch dependent packages
88
101
RUN --mount=type=cache,target=/root/.cache/uv \
89
102
--mount=type=bind,src=requirements-common.txt,dst=/requirements-common.txt,ro \
90
103
source /opt/rh/gcc-toolset-13/enable && \
91
104
grep "outlines" requirements-common.txt | uv pip install -r /dev/stdin && \
92
105
grep "tensors" requirements-common.txt | uv pip install -r /dev/stdin && \
93
106
uv pip list
107
+
108
+
94
109
###############################################################
95
110
# Stage to build pyarrow
96
111
###############################################################
112
+
97
113
FROM base-builder AS arrow-builder
114
+
98
115
ARG MAX_JOBS
99
116
ARG PYARROW_PARALLEL
100
117
ARG PYARROW_VERSION=19.0.1
@@ -118,10 +135,14 @@ RUN --mount=type=cache,target=/root/.cache/uv \
118
135
python setup.py build_ext \
119
136
--build-type=release --bundle-arrow-cpp \
120
137
bdist_wheel --dist-dir /arrowwheels/
138
+
139
+
121
140
###############################################################
122
141
# Stage to build opencv
123
142
###############################################################
143
+
124
144
FROM base-builder AS cv-builder
145
+
125
146
ARG MAX_JOBS
126
147
ARG OPENCV_VERSION=84
127
148
ARG ENABLE_HEADLESS=1
@@ -131,6 +152,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
131
152
cd opencv-python && \
132
153
sed -i 's/"setuptools==59.2.0",/"setuptools<70.0",/g' pyproject.toml && \
133
154
python -m build --wheel --installer=uv --outdir /opencvwheels/
155
+
134
156
# build opencv dependent packages
135
157
RUN --mount=type=cache,target=/root/.cache/uv \
136
158
--mount=type=bind,src=requirements-common.txt,dst=/requirements-common.txt,ro \
@@ -139,18 +161,24 @@ RUN --mount=type=cache,target=/root/.cache/uv \
139
161
uv pip list | grep opencv && \
140
162
grep "opencv" requirements-common.txt | uv pip install -r /dev/stdin --no-build-isolation && \
141
163
uv pip list
164
+
165
+
142
166
###############################################################
143
167
# Stage to build vllm - this stage builds and installs
144
168
# vllm, tensorizer and vllm-tgis-adapter and builds uv cache
145
169
# for transitive dependencies - eg. grpcio
146
170
###############################################################
171
+
147
172
FROM base-builder AS vllmcache-builder
173
+
148
174
COPY --from=torch-builder /tmp/control /dev/null
149
175
COPY --from=arrow-builder /tmp/control /dev/null
150
176
COPY --from=cv-builder /tmp/control /dev/null
177
+
151
178
ARG VLLM_TGIS_ADAPTER_VERSION=0.6.3
152
179
ARG VLLM_TARGET_DEVICE=cpu
153
180
ARG GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
181
+
154
182
# this step installs vllm & tgis adapter and populates uv cache
155
183
# with all the transitive dependencies
156
184
RUN --mount=type=cache,target=/root/.cache/uv \
@@ -166,48 +194,97 @@ RUN --mount=type=cache,target=/root/.cache/uv \
166
194
cd /src/ && \
167
195
uv build --wheel --out-dir /vllmwheel/ --no-build-isolation && \
168
196
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
+
169
228
###############################################################
170
229
# FINAL VLLM IMAGE STAGE #
171
230
###############################################################
231
+
172
232
FROM registry.access.redhat.com/ubi9/ubi-minimal:${BASE_UBI_IMAGE_TAG} AS vllm-openai
233
+
173
234
ARG PYTHON_VERSION=3.12
174
235
ARG OPENBLAS_VERSION=0.3.29
236
+
175
237
# Set Environment Variables for venv & openblas
176
238
ENV VIRTUAL_ENV=/opt/vllm
177
239
ENV PATH=${VIRTUAL_ENV}/bin:$PATH
178
240
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
179
241
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 && \
182
256
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 \
185
259
libtiff libjpeg openjpeg2 zlib zeromq \
186
260
freetype lcms2 libwebp tcl tk utf8proc \
187
261
harfbuzz fribidi libraqm libimagequant libxcb \
188
262
python${PYTHON_VERSION}-devel python${PYTHON_VERSION}-pip \
189
263
&& microdnf clean all \
190
264
&& python${PYTHON_VERSION} -m venv ${VIRTUAL_ENV} \
191
265
&& 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
+
198
272
# consume previously built wheels
199
273
RUN --mount=type=cache,target=/root/.cache/uv \
200
274
--mount=type=bind,from=torch-builder,source=/torchwheels/,target=/torchwheels/,ro \
201
275
--mount=type=bind,from=arrow-builder,source=/arrowwheels/,target=/arrowwheels/,ro \
202
276
--mount=type=bind,from=cv-builder,source=/opencvwheels/,target=/opencvwheels/,ro \
203
277
--mount=type=bind,from=vllmcache-builder,source=/vllmwheel/,target=/vllmwheel/,ro \
204
278
HOME=/root uv pip install /opencvwheels/*.whl /arrowwheels/*.whl /torchwheels/*.whl /vllmwheel/*.whl
279
+
205
280
WORKDIR /home/vllm
281
+
206
282
# setup non-root user for OpenShift
207
283
RUN umask 002 && \
208
284
useradd --uid 2000 --gid 0 vllm && \
209
285
mkdir -p /home/vllm && \
210
286
chmod g+rwx /home/vllm
287
+
211
288
ENV HF_HUB_OFFLINE=0 \
212
289
HOME=/home/vllm \
213
290
# Allow requested max length to exceed what is extracted from the
@@ -218,22 +295,31 @@ ENV HF_HUB_OFFLINE=0 \
218
295
VLLM_WORKER_MULTIPROC_METHOD=fork \
219
296
VLLM_NO_USAGE_STATS=1 \
220
297
OUTLINES_CACHE_DIR=/tmp/outlines
298
+
221
299
COPY LICENSE /licenses/vllm.md
222
300
COPY examples/*.jinja /app/data/template/
301
+
223
302
USER 2000
303
+
224
304
ENTRYPOINT ["python", "-m", "vllm.entrypoints.openai.api_server"]
305
+
225
306
FROM vllm-openai as vllm-grpc-adapter
307
+
226
308
USER root
309
+
227
310
ARG VLLM_TGIS_ADAPTER_VERSION=0.6.3
228
311
RUN --mount=type=cache,target=/root/.cache/uv \
229
312
--mount=type=bind,from=vllmcache-builder,source=/vllmwheel/,target=/vllmwheel/,ro \
230
313
HOME=/root uv pip install "$(echo /vllmwheel/*.whl)[tensorizer]" vllm-tgis-adapter==${VLLM_TGIS_ADAPTER_VERSION}
314
+
231
315
ENV GRPC_PORT=8033 \
232
316
PORT=8000 \
233
317
# As an optimization, vLLM disables logprobs when using spec decoding by
234
318
# default, but this would be unexpected to users of a hosted model that
235
319
# happens to have spec decoding
236
320
# see: https://github.com/vllm-project/vllm/pull/6485
237
321
DISABLE_LOGPROBS_DURING_SPEC_DECODING=false
322
+
238
323
USER 2000
324
+
239
325
ENTRYPOINT ["python", "-m", "vllm_tgis_adapter", "--uvicorn-log-level=warning"]
0 commit comments