From 916d219d62e9e4005e10be23f81d881afdb8d6d0 Mon Sep 17 00:00:00 2001 From: "Kevin H. Luu" Date: Wed, 12 Jun 2024 17:58:12 -0700 Subject: [PATCH] [ci] Use sccache to build images (#5419) Signed-off-by: kevin --- .buildkite/test-template-aws.j2 | 2 +- Dockerfile | 22 ++++++++++++++++++++-- setup.py | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.buildkite/test-template-aws.j2 b/.buildkite/test-template-aws.j2 index 645747ddd425..09649b625c31 100644 --- a/.buildkite/test-template-aws.j2 +++ b/.buildkite/test-template-aws.j2 @@ -7,7 +7,7 @@ steps: queue: cpu_queue commands: - "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/q9t5s3a7" - - "docker build --build-arg max_jobs=16 --tag {{ docker_image }} --target test --progress plain ." + - "docker build --build-arg max_jobs=16 --build-arg USE_SCCACHE=1 --tag {{ docker_image }} --target test --progress plain ." - "docker push {{ docker_image }}" env: DOCKER_BUILDKIT: "1" diff --git a/Dockerfile b/Dockerfile index eb96bf3c1db2..62c401069cc1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ FROM nvidia/cuda:12.4.1-devel-ubuntu22.04 AS dev RUN apt-get update -y \ - && apt-get install -y python3-pip git + && apt-get install -y python3-pip git curl sudo # Workaround for https://github.com/openai/triton/issues/2507 and # https://github.com/pytorch/pytorch/issues/107960 -- hopefully @@ -70,10 +70,28 @@ ENV NVCC_THREADS=$nvcc_threads # make sure punica kernels are built (for LoRA) ENV VLLM_INSTALL_PUNICA_KERNELS=1 +ARG USE_SCCACHE +# if USE_SCCACHE is set, use sccache to speed up compilation +RUN --mount=type=cache,target=/root/.cache/pip \ + if [ "$USE_SCCACHE" = "1" ]; then \ + echo "Installing sccache..." \ + && 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 \ + && tar -xzf sccache.tar.gz \ + && sudo mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/bin/sccache \ + && rm -rf sccache.tar.gz sccache-v0.8.1-x86_64-unknown-linux-musl \ + && export SCCACHE_BUCKET=vllm-build-sccache \ + && export SCCACHE_REGION=us-west-2 \ + && sccache --show-stats \ + && python3 setup.py bdist_wheel --dist-dir=dist \ + && sccache --show-stats; \ + fi + ENV CCACHE_DIR=/root/.cache/ccache RUN --mount=type=cache,target=/root/.cache/ccache \ --mount=type=cache,target=/root/.cache/pip \ - python3 setup.py bdist_wheel --dist-dir=dist + if [ "$USE_SCCACHE" != "1" ]; then \ + python3 setup.py bdist_wheel --dist-dir=dist; \ + fi # check the size of the wheel, we cannot upload wheels larger than 100MB COPY .buildkite/check-wheel-size.py check-wheel-size.py diff --git a/setup.py b/setup.py index 12e5c34568f7..3a41b1a0b31b 100644 --- a/setup.py +++ b/setup.py @@ -140,6 +140,7 @@ class cmake_build_ext(build_ext): cmake_args += [ '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache', '-DCMAKE_CUDA_COMPILER_LAUNCHER=sccache', + '-DCMAKE_C_COMPILER_LAUNCHER=sccache', ] elif is_ccache_available(): cmake_args += [ @@ -171,7 +172,6 @@ class cmake_build_ext(build_ext): else: # Default build tool to whatever cmake picks. build_tool = [] - subprocess.check_call( ['cmake', ext.cmake_lists_dir, *build_tool, *cmake_args], cwd=self.build_temp)