Skip to content

Commit e904576

Browse files
authored
[CI/Build] Dockerfile.cpu improvements (vllm-project#7298)
1 parent e14fb22 commit e904576

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
vllm/*.so
2+
/.venv
3+
/build
4+
dist

Dockerfile.cpu

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,49 @@
22

33
FROM ubuntu:22.04 AS cpu-test-1
44

5-
RUN apt-get update -y \
6-
&& apt-get install -y curl git wget vim numactl gcc-12 g++-12 python3 python3-pip libtcmalloc-minimal4 libnuma-dev \
5+
RUN --mount=type=cache,target=/var/cache/apt \
6+
apt-get update -y \
7+
&& apt-get install -y curl ccache git wget vim numactl gcc-12 g++-12 python3 python3-pip libtcmalloc-minimal4 libnuma-dev \
78
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 --slave /usr/bin/g++ g++ /usr/bin/g++-12
89

910
# https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/performance_tuning/tuning_guide.html
1011
# intel-openmp provides additional performance improvement vs. openmp
1112
# tcmalloc provides better memory allocation efficiency, e.g, holding memory in caches to speed up access of commonly-used objects.
12-
RUN pip install intel-openmp
13+
RUN --mount=type=cache,target=/root/.cache/pip \
14+
pip install intel-openmp
1315

1416
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4:/usr/local/lib/libiomp5.so:$LD_PRELOAD"
1517

1618
RUN echo 'ulimit -c 0' >> ~/.bashrc
1719

1820
RUN pip install https://intel-extension-for-pytorch.s3.amazonaws.com/ipex_dev/cpu/intel_extension_for_pytorch-2.4.0%2Bgitfbaa4bc-cp310-cp310-linux_x86_64.whl
1921

20-
RUN pip install --upgrade pip \
21-
&& pip install wheel packaging ninja "setuptools>=49.4.0" numpy
22+
ENV PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu
23+
RUN --mount=type=cache,target=/root/.cache/pip \
24+
--mount=type=bind,src=requirements-build.txt,target=requirements-build.txt \
25+
pip install --upgrade pip && \
26+
pip install -r requirements-build.txt
2227

2328
FROM cpu-test-1 AS build
2429

25-
COPY ./ /workspace/vllm
26-
2730
WORKDIR /workspace/vllm
2831

29-
RUN pip install -v -r requirements-cpu.txt --extra-index-url https://download.pytorch.org/whl/cpu
32+
RUN --mount=type=cache,target=/root/.cache/pip \
33+
--mount=type=bind,src=requirements-common.txt,target=requirements-common.txt \
34+
--mount=type=bind,src=requirements-cpu.txt,target=requirements-cpu.txt \
35+
pip install -v -r requirements-cpu.txt
36+
37+
COPY ./ ./
3038

3139
# Support for building with non-AVX512 vLLM: docker build --build-arg VLLM_CPU_DISABLE_AVX512="true" ...
3240
ARG VLLM_CPU_DISABLE_AVX512
3341
ENV VLLM_CPU_DISABLE_AVX512=${VLLM_CPU_DISABLE_AVX512}
3442

35-
RUN VLLM_TARGET_DEVICE=cpu python3 setup.py install
43+
ENV CCACHE_DIR=/root/.cache/ccache
44+
RUN --mount=type=cache,target=/root/.cache/pip \
45+
--mount=type=cache,target=/root/.cache/ccache \
46+
VLLM_TARGET_DEVICE=cpu python3 setup.py bdist_wheel && \
47+
pip install dist/*.whl
3648

3749
WORKDIR /workspace/
3850

0 commit comments

Comments
 (0)