2025-04-01 20:44:21 +00:00
|
|
|
# ---------- Builder Base ----------
|
2026-04-03 08:44:36 +00:00
|
|
|
# Using NVIDIA NGC PyTorch container (26.03) with:
|
|
|
|
|
# - PyTorch 2.11.0a0 (bleeding edge)
|
|
|
|
|
# - CUDA 13.2.0
|
|
|
|
|
# - cuDNN 9.20, NCCL 2.29.7, TensorRT 10.16, TransformerEngine 2.13
|
|
|
|
|
# - Multi-arch: x86 + ARM SBSA (GH200 support)
|
2026-04-03 08:46:43 +00:00
|
|
|
FROM nvcr.io/nvidia/pytorch:26.03-py3 AS base
|
2025-04-01 20:44:21 +00:00
|
|
|
|
|
|
|
|
# Set arch lists for all targets
|
|
|
|
|
# 'a' suffix is not forward compatible but enables all optimizations
|
|
|
|
|
ARG TORCH_CUDA_ARCH_LIST="9.0a"
|
|
|
|
|
ENV TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST}
|
|
|
|
|
ARG VLLM_FA_CMAKE_GPU_ARCHES="90a-real"
|
|
|
|
|
ENV VLLM_FA_CMAKE_GPU_ARCHES=${VLLM_FA_CMAKE_GPU_ARCHES}
|
|
|
|
|
|
2026-04-03 08:44:36 +00:00
|
|
|
# Install additional build dependencies
|
2025-04-01 20:44:21 +00:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
2026-04-03 08:44:36 +00:00
|
|
|
RUN apt update && apt install -y --no-install-recommends \
|
2025-04-01 20:44:21 +00:00
|
|
|
curl \
|
|
|
|
|
git \
|
|
|
|
|
libibverbs-dev \
|
2025-06-03 22:34:21 +00:00
|
|
|
zlib1g-dev \
|
2026-04-03 08:44:36 +00:00
|
|
|
libnuma-dev \
|
|
|
|
|
wget \
|
|
|
|
|
&& apt clean \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives
|
2025-04-01 20:44:21 +00:00
|
|
|
|
|
|
|
|
# Set compiler paths
|
2026-04-02 22:50:23 +00:00
|
|
|
ENV CC=/usr/bin/gcc
|
|
|
|
|
ENV CXX=/usr/bin/g++
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2026-04-03 08:44:36 +00:00
|
|
|
# Install uv for faster package management
|
2025-04-01 20:44:21 +00:00
|
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR=/usr/local/bin sh
|
|
|
|
|
|
|
|
|
|
# Setup build workspace
|
|
|
|
|
WORKDIR /workspace
|
|
|
|
|
|
2026-04-03 08:44:36 +00:00
|
|
|
# Environment setup (PyTorch container already has CUDA paths set)
|
2025-04-01 20:44:21 +00:00
|
|
|
ENV CUDA_HOME=/usr/local/cuda
|
|
|
|
|
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
2025-10-20 20:16:06 +00:00
|
|
|
ENV CPLUS_INCLUDE_PATH=${CUDA_HOME}/include/cccl
|
|
|
|
|
ENV C_INCLUDE_PATH=${CUDA_HOME}/include/cccl
|
|
|
|
|
ENV PATH=${CUDA_HOME}/cuda/bin:${PATH}
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2026-04-03 08:44:36 +00:00
|
|
|
# Use the Python environment from the container
|
|
|
|
|
# The NGC container already has a working Python/PyTorch setup
|
2025-04-01 20:44:21 +00:00
|
|
|
|
|
|
|
|
FROM base AS build-base
|
|
|
|
|
RUN mkdir /wheels
|
|
|
|
|
|
|
|
|
|
# Install build deps that aren't in project requirements files
|
2026-04-02 20:19:39 +00:00
|
|
|
# Pin setuptools to <81 for LMCache compatibility (needs >=77.0.3,<81.0.0)
|
2026-04-03 08:52:43 +00:00
|
|
|
# Note: wheel is already installed in NGC container, don't try to upgrade it
|
|
|
|
|
RUN pip install -U build cmake ninja pybind11 "setuptools>=77.0.3,<81.0.0"
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2026-04-02 23:58:20 +00:00
|
|
|
# Use PyPI triton wheel instead of building (QEMU segfaults during triton build)
|
2025-04-01 20:44:21 +00:00
|
|
|
FROM build-base AS build-triton
|
2026-04-02 23:58:20 +00:00
|
|
|
RUN mkdir -p /wheels && \
|
|
|
|
|
pip download triton==3.6.0 --platform manylinux_2_27_aarch64 --only-binary=:all: --no-deps -d /wheels
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2026-04-03 05:50:02 +00:00
|
|
|
# Skip xformers - vLLM has built-in FlashAttention kernels
|
|
|
|
|
# xformers requires TORCH_STABLE_ONLY which needs PyTorch headers not in 2.9.0
|
|
|
|
|
# FROM build-base AS build-xformers
|
|
|
|
|
# RUN git clone https://github.com/facebookresearch/xformers.git
|
|
|
|
|
# RUN cd xformers && \
|
|
|
|
|
# git submodule sync && \
|
|
|
|
|
# git submodule update --init --recursive -j 8 && \
|
2026-04-03 08:44:36 +00:00
|
|
|
# MAX_JOBS=8 pip build --wheel --no-build-isolation -o /wheels
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2025-09-24 05:52:11 +00:00
|
|
|
FROM build-base AS build-flashinfer
|
|
|
|
|
ARG FLASHINFER_ENABLE_AOT=1
|
2026-04-03 07:13:16 +00:00
|
|
|
ARG FLASHINFER_REF=v0.6.6
|
2026-04-03 08:44:36 +00:00
|
|
|
ARG FLASHINFER_BUILD_SUFFIX=cu132
|
2025-09-24 05:52:11 +00:00
|
|
|
ENV FLASHINFER_LOCAL_VERSION=${FLASHINFER_BUILD_SUFFIX:-}
|
|
|
|
|
RUN git clone https://github.com/flashinfer-ai/flashinfer.git
|
|
|
|
|
RUN cd flashinfer && \
|
|
|
|
|
git checkout ${FLASHINFER_REF} && \
|
|
|
|
|
git submodule sync && \
|
|
|
|
|
git submodule update --init --recursive -j 8 && \
|
2026-04-03 08:52:43 +00:00
|
|
|
python -m build --wheel --no-build-isolation -o /wheels
|
2025-08-20 21:02:46 +00:00
|
|
|
|
2025-09-24 05:52:11 +00:00
|
|
|
FROM build-base AS build-lmcache
|
2026-04-03 03:34:58 +00:00
|
|
|
# Bleeding edge: build from dev branch (v0.4.2+)
|
2026-04-03 03:16:45 +00:00
|
|
|
RUN git clone https://github.com/LMCache/LMCache.git && \
|
2025-09-24 05:52:11 +00:00
|
|
|
cd LMCache && \
|
2026-04-03 03:34:58 +00:00
|
|
|
git checkout dev && \
|
2026-04-03 08:26:53 +00:00
|
|
|
echo "\n\n========================================" && \
|
|
|
|
|
echo ">>> BUILDING LMCACHE FROM:" && \
|
|
|
|
|
echo ">>> BRANCH: $(git rev-parse --abbrev-ref HEAD)" && \
|
|
|
|
|
echo ">>> COMMIT: $(git rev-parse HEAD)" && \
|
|
|
|
|
echo ">>> DATE: $(git log -1 --format=%cd --date=short)" && \
|
|
|
|
|
echo "========================================\n\n" && \
|
2025-10-20 20:16:06 +00:00
|
|
|
sed -i '/torch/d' pyproject.toml && \
|
2026-04-03 08:44:36 +00:00
|
|
|
pip install setuptools_scm && \
|
2026-04-03 08:09:05 +00:00
|
|
|
MAX_JOBS=8 python -m build --wheel --no-isolation && \
|
2025-09-24 05:52:11 +00:00
|
|
|
cp dist/*.whl /wheels/
|
2025-08-20 21:02:46 +00:00
|
|
|
|
2025-10-21 19:21:13 +00:00
|
|
|
|
2025-10-23 18:11:41 +00:00
|
|
|
FROM build-base AS build-flash-attention
|
|
|
|
|
RUN apt-get update && apt-get install -y build-essential cmake gcc && \
|
|
|
|
|
git clone https://github.com/Dao-AILab/flash-attention flash-attention && \
|
|
|
|
|
cd flash-attention/hopper && \
|
|
|
|
|
mkdir wheels && \
|
2026-04-03 05:46:11 +00:00
|
|
|
export MAX_JOBS=8 && \
|
|
|
|
|
export NVCC_THREADS=4 && \
|
2025-10-23 18:11:41 +00:00
|
|
|
export CMAKE_BUILD_PARALLEL_LEVEL=$MAX_JOBS && \
|
|
|
|
|
MAX_JOBS=$MAX_JOBS \
|
|
|
|
|
CMAKE_BUILD_PARALLEL_LEVEL=$MAX_JOBS \
|
|
|
|
|
FLASH_ATTENTION_FORCE_BUILD="TRUE" \
|
|
|
|
|
FLASH_ATTENTION_FORCE_CXX11_ABI="FALSE" \
|
|
|
|
|
FLASH_ATTENTION_SKIP_CUDA_BUILD="FALSE" \
|
2026-04-02 20:55:32 +00:00
|
|
|
pip wheel . -v --no-deps --no-build-isolation -w ./wheels/ && \
|
2025-10-23 18:11:41 +00:00
|
|
|
cp wheels/*.whl /wheels/
|
2025-10-20 20:16:06 +00:00
|
|
|
|
2026-04-03 00:05:56 +00:00
|
|
|
# ==============================================================================
|
2026-04-03 08:44:36 +00:00
|
|
|
# Build vLLM from source
|
2026-04-03 00:05:56 +00:00
|
|
|
# ==============================================================================
|
2026-04-03 02:49:43 +00:00
|
|
|
FROM build-base AS build-vllm
|
2026-04-03 03:14:01 +00:00
|
|
|
# Bleeding edge: build from main branch
|
|
|
|
|
ARG VLLM_REF=main
|
2026-04-03 02:49:43 +00:00
|
|
|
# Install ccache for faster compilation
|
|
|
|
|
RUN apt-get update && apt-get install -y ccache
|
|
|
|
|
RUN git clone https://github.com/vllm-project/vllm.git
|
|
|
|
|
RUN cd vllm && \
|
|
|
|
|
git checkout ${VLLM_REF} && \
|
2026-04-03 08:44:36 +00:00
|
|
|
echo "\n\n========================================" && \
|
|
|
|
|
echo ">>> BUILDING VLLM FROM:" && \
|
|
|
|
|
echo ">>> BRANCH: $(git rev-parse --abbrev-ref HEAD)" && \
|
|
|
|
|
echo ">>> COMMIT: $(git rev-parse HEAD)" && \
|
|
|
|
|
echo ">>> DATE: $(git log -1 --format=%cd --date=short)" && \
|
|
|
|
|
echo ">>> TAG: $(git describe --tags --always 2>/dev/null || echo 'no tag')" && \
|
|
|
|
|
echo "========================================\n\n" && \
|
2026-04-03 02:49:43 +00:00
|
|
|
git submodule sync && \
|
|
|
|
|
git submodule update --init --recursive -j 8 && \
|
|
|
|
|
sed -i 's/GIT_TAG [a-f0-9]\{40\}/GIT_TAG main/' cmake/external_projects/vllm_flash_attn.cmake && \
|
2026-04-03 05:46:11 +00:00
|
|
|
export MAX_JOBS=8 && \
|
2026-04-03 02:49:43 +00:00
|
|
|
export CMAKE_BUILD_PARALLEL_LEVEL=$MAX_JOBS && \
|
|
|
|
|
python use_existing_torch.py && \
|
2026-04-03 08:44:36 +00:00
|
|
|
pip install -r requirements/build.txt && \
|
2026-04-03 08:52:43 +00:00
|
|
|
CCACHE_NOHASHDIR="true" python -m build --wheel --no-build-isolation -o /wheels
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2025-09-24 05:52:11 +00:00
|
|
|
# Build infinistore after vllm to avoid cache invalidation
|
|
|
|
|
FROM build-base AS build-infinistore
|
|
|
|
|
# Install additional dependencies needed for building infinistore on aarch64
|
|
|
|
|
RUN apt update && apt install -y cmake pybind11-dev python3-dev libuv1-dev libspdlog-dev libboost-dev libboost-all-dev meson
|
|
|
|
|
|
|
|
|
|
# Build flatbuffers from source with proper CMake version
|
|
|
|
|
RUN git clone -b v1.12.0 https://github.com/google/flatbuffers.git && \
|
|
|
|
|
cd flatbuffers && \
|
|
|
|
|
cmake -B build -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 && \
|
|
|
|
|
cmake --build build -j && \
|
|
|
|
|
cmake --install build
|
|
|
|
|
|
|
|
|
|
# Build InfiniStore from source as a Python package
|
|
|
|
|
RUN git clone https://github.com/bytedance/InfiniStore && \
|
|
|
|
|
cd InfiniStore && \
|
2026-04-03 08:44:36 +00:00
|
|
|
pip install meson && \
|
|
|
|
|
pip install --no-deps --no-build-isolation -e . && \
|
|
|
|
|
pip uninstall infinistore && \
|
2025-09-24 05:52:11 +00:00
|
|
|
python -m build --wheel --no-isolation && \
|
|
|
|
|
cp dist/*.whl /wheels/
|
2025-04-01 20:44:21 +00:00
|
|
|
|
|
|
|
|
FROM base AS vllm-openai
|
2025-10-23 18:11:41 +00:00
|
|
|
COPY --from=build-flash-attention /wheels/* wheels/
|
2025-10-16 01:08:21 +00:00
|
|
|
COPY --from=build-flashinfer /wheels/* wheels/
|
2025-04-01 20:44:21 +00:00
|
|
|
COPY --from=build-triton /wheels/* wheels/
|
|
|
|
|
COPY --from=build-vllm /wheels/* wheels/
|
2025-09-24 05:52:11 +00:00
|
|
|
COPY --from=build-lmcache /wheels/* wheels/
|
|
|
|
|
COPY --from=build-infinistore /wheels/* wheels/
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2025-09-24 05:52:11 +00:00
|
|
|
# Install wheels (infinistore is now built as a wheel)
|
2026-04-03 08:44:36 +00:00
|
|
|
RUN pip install wheels/*
|
2025-04-01 20:44:21 +00:00
|
|
|
RUN rm -r wheels
|
|
|
|
|
|
|
|
|
|
# Install pynvml
|
2026-04-03 08:44:36 +00:00
|
|
|
RUN pip install pynvml pandas
|
2025-04-01 20:44:21 +00:00
|
|
|
|
|
|
|
|
# Add additional packages for vLLM OpenAI
|
2026-04-03 03:14:01 +00:00
|
|
|
# Bleeding edge: latest transformers
|
2026-04-03 08:44:36 +00:00
|
|
|
RUN pip install accelerate hf_transfer modelscope bitsandbytes timm boto3 runai-model-streamer runai-model-streamer[s3] tensorizer transformers --upgrade
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2026-04-03 08:44:36 +00:00
|
|
|
# Clean pip cache
|
|
|
|
|
RUN pip cache purge || true
|
2025-04-01 20:44:21 +00:00
|
|
|
|
2025-06-04 03:22:03 +00:00
|
|
|
# Install build tools and dependencies
|
2026-04-03 08:52:43 +00:00
|
|
|
RUN pip install -U build cmake ninja pybind11 setuptools==79.0.1
|
2025-06-03 22:34:21 +00:00
|
|
|
|
2025-04-01 20:44:21 +00:00
|
|
|
# Enable hf-transfer
|
|
|
|
|
ENV HF_HUB_ENABLE_HF_TRANSFER=1
|
2026-04-03 08:44:36 +00:00
|
|
|
RUN pip install datasets aiohttp
|
2025-04-17 18:46:25 +00:00
|
|
|
|
|
|
|
|
# Install nsys for profiling
|
2025-09-24 05:52:11 +00:00
|
|
|
ARG NSYS_URL=https://developer.nvidia.com/downloads/assets/tools/secure/nsight-systems/2025_5/
|
|
|
|
|
ARG NSYS_PKG=nsight-systems-cli-2025.5.1_2025.5.1.121-1_arm64.deb
|
2025-04-17 18:46:25 +00:00
|
|
|
RUN apt-get update && apt install -y wget libglib2.0-0
|
|
|
|
|
RUN wget ${NSYS_URL}${NSYS_PKG} && dpkg -i $NSYS_PKG && rm $NSYS_PKG
|
2025-05-27 20:34:14 +00:00
|
|
|
RUN apt install -y --no-install-recommends tmux cmake
|
2025-04-17 18:46:25 +00:00
|
|
|
|
2025-09-24 06:14:16 +00:00
|
|
|
# Deprecated cleanup
|
2026-04-03 08:44:36 +00:00
|
|
|
RUN pip uninstall pynvml && pip install nvidia-ml-py
|
2025-09-24 06:14:16 +00:00
|
|
|
|
2025-04-01 20:44:21 +00:00
|
|
|
# API server entrypoint
|
2025-06-04 15:28:22 +00:00
|
|
|
# ENTRYPOINT ["vllm", "serve"]
|
2025-06-18 21:49:59 +00:00
|
|
|
CMD ["/bin/bash"]
|