@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / d9292786e1
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 15, 21:00 UTC

[CI/Build] Use uv python for docker rather than ppa:deadsnakes/ppa (#13569)

Signed-off-by: mgoin <mgoin64@gmail.com>

Michael Goin committed Mar 6, 2025 at 16:08 UTC d9292786e106f62c7315832d26d2ffb4eb28f023
1 file changed +38 -44
Dockerfile
+38 -44
@@ -14,22 +14,19 @@ ARG PYTHON_VERSION=3.12
14 ARG TARGETPLATFORM
15 ENV DEBIAN_FRONTEND=noninteractive
16
17 -# Install Python and other dependencies
17 +# Install minimal dependencies and uv
18 RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
19 && echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
20 && apt-get update -y \
21 - && apt-get install -y ccache software-properties-common git curl sudo \
22 - && add-apt-repository ppa:deadsnakes/ppa \
23 - && apt-get update -y \
24 - && apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv \
25 - && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
26 - && update-alternatives --set python3 /usr/bin/python${PYTHON_VERSION} \
27 - && ln -sf /usr/bin/python${PYTHON_VERSION}-config /usr/bin/python3-config \
28 - && curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \
29 - && python3 --version && python3 -m pip --version
30 -# Install uv for faster pip installs
31 -RUN --mount=type=cache,target=/root/.cache/uv \
32 - python3 -m pip install uv
21 + && apt-get install -y ccache git curl wget sudo \
22 + && curl -LsSf https://astral.sh/uv/install.sh | sh
23 +
24 +# Add uv to PATH
25 +ENV PATH="/root/.local/bin:$PATH"
26 +# Create venv with specified Python and activate by placing at the front of path
27 +ENV VIRTUAL_ENV="/opt/venv"
28 +RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV}
29 +ENV PATH="$VIRTUAL_ENV/bin:$PATH"
30
31 # This timeout (in seconds) is necessary when installing some dependencies via uv since it's likely to time out
32 # Reference: https://github.com/astral-sh/uv/pull/1694
@@ -51,21 +48,19 @@ RUN ldconfig /usr/local/cuda-$(echo $CUDA_VERSION | cut -d. -f1,2)/compat/
48
49 WORKDIR /workspace
50
54 -# install build and runtime dependencies
55 -
51 # arm64 (GH200) build follows the practice of "use existing pytorch" build,
52 # we need to install torch and torchvision from the nightly builds first,
53 # pytorch will not appear as a vLLM dependency in all of the following steps
54 # after this step
55 RUN --mount=type=cache,target=/root/.cache/uv \
56 if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
62 - uv pip install --system --index-url https://download.pytorch.org/whl/nightly/cu126 "torch==2.7.0.dev20250121+cu126" "torchvision==0.22.0.dev20250121"; \
57 + uv pip install --index-url https://download.pytorch.org/whl/nightly/cu126 "torch==2.7.0.dev20250121+cu126" "torchvision==0.22.0.dev20250121"; \
58 fi
59
60 COPY requirements-common.txt requirements-common.txt
61 COPY requirements-cuda.txt requirements-cuda.txt
62 RUN --mount=type=cache,target=/root/.cache/uv \
68 - uv pip install --system -r requirements-cuda.txt
63 + uv pip install -r requirements-cuda.txt
64
65 # cuda arch list used by torch
66 # can be useful for both `dev` and `test`
@@ -90,12 +85,12 @@ COPY requirements-build.txt requirements-build.txt
85 ENV UV_HTTP_TIMEOUT=500
86
87 RUN --mount=type=cache,target=/root/.cache/uv \
93 - uv pip install --system -r requirements-build.txt
88 + uv pip install -r requirements-build.txt
89
90 COPY . .
91 ARG GIT_REPO_CHECK=0
92 RUN --mount=type=bind,source=.git,target=.git \
98 - if [ "$GIT_REPO_CHECK" != 0 ]; then bash tools/check_repo.sh ; fi
93 + if [ "$GIT_REPO_CHECK" != "0" ]; then bash tools/check_repo.sh ; fi
94
95 # max jobs used by Ninja to build extensions
96 ARG max_jobs=2
@@ -132,6 +127,9 @@ RUN --mount=type=cache,target=/root/.cache/ccache \
127 --mount=type=cache,target=/root/.cache/uv \
128 --mount=type=bind,source=.git,target=.git \
129 if [ "$USE_SCCACHE" != "1" ]; then \
130 + # Clean any existing CMake artifacts
131 + rm -rf .deps && \
132 + mkdir -p .deps && \
133 python3 setup.py bdist_wheel --dist-dir=dist --py-limited-api=cp38; \
134 fi
135
@@ -159,7 +157,7 @@ COPY requirements-lint.txt requirements-lint.txt
157 COPY requirements-test.txt requirements-test.txt
158 COPY requirements-dev.txt requirements-dev.txt
159 RUN --mount=type=cache,target=/root/.cache/uv \
162 - uv pip install --system -r requirements-dev.txt
160 + uv pip install -r requirements-dev.txt
161 #################### DEV IMAGE ####################
162
163 #################### vLLM installation IMAGE ####################
@@ -175,23 +173,20 @@ ARG TARGETPLATFORM
173 RUN PYTHON_VERSION_STR=$(echo ${PYTHON_VERSION} | sed 's/\.//g') && \
174 echo "export PYTHON_VERSION_STR=${PYTHON_VERSION_STR}" >> /etc/environment
175
178 -# Install Python and other dependencies
176 +# Install minimal dependencies and uv
177 RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
178 && echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
179 && apt-get update -y \
182 - && apt-get install -y ccache software-properties-common git curl wget sudo vim python3-pip \
183 - && apt-get install -y ffmpeg libsm6 libxext6 libgl1 \
184 - && add-apt-repository ppa:deadsnakes/ppa \
185 - && apt-get update -y \
186 - && apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv libibverbs-dev \
187 - && update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
188 - && update-alternatives --set python3 /usr/bin/python${PYTHON_VERSION} \
189 - && ln -sf /usr/bin/python${PYTHON_VERSION}-config /usr/bin/python3-config \
190 - && curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \
191 - && python3 --version && python3 -m pip --version
192 -# Install uv for faster pip installs
193 -RUN --mount=type=cache,target=/root/.cache/uv \
194 - python3 -m pip install uv
180 + && apt-get install -y ccache git curl wget sudo vim \
181 + && apt-get install -y ffmpeg libsm6 libxext6 libgl1 libibverbs-dev \
182 + && curl -LsSf https://astral.sh/uv/install.sh | sh
183 +
184 +# Add uv to PATH
185 +ENV PATH="/root/.local/bin:$PATH"
186 +# Create venv with specified Python and activate by placing at the front of path
187 +ENV VIRTUAL_ENV="/opt/venv"
188 +RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV}
189 +ENV PATH="$VIRTUAL_ENV/bin:$PATH"
190
191 # This timeout (in seconds) is necessary when installing some dependencies via uv since it's likely to time out
192 # Reference: https://github.com/astral-sh/uv/pull/1694
@@ -209,13 +204,13 @@ RUN ldconfig /usr/local/cuda-$(echo $CUDA_VERSION | cut -d. -f1,2)/compat/
204 # after this step
205 RUN --mount=type=cache,target=/root/.cache/uv \
206 if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
212 - uv pip install --system --index-url https://download.pytorch.org/whl/nightly/cu124 "torch==2.6.0.dev20241210+cu124" "torchvision==0.22.0.dev20241215"; \
207 + uv pip install --index-url https://download.pytorch.org/whl/nightly/cu124 "torch==2.6.0.dev20241210+cu124" "torchvision==0.22.0.dev20241215"; \
208 fi
209
210 # Install vllm wheel first, so that torch etc will be installed.
211 RUN --mount=type=bind,from=build,src=/workspace/dist,target=/vllm-workspace/dist \
212 --mount=type=cache,target=/root/.cache/uv \
218 - uv pip install --system dist/*.whl --verbose
213 + uv pip install dist/*.whl --verbose
214
215 # If we need to build FlashInfer wheel before its release:
216 # $ export FLASHINFER_ENABLE_AOT=1
@@ -230,9 +225,8 @@ RUN --mount=type=bind,from=build,src=/workspace/dist,target=/vllm-workspace/dist
225 # $ # upload the wheel to a public location, e.g. https://wheels.vllm.ai/flashinfer/524304395bd1d8cd7d07db083859523fcaa246a4/flashinfer_python-0.2.1.post1+cu124torch2.5-cp38-abi3-linux_x86_64.whl
226
227 RUN --mount=type=cache,target=/root/.cache/uv \
233 -. /etc/environment && \
228 if [ "$TARGETPLATFORM" != "linux/arm64" ]; then \
235 - uv pip install --system https://github.com/flashinfer-ai/flashinfer/releases/download/v0.2.1.post1/flashinfer_python-0.2.1.post1+cu124torch2.5-cp38-abi3-linux_x86_64.whl ; \
229 + uv pip install https://github.com/flashinfer-ai/flashinfer/releases/download/v0.2.1.post1/flashinfer_python-0.2.1.post1+cu124torch2.5-cp38-abi3-linux_x86_64.whl ; \
230 fi
231 COPY examples examples
232
@@ -242,7 +236,7 @@ COPY examples examples
236 # TODO: Remove this once FlashInfer AOT wheel is fixed
237 COPY requirements-build.txt requirements-build.txt
238 RUN --mount=type=cache,target=/root/.cache/uv \
245 - uv pip install --system -r requirements-build.txt
239 + uv pip install -r requirements-build.txt
240
241 #################### vLLM installation IMAGE ####################
242
@@ -259,15 +253,15 @@ ENV UV_HTTP_TIMEOUT=500
253
254 # install development dependencies (for testing)
255 RUN --mount=type=cache,target=/root/.cache/uv \
262 - uv pip install --system -r requirements-dev.txt
256 + uv pip install -r requirements-dev.txt
257
258 # install development dependencies (for testing)
259 RUN --mount=type=cache,target=/root/.cache/uv \
266 - uv pip install --system -e tests/vllm_test_utils
260 + uv pip install -e tests/vllm_test_utils
261
262 # enable fast downloads from hf (for testing)
263 RUN --mount=type=cache,target=/root/.cache/uv \
270 - uv pip install --system hf_transfer
264 + uv pip install hf_transfer
265 ENV HF_HUB_ENABLE_HF_TRANSFER 1
266
267 # Copy in the v1 package for testing (it isn't distributed yet)
@@ -292,9 +286,9 @@ ENV UV_HTTP_TIMEOUT=500
286 # install additional dependencies for openai api server
287 RUN --mount=type=cache,target=/root/.cache/uv \
288 if [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
295 - uv pip install --system accelerate hf_transfer 'modelscope!=1.15.0' 'bitsandbytes>=0.42.0' 'timm==0.9.10' boto3 runai-model-streamer runai-model-streamer[s3]; \
289 + uv pip install accelerate hf_transfer 'modelscope!=1.15.0' 'bitsandbytes>=0.42.0' 'timm==0.9.10' boto3 runai-model-streamer runai-model-streamer[s3]; \
290 else \
297 - uv pip install --system accelerate hf_transfer 'modelscope!=1.15.0' 'bitsandbytes>=0.45.0' 'timm==0.9.10' boto3 runai-model-streamer runai-model-streamer[s3]; \
291 + uv pip install accelerate hf_transfer 'modelscope!=1.15.0' 'bitsandbytes>=0.45.0' 'timm==0.9.10' boto3 runai-model-streamer runai-model-streamer[s3]; \
292 fi
293
294 ENV VLLM_USAGE_SOURCE production-docker-image