Skip to content

Commit 666ad0a

Browse files
authored
[ci] Cleanup & refactor Dockerfile to pass different Python versions and sccache bucket via build args (#7705)
Signed-off-by: kevin <[email protected]>
1 parent 15310b5 commit 666ad0a

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

Dockerfile

+26-35
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,23 @@ ARG CUDA_VERSION=12.4.1
99
#################### BASE BUILD IMAGE ####################
1010
# prepare basic build environment
1111
FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu20.04 AS base
12-
1312
ARG CUDA_VERSION=12.4.1
1413
ARG PYTHON_VERSION=3.10
15-
1614
ENV DEBIAN_FRONTEND=noninteractive
1715

16+
# Install Python and other dependencies
1817
RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
1918
&& echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
2019
&& apt-get update -y \
21-
&& apt-get install -y ccache software-properties-common \
20+
&& apt-get install -y ccache software-properties-common git curl sudo \
2221
&& add-apt-repository ppa:deadsnakes/ppa \
2322
&& apt-get update -y \
2423
&& apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv \
25-
&& if [ "${PYTHON_VERSION}" != "3" ]; then update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1; fi \
26-
&& python3 --version
27-
28-
RUN apt-get update -y \
29-
&& apt-get install -y git curl sudo
30-
31-
# Install pip s.t. it will be compatible with our PYTHON_VERSION
32-
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
33-
RUN python3 -m pip --version
24+
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
25+
&& update-alternatives --set python3 /usr/bin/python${PYTHON_VERSION} \
26+
&& ln -sf /usr/bin/python${PYTHON_VERSION}-config /usr/bin/python3-config \
27+
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \
28+
&& python3 --version && python3 -m pip --version
3429

3530
# Workaround for https://github.com/openai/triton/issues/2507 and
3631
# https://github.com/pytorch/pytorch/issues/107960 -- hopefully
@@ -62,17 +57,12 @@ ENV TORCH_CUDA_ARCH_LIST=${torch_cuda_arch_list}
6257
#################### WHEEL BUILD IMAGE ####################
6358
FROM base AS build
6459

65-
ARG PYTHON_VERSION=3.10
66-
6760
# install build dependencies
6861
COPY requirements-build.txt requirements-build.txt
6962

7063
RUN --mount=type=cache,target=/root/.cache/pip \
7164
python3 -m pip install -r requirements-build.txt
7265

73-
# install compiler cache to speed up compilation leveraging local or remote caching
74-
RUN apt-get update -y && apt-get install -y ccache
75-
7666
# files and directories related to build wheels
7767
COPY csrc csrc
7868
COPY setup.py setup.py
@@ -95,6 +85,8 @@ ARG buildkite_commit
9585
ENV BUILDKITE_COMMIT=${buildkite_commit}
9686

9787
ARG USE_SCCACHE
88+
ARG SCCACHE_BUCKET_NAME=vllm-build-sccache
89+
ARG SCCACHE_REGION_NAME=us-west-2
9890
# if USE_SCCACHE is set, use sccache to speed up compilation
9991
RUN --mount=type=cache,target=/root/.cache/pip \
10092
if [ "$USE_SCCACHE" = "1" ]; then \
@@ -103,12 +95,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \
10395
&& tar -xzf sccache.tar.gz \
10496
&& sudo mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/bin/sccache \
10597
&& rm -rf sccache.tar.gz sccache-v0.8.1-x86_64-unknown-linux-musl \
106-
&& if [ "$CUDA_VERSION" = "11.8.0" ]; then \
107-
export SCCACHE_BUCKET=vllm-build-sccache-2; \
108-
else \
109-
export SCCACHE_BUCKET=vllm-build-sccache; \
110-
fi \
111-
&& export SCCACHE_REGION=us-west-2 \
98+
&& export SCCACHE_BUCKET=${SCCACHE_BUCKET_NAME} \
99+
&& export SCCACHE_REGION=${SCCACHE_REGION_NAME} \
100+
&& export SCCACHE_IDLE_TIMEOUT=0 \
112101
&& export CMAKE_BUILD_TYPE=Release \
113102
&& sccache --show-stats \
114103
&& python3 setup.py bdist_wheel --dist-dir=dist --py-limited-api=cp38 \
@@ -160,23 +149,24 @@ FROM nvidia/cuda:${CUDA_VERSION}-base-ubuntu20.04 AS vllm-base
160149
ARG CUDA_VERSION=12.4.1
161150
ARG PYTHON_VERSION=3.10
162151
WORKDIR /vllm-workspace
152+
ENV DEBIAN_FRONTEND=noninteractive
153+
154+
RUN PYTHON_VERSION_STR=$(echo ${PYTHON_VERSION} | sed 's/\.//g') && \
155+
echo "export PYTHON_VERSION_STR=${PYTHON_VERSION_STR}" >> /etc/environment
163156

157+
# Install Python and other dependencies
164158
RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
165159
&& echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
166160
&& apt-get update -y \
167-
&& apt-get install -y ccache software-properties-common \
161+
&& apt-get install -y ccache software-properties-common git curl sudo vim python3-pip \
168162
&& add-apt-repository ppa:deadsnakes/ppa \
169163
&& apt-get update -y \
170-
&& apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv \
171-
&& if [ "${PYTHON_VERSION}" != "3" ]; then update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1; fi \
172-
&& python3 --version
173-
174-
RUN apt-get update -y \
175-
&& apt-get install -y python3-pip git vim curl libibverbs-dev
176-
177-
# Install pip s.t. it will be compatible with our PYTHON_VERSION
178-
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}
179-
RUN python3 -m pip --version
164+
&& apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv libibverbs-dev \
165+
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 1 \
166+
&& update-alternatives --set python3 /usr/bin/python${PYTHON_VERSION} \
167+
&& ln -sf /usr/bin/python${PYTHON_VERSION}-config /usr/bin/python3-config \
168+
&& curl -sS https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION} \
169+
&& python3 --version && python3 -m pip --version
180170

181171
# Workaround for https://github.com/openai/triton/issues/2507 and
182172
# https://github.com/pytorch/pytorch/issues/107960 -- hopefully
@@ -194,7 +184,8 @@ RUN --mount=type=bind,from=mamba-builder,src=/usr/src/mamba,target=/usr/src/mamb
194184
python3 -m pip install /usr/src/mamba/*.whl --no-cache-dir
195185

196186
RUN --mount=type=cache,target=/root/.cache/pip \
197-
python3 -m pip install https://github.com/flashinfer-ai/flashinfer/releases/download/v0.1.4/flashinfer-0.1.4+cu121torch2.4-cp310-cp310-linux_x86_64.whl
187+
. /etc/environment && \
188+
python3 -m pip install https://github.com/flashinfer-ai/flashinfer/releases/download/v0.1.4/flashinfer-0.1.4+cu121torch2.4-cp${PYTHON_VERSION_STR}-cp${PYTHON_VERSION_STR}-linux_x86_64.whl
198189
#################### vLLM installation IMAGE ####################
199190

200191

0 commit comments

Comments
 (0)