Dockerfile.cpu 2.67 KB
Newer Older
1
2
# This vLLM Dockerfile is used to construct image that can build and run vLLM on x86 CPU platform.

3
FROM ubuntu:22.04 AS cpu-test-1
4

5
6
7
8
ENV CCACHE_DIR=/root/.cache/ccache

ENV CMAKE_CXX_COMPILER_LAUNCHER=ccache

9
10
11
RUN --mount=type=cache,target=/var/cache/apt \
    apt-get update -y \
    && apt-get install -y curl ccache git wget vim numactl gcc-12 g++-12 python3 python3-pip libtcmalloc-minimal4 libnuma-dev \
12
    && apt-get install -y ffmpeg libsm6 libxext6 libgl1 \
13
14
    && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 --slave /usr/bin/g++ g++ /usr/bin/g++-12

15
16
17
# https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/performance_tuning/tuning_guide.html
# intel-openmp provides additional performance improvement vs. openmp
# tcmalloc provides better memory allocation efficiency, e.g, holding memory in caches to speed up access of commonly-used objects.
18
RUN --mount=type=cache,target=/root/.cache/pip \
19
    pip install intel-openmp==2025.0.1
20

21
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4:/usr/local/lib/libiomp5.so"
22

23
RUN echo 'ulimit -c 0' >> ~/.bashrc
24

25
RUN pip install intel_extension_for_pytorch==2.5.0
26

27
28
WORKDIR /workspace

29
30
ARG PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cpu"
ENV PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}
31
RUN --mount=type=cache,target=/root/.cache/pip \
32
    --mount=type=bind,src=requirements-build.txt,target=requirements-build.txt \
33
34
    pip install --upgrade pip && \
    pip install -r requirements-build.txt
35

36
37
FROM cpu-test-1 AS build

38
39
WORKDIR /workspace/vllm

40
RUN --mount=type=cache,target=/root/.cache/pip \
41
42
    --mount=type=bind,src=requirements-common.txt,target=requirements-common.txt \
    --mount=type=bind,src=requirements-cpu.txt,target=requirements-cpu.txt \
43
44
    pip install -v -r requirements-cpu.txt

45
46
47
48
COPY . .
ARG GIT_REPO_CHECK=0
RUN --mount=type=bind,source=.git,target=.git \
    if [ "$GIT_REPO_CHECK" != 0 ]; then bash tools/check_repo.sh ; fi
49

50
51
52
53
# Support for building with non-AVX512 vLLM: docker build --build-arg VLLM_CPU_DISABLE_AVX512="true" ...
ARG VLLM_CPU_DISABLE_AVX512
ENV VLLM_CPU_DISABLE_AVX512=${VLLM_CPU_DISABLE_AVX512}

54
55
RUN --mount=type=cache,target=/root/.cache/pip \
    --mount=type=cache,target=/root/.cache/ccache \
56
    --mount=type=bind,source=.git,target=.git \
57
    VLLM_TARGET_DEVICE=cpu python3 setup.py bdist_wheel && \
58
59
    pip install dist/*.whl && \
    rm -rf dist
60

61
62
WORKDIR /workspace/

63
RUN ln -s /workspace/vllm/tests && ln -s /workspace/vllm/examples && ln -s /workspace/vllm/benchmarks
64

youkaichao's avatar
youkaichao committed
65
66
67
68
# install development dependencies (for testing)
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install -e tests/vllm_test_utils

69
ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"]