Skip to content

Commit 916d219

Browse files
authored
[ci] Use sccache to build images (#5419)
Signed-off-by: kevin <[email protected]>
1 parent ea3890a commit 916d219

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.buildkite/test-template-aws.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ steps:
77
queue: cpu_queue
88
commands:
99
- "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/q9t5s3a7"
10-
- "docker build --build-arg max_jobs=16 --tag {{ docker_image }} --target test --progress plain ."
10+
- "docker build --build-arg max_jobs=16 --build-arg USE_SCCACHE=1 --tag {{ docker_image }} --target test --progress plain ."
1111
- "docker push {{ docker_image }}"
1212
env:
1313
DOCKER_BUILDKIT: "1"

Dockerfile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 AS dev
1111

1212
RUN apt-get update -y \
13-
&& apt-get install -y python3-pip git
13+
&& apt-get install -y python3-pip git curl sudo
1414

1515
# Workaround for https://github.com/openai/triton/issues/2507 and
1616
# https://github.com/pytorch/pytorch/issues/107960 -- hopefully
@@ -70,10 +70,28 @@ ENV NVCC_THREADS=$nvcc_threads
7070
# make sure punica kernels are built (for LoRA)
7171
ENV VLLM_INSTALL_PUNICA_KERNELS=1
7272

73+
ARG USE_SCCACHE
74+
# if USE_SCCACHE is set, use sccache to speed up compilation
75+
RUN --mount=type=cache,target=/root/.cache/pip \
76+
if [ "$USE_SCCACHE" = "1" ]; then \
77+
echo "Installing sccache..." \
78+
&& curl -L -o sccache.tar.gz https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz \
79+
&& tar -xzf sccache.tar.gz \
80+
&& sudo mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/bin/sccache \
81+
&& rm -rf sccache.tar.gz sccache-v0.8.1-x86_64-unknown-linux-musl \
82+
&& export SCCACHE_BUCKET=vllm-build-sccache \
83+
&& export SCCACHE_REGION=us-west-2 \
84+
&& sccache --show-stats \
85+
&& python3 setup.py bdist_wheel --dist-dir=dist \
86+
&& sccache --show-stats; \
87+
fi
88+
7389
ENV CCACHE_DIR=/root/.cache/ccache
7490
RUN --mount=type=cache,target=/root/.cache/ccache \
7591
--mount=type=cache,target=/root/.cache/pip \
76-
python3 setup.py bdist_wheel --dist-dir=dist
92+
if [ "$USE_SCCACHE" != "1" ]; then \
93+
python3 setup.py bdist_wheel --dist-dir=dist; \
94+
fi
7795

7896
# check the size of the wheel, we cannot upload wheels larger than 100MB
7997
COPY .buildkite/check-wheel-size.py check-wheel-size.py

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def configure(self, ext: CMakeExtension) -> None:
140140
cmake_args += [
141141
'-DCMAKE_CXX_COMPILER_LAUNCHER=sccache',
142142
'-DCMAKE_CUDA_COMPILER_LAUNCHER=sccache',
143+
'-DCMAKE_C_COMPILER_LAUNCHER=sccache',
143144
]
144145
elif is_ccache_available():
145146
cmake_args += [
@@ -171,7 +172,6 @@ def configure(self, ext: CMakeExtension) -> None:
171172
else:
172173
# Default build tool to whatever cmake picks.
173174
build_tool = []
174-
175175
subprocess.check_call(
176176
['cmake', ext.cmake_lists_dir, *build_tool, *cmake_args],
177177
cwd=self.build_temp)

0 commit comments

Comments
 (0)