Skip to content

Commit bd22783

Browse files
mgoinshreyankg
authored andcommitted
[CI/Build] Use uv python for docker rather than ppa:deadsnakes/ppa (vllm-project#13569)
Signed-off-by: mgoin <[email protected]>
1 parent 55e89d6 commit bd22783

File tree

1 file changed

+38
-44
lines changed

1 file changed

+38
-44
lines changed

Dockerfile

Lines changed: 38 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@ ARG PYTHON_VERSION=3.12
1414
ARG TARGETPLATFORM
1515
ENV DEBIAN_FRONTEND=noninteractive
1616

17-
# Install Python and other dependencies
17+
# Install minimal dependencies and uv
1818
RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
1919
&& echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
2020
&& 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"
3330

3431
# This timeout (in seconds) is necessary when installing some dependencies via uv since it's likely to time out
3532
# 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/
5148

5249
WORKDIR /workspace
5350

54-
# install build and runtime dependencies
55-
5651
# arm64 (GH200) build follows the practice of "use existing pytorch" build,
5752
# we need to install torch and torchvision from the nightly builds first,
5853
# pytorch will not appear as a vLLM dependency in all of the following steps
5954
# after this step
6055
RUN --mount=type=cache,target=/root/.cache/uv \
6156
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"; \
6358
fi
6459

6560
COPY requirements-common.txt requirements-common.txt
6661
COPY requirements-cuda.txt requirements-cuda.txt
6762
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
6964

7065
# cuda arch list used by torch
7166
# can be useful for both `dev` and `test`
@@ -90,12 +85,12 @@ COPY requirements-build.txt requirements-build.txt
9085
ENV UV_HTTP_TIMEOUT=500
9186

9287
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
9489

9590
COPY . .
9691
ARG GIT_REPO_CHECK=0
9792
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
9994

10095
# max jobs used by Ninja to build extensions
10196
ARG max_jobs=2
@@ -132,6 +127,9 @@ RUN --mount=type=cache,target=/root/.cache/ccache \
132127
--mount=type=cache,target=/root/.cache/uv \
133128
--mount=type=bind,source=.git,target=.git \
134129
if [ "$USE_SCCACHE" != "1" ]; then \
130+
# Clean any existing CMake artifacts
131+
rm -rf .deps && \
132+
mkdir -p .deps && \
135133
python3 setup.py bdist_wheel --dist-dir=dist --py-limited-api=cp38; \
136134
fi
137135

@@ -159,7 +157,7 @@ COPY requirements-lint.txt requirements-lint.txt
159157
COPY requirements-test.txt requirements-test.txt
160158
COPY requirements-dev.txt requirements-dev.txt
161159
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
163161
#################### DEV IMAGE ####################
164162

165163
#################### vLLM installation IMAGE ####################
@@ -175,23 +173,20 @@ ARG TARGETPLATFORM
175173
RUN PYTHON_VERSION_STR=$(echo ${PYTHON_VERSION} | sed 's/\.//g') && \
176174
echo "export PYTHON_VERSION_STR=${PYTHON_VERSION_STR}" >> /etc/environment
177175

178-
# Install Python and other dependencies
176+
# Install minimal dependencies and uv
179177
RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
180178
&& echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
181179
&& 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"
195190

196191
# This timeout (in seconds) is necessary when installing some dependencies via uv since it's likely to time out
197192
# 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/
209204
# after this step
210205
RUN --mount=type=cache,target=/root/.cache/uv \
211206
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"; \
213208
fi
214209

215210
# Install vllm wheel first, so that torch etc will be installed.
216211
RUN --mount=type=bind,from=build,src=/workspace/dist,target=/vllm-workspace/dist \
217212
--mount=type=cache,target=/root/.cache/uv \
218-
uv pip install --system dist/*.whl --verbose
213+
uv pip install dist/*.whl --verbose
219214

220215
# If we need to build FlashInfer wheel before its release:
221216
# $ export FLASHINFER_ENABLE_AOT=1
@@ -230,9 +225,8 @@ RUN --mount=type=bind,from=build,src=/workspace/dist,target=/vllm-workspace/dist
230225
# $ # 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
231226

232227
RUN --mount=type=cache,target=/root/.cache/uv \
233-
. /etc/environment && \
234228
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 ; \
236230
fi
237231
COPY examples examples
238232

@@ -242,7 +236,7 @@ COPY examples examples
242236
# TODO: Remove this once FlashInfer AOT wheel is fixed
243237
COPY requirements-build.txt requirements-build.txt
244238
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
246240

247241
#################### vLLM installation IMAGE ####################
248242

@@ -259,15 +253,15 @@ ENV UV_HTTP_TIMEOUT=500
259253

260254
# install development dependencies (for testing)
261255
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
263257

264258
# install development dependencies (for testing)
265259
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
267261

268262
# enable fast downloads from hf (for testing)
269263
RUN --mount=type=cache,target=/root/.cache/uv \
270-
uv pip install --system hf_transfer
264+
uv pip install hf_transfer
271265
ENV HF_HUB_ENABLE_HF_TRANSFER 1
272266

273267
# Copy in the v1 package for testing (it isn't distributed yet)
@@ -292,9 +286,9 @@ ENV UV_HTTP_TIMEOUT=500
292286
# install additional dependencies for openai api server
293287
RUN --mount=type=cache,target=/root/.cache/uv \
294288
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]; \
296290
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]; \
298292
fi
299293

300294
ENV VLLM_USAGE_SOURCE production-docker-image

0 commit comments

Comments
 (0)