Spaces:
Paused
Paused
Create Dockerfile
Browse files- Dockerfile +77 -0
Dockerfile
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
######################### BASE IMAGE #########################
|
| 2 |
+
FROM ubuntu:22.04 AS base
|
| 3 |
+
|
| 4 |
+
WORKDIR /workspace/
|
| 5 |
+
|
| 6 |
+
ARG PYTHON_VERSION=3.12
|
| 7 |
+
ARG PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cpu"
|
| 8 |
+
|
| 9 |
+
ENV LD_PRELOAD=""
|
| 10 |
+
|
| 11 |
+
# Install minimal dependencies and uv
|
| 12 |
+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
| 13 |
+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
| 14 |
+
apt-get update -y \
|
| 15 |
+
&& apt-get install -y --no-install-recommends ccache git curl wget ca-certificates \
|
| 16 |
+
gcc-12 g++-12 libtcmalloc-minimal4 libnuma-dev ffmpeg libsm6 libxext6 libgl1 \
|
| 17 |
+
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10 --slave /usr/bin/g++ g++ /usr/bin/g++-12 \
|
| 18 |
+
&& curl -LsSf https://astral.sh/uv/install.sh | sh
|
| 19 |
+
|
| 20 |
+
RUN git clone --branch v0.8.5.post1 https://github.com/vllm-project/vllm.git /workspace/vllm
|
| 21 |
+
|
| 22 |
+
ENV CCACHE_DIR=/root/.cache/ccache
|
| 23 |
+
ENV CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
| 24 |
+
|
| 25 |
+
ENV PATH="/root/.local/bin:$PATH"
|
| 26 |
+
ENV VIRTUAL_ENV="/opt/venv"
|
| 27 |
+
ENV UV_PYTHON_INSTALL_DIR=/opt/uv/python
|
| 28 |
+
RUN uv venv --python ${PYTHON_VERSION} --seed ${VIRTUAL_ENV}
|
| 29 |
+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 30 |
+
|
| 31 |
+
ENV UV_HTTP_TIMEOUT=500
|
| 32 |
+
|
| 33 |
+
# Install Python dependencies
|
| 34 |
+
ENV PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}
|
| 35 |
+
ENV UV_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}
|
| 36 |
+
ENV UV_INDEX_STRATEGY="unsafe-best-match"
|
| 37 |
+
ENV UV_LINK_MODE="copy"
|
| 38 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 39 |
+
uv pip install --upgrade pip && \
|
| 40 |
+
uv pip install -r /workspace/vllm/requirements/cpu.txt
|
| 41 |
+
|
| 42 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 43 |
+
uv pip install intel-openmp==2024.2.1 intel_extension_for_pytorch==2.6.0
|
| 44 |
+
|
| 45 |
+
ENV LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4:/opt/venv/lib/libiomp5.so:$LD_PRELOAD"
|
| 46 |
+
|
| 47 |
+
RUN echo 'ulimit -c 0' >> ~/.bashrc
|
| 48 |
+
|
| 49 |
+
######################### BUILD IMAGE #########################
|
| 50 |
+
FROM base AS vllm-build
|
| 51 |
+
|
| 52 |
+
ARG GIT_REPO_CHECK=0
|
| 53 |
+
# Support for building with non-AVX512 vLLM: docker build --build-arg VLLM_CPU_DISABLE_AVX512="true" ...
|
| 54 |
+
ARG VLLM_CPU_DISABLE_AVX512
|
| 55 |
+
ENV VLLM_CPU_DISABLE_AVX512=${VLLM_CPU_DISABLE_AVX512}
|
| 56 |
+
|
| 57 |
+
WORKDIR /workspace/vllm
|
| 58 |
+
|
| 59 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 60 |
+
uv pip install -r /workspace/vllm/requirements/build.txt
|
| 61 |
+
|
| 62 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 63 |
+
--mount=type=cache,target=/root/.cache/ccache \
|
| 64 |
+
VLLM_TARGET_DEVICE=cpu python3 setup.py bdist_wheel
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
######################### RELEASE IMAGE #########################
|
| 68 |
+
FROM base AS vllm-openai
|
| 69 |
+
|
| 70 |
+
WORKDIR /workspace/
|
| 71 |
+
|
| 72 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 73 |
+
--mount=type=cache,target=/root/.cache/ccache \
|
| 74 |
+
--mount=type=bind,from=vllm-build,src=/workspace/vllm/dist,target=dist \
|
| 75 |
+
uv pip install dist/*.whl
|
| 76 |
+
|
| 77 |
+
ENTRYPOINT ["python3", "-m", "vllm.entrypoints.openai.api_server"]
|