@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 666ad0aa16
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 16, 18:15 UTC

[ci] Cleanup & refactor Dockerfile to pass different Python versions and sccache bucket via build args (#7705)

Signed-off-by: kevin <kevin@anyscale.com>

Kevin H. Luu committed Aug 22, 2024 at 13:10 UTC 666ad0aa16f0c656e48e58b4f31ffe956b484d3b
1 file changed +26 -35
Dockerfile
+26 -35
@@ -9,28 +9,23 @@ ARG CUDA_VERSION=12.4.1
9 #################### BASE BUILD IMAGE ####################
10 # prepare basic build environment
11 FROM nvidia/cuda:${CUDA_VERSION}-devel-ubuntu20.04 AS base
12 -
12 ARG CUDA_VERSION=12.4.1
13 ARG PYTHON_VERSION=3.10
15 -
14 ENV DEBIAN_FRONTEND=noninteractive
15
16 +# Install Python and other dependencies
17 RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
18 && echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
19 && 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 \
21 && add-apt-repository ppa:deadsnakes/ppa \
22 && apt-get update -y \
23 && 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
29
30 # Workaround for https://github.com/openai/triton/issues/2507 and
31 # https://github.com/pytorch/pytorch/issues/107960 -- hopefully
@@ -62,17 +57,12 @@ ENV TORCH_CUDA_ARCH_LIST=${torch_cuda_arch_list}
57 #################### WHEEL BUILD IMAGE ####################
58 FROM base AS build
59
65 -ARG PYTHON_VERSION=3.10
66 -
60 # install build dependencies
61 COPY requirements-build.txt requirements-build.txt
62
63 RUN --mount=type=cache,target=/root/.cache/pip \
64 python3 -m pip install -r requirements-build.txt
65
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 -
66 # files and directories related to build wheels
67 COPY csrc csrc
68 COPY setup.py setup.py
@@ -95,6 +85,8 @@ ARG buildkite_commit
85 ENV BUILDKITE_COMMIT=${buildkite_commit}
86
87 ARG USE_SCCACHE
88 +ARG SCCACHE_BUCKET_NAME=vllm-build-sccache
89 +ARG SCCACHE_REGION_NAME=us-west-2
90 # if USE_SCCACHE is set, use sccache to speed up compilation
91 RUN --mount=type=cache,target=/root/.cache/pip \
92 if [ "$USE_SCCACHE" = "1" ]; then \
@@ -103,12 +95,9 @@ RUN --mount=type=cache,target=/root/.cache/pip \
95 && tar -xzf sccache.tar.gz \
96 && sudo mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/bin/sccache \
97 && 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 \
101 && export CMAKE_BUILD_TYPE=Release \
102 && sccache --show-stats \
103 && 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
149 ARG CUDA_VERSION=12.4.1
150 ARG PYTHON_VERSION=3.10
151 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
156
157 +# Install Python and other dependencies
158 RUN echo 'tzdata tzdata/Areas select America' | debconf-set-selections \
159 && echo 'tzdata tzdata/Zones/America select Los_Angeles' | debconf-set-selections \
160 && 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 \
162 && add-apt-repository ppa:deadsnakes/ppa \
163 && 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
170
171 # Workaround for https://github.com/openai/triton/issues/2507 and
172 # 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
184 python3 -m pip install /usr/src/mamba/*.whl --no-cache-dir
185
186 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
189 #################### vLLM installation IMAGE ####################
190
191