Commit 5045ada4 authored by Pavithra Vijayakrishnan's avatar Pavithra Vijayakrishnan Committed by GitHub
Browse files

feat: Add manylinux support for Dynamo (#536)


Signed-off-by: default avatarPavithra Vijayakrishnan <160681768+pvijayakrish@users.noreply.github.com>
parent f8520e92
......@@ -15,8 +15,14 @@
ARG BASE_IMAGE="tensorrt_llm/release"
ARG BASE_IMAGE_TAG="latest"
ARG MANYLINUX_IMAGE="quay.io/pypa/manylinux_2_28_x86_64"
ARG RELEASE_BUILD
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} AS dev
##################################
########## Build Image ###########
##################################
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} AS build
USER root
......@@ -116,15 +122,61 @@ COPY deploy/dynamo/sdk /workspace/deploy/dynamo/sdk
# Install uv, create virtualenv for general use, and build dynamo wheel
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
### VIRTUAL ENVIRONMENT SETUP ###
RUN mkdir /opt/dynamo && \
uv venv /opt/dynamo/venv --python 3.12
###################################
####### WHEEL BUILD STAGE #########
###################################
# Build the wheel in the manylinux environment
FROM ${MANYLINUX_IMAGE} AS wheel_builder
ARG RELEASE_BUILD
ARG CARGO_BUILD_JOBS
# Set CARGO_BUILD_JOBS to 16 if not provided
# This is to prevent cargo from building $(nproc) jobs in parallel,
# which might exceed the number of opened files limit.
ENV CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-16}
WORKDIR /workspace
RUN yum install -y protobuf-compiler \
&& yum clean all \
&& rm -rf /var/cache/yum
COPY --from=build /workspace /workspace
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
CARGO_TARGET_DIR=/workspace/target
COPY --from=build $RUSTUP_HOME $RUSTUP_HOME
COPY --from=build $CARGO_HOME $CARGO_HOME
# Create virtualenv and build dynamo wheel
RUN mkdir /opt/dynamo && \
uv venv /opt/dynamo/venv --python 3.12 && \
source /opt/dynamo/venv/bin/activate && \
cd /workspace/lib/bindings/python && \
uv build --wheel --out-dir /workspace/dist && \
uv pip install /workspace/dist/ai_dynamo_runtime*cp312*.whl && \
uv build --wheel --out-dir /workspace/dist --python 3.12 && \
if [ "$RELEASE_BUILD" = "true" ]; then \
uv build --wheel --out-dir /workspace/dist --python 3.11 && \
uv build --wheel --out-dir /workspace/dist --python 3.10; \
fi && \
cd /workspace && \
uv build --wheel --out-dir /workspace/dist && \
uv pip install /workspace/dist/ai_dynamo*any.whl
uv build --wheel --out-dir /workspace/dist
########################################
########## Development Image ###########
########################################
FROM build AS dev
WORKDIR /workspace
COPY --from=wheel_builder /workspace/dist/ /workspace/dist/
# Package the bindings
RUN mkdir -p /opt/dynamo/bindings/wheels && \
......@@ -133,6 +185,10 @@ RUN mkdir -p /opt/dynamo/bindings/wheels && \
cp target/release/libdynamo_llm_capi.so /opt/dynamo/bindings/lib/. && \
cp -r lib/bindings/c/include /opt/dynamo/bindings/.
RUN . /opt/dynamo/venv/bin/activate && \
uv pip install /workspace/dist/ai_dynamo_runtime*cp312*.whl && \
uv pip install /workspace/dist/ai_dynamo*any.whl
# Install dynamo.runtime and dynamo.llm wheels globally in container for tests that
# currently run without virtual environment activated.
# TODO: In future, we may use a virtualenv for everything and remove this.
......
......@@ -3,10 +3,10 @@
ARG BASE_IMAGE="nvcr.io/nvidia/cuda-dl-base"
ARG BASE_IMAGE_TAG="25.01-cuda12.8-devel-ubuntu24.04"
ARG RELEASE_BUILD
ARG RUNTIME_IMAGE="nvcr.io/nvidia/cuda"
ARG RUNTIME_IMAGE_TAG="12.8.1-runtime-ubuntu24.04"
ARG MANYLINUX_IMAGE="quay.io/pypa/manylinux_2_28_x86_64"
ARG GENAI_PERF_TAG="25d0188713adc47868d6b3f22426375237a90529"
FROM ${BASE_IMAGE}:${BASE_IMAGE_TAG} AS nixl_base
......@@ -280,24 +280,6 @@ RUN cargo build --release --locked --features mistralrs,sglang,vllm,python && \
COPY deploy/dynamo/sdk /workspace/deploy/dynamo/sdk
COPY deploy/dynamo/api-store /workspace/deploy/dynamo/api-store
# Build dynamo wheel
RUN source /opt/dynamo/venv/bin/activate && \
cd /workspace/lib/bindings/python && \
uv build --wheel --out-dir /workspace/dist && \
uv pip install /workspace/dist/ai_dynamo_runtime*cp312*.whl && \
cd /workspace && \
uv build --wheel --out-dir /workspace/dist && \
uv pip install /workspace/dist/ai_dynamo*any.whl && \
cd /workspace/deploy/dynamo/api-store && \
uv build --wheel --out-dir /workspace/dist && \
uv pip install /workspace/dist/ai_dynamo_store*any.whl
# Package the bindings
RUN mkdir -p /opt/dynamo/bindings/wheels && \
mkdir /opt/dynamo/bindings/lib && \
cp dist/ai_dynamo*cp312*.whl /opt/dynamo/bindings/wheels/. && \
cp target/release/libdynamo_llm_capi.so /opt/dynamo/bindings/lib/. && \
cp -r lib/bindings/c/include /opt/dynamo/bindings/.
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing
ENV VLLM_KV_CAPI_PATH="/opt/dynamo/bindings/lib/libdynamo_llm_capi.so"
......@@ -309,12 +291,74 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/la
CMD []
###################################
####### WHEEL BUILD STAGE #########
###################################
# Build the wheel in the manylinux environment
FROM ${MANYLINUX_IMAGE} AS wheel_builder
ARG CARGO_BUILD_JOBS
# Set CARGO_BUILD_JOBS to 16 if not provided
# This is to prevent cargo from building $(nproc) jobs in parallel,
# which might exceed the number of opened files limit.
ENV CARGO_BUILD_JOBS=${CARGO_BUILD_JOBS:-16}
# Use build arg RELEASE_BUILD = true to generate wheels for Python 3.10, 3.11 and 3.12.
ARG RELEASE_BUILD
WORKDIR /workspace
RUN yum install -y protobuf-compiler \
&& yum clean all \
&& rm -rf /var/cache/yum
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
CARGO_TARGET_DIR=/workspace/target
COPY --from=build /workspace /workspace
COPY --from=build $RUSTUP_HOME $RUSTUP_HOME
COPY --from=build $CARGO_HOME $CARGO_HOME
# Copy uv from build and build wheel in virtualenv
RUN mkdir /opt/dynamo && \
uv venv /opt/dynamo/venv --python 3.12
# Activate virtual environment
ENV VIRTUAL_ENV=/opt/dynamo/venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
ENV PATH="$PATH:/usr/local/bin"
# Build dynamo wheel
RUN source /opt/dynamo/venv/bin/activate && \
cd /workspace/lib/bindings/python && \
uv build --wheel --out-dir /workspace/dist --python 3.12 && \
if [ "$RELEASE_BUILD" = "true" ]; then \
uv build --wheel --out-dir /workspace/dist --python 3.11 && \
uv build --wheel --out-dir /workspace/dist --python 3.10; \
fi && \
cd /workspace && \
uv build --wheel --out-dir /workspace/dist && \
cd /workspace/deploy/dynamo/api-store && \
uv build --wheel --out-dir /workspace/dist
#######################################
########## CI Minimum Image ###########
#######################################
FROM build AS ci_minimum
COPY . /workspace
COPY --from=wheel_builder /workspace/dist/ /workspace/dist/
# Package the bindings
RUN mkdir -p /opt/dynamo/bindings/wheels && \
mkdir /opt/dynamo/bindings/lib && \
cp dist/ai_dynamo*cp312*.whl /opt/dynamo/bindings/wheels/. && \
cp target/release/libdynamo_llm_capi.so /opt/dynamo/bindings/lib/. && \
cp -r lib/bindings/c/include /opt/dynamo/bindings/.
RUN uv pip install /workspace/dist/ai_dynamo_runtime*cp312*.whl && \
uv pip install /workspace/dist/ai_dynamo*any.whl && \
uv pip install /workspace/dist/ai_dynamo_store*any.whl
##########################################
########## Perf Analyzer Image ###########
......@@ -338,7 +382,7 @@ RUN mkdir bin && \
########################################
########## Development Image ###########
########################################
FROM build AS dev
FROM ci_minimum AS dev
ARG GENAI_PERF_TAG
......@@ -380,8 +424,8 @@ RUN apt-get update && \
echo "source $VIRTUAL_ENV/bin/activate" >> ~/.bashrc
# Install the wheels
COPY --from=build /workspace/dist/*.whl wheelhouse/
RUN uv pip install ai-dynamo[vllm] --find-links wheelhouse && \
COPY --from=wheel_builder /workspace/dist/*.whl wheelhouse/
RUN uv pip install ai-dynamo[vllm] --find-links wheelhouse && \
rm -r wheelhouse
# Tell vllm to use the Dynamo LLM C API for KV Cache Routing
......
......@@ -170,6 +170,9 @@ get_options() {
missing_requirement $1
fi
;;
--release-build)
RELEASE_BUILD=true
;;
--)
shift
break
......@@ -340,6 +343,10 @@ fi
if [ ! -z ${HF_TOKEN} ]; then
BUILD_ARGS+=" --build-arg HF_TOKEN=${HF_TOKEN} "
fi
if [ ! -z ${RELEASE_BUILD} ]; then
echo "Performing a release build!"
BUILD_ARGS+=" --build-arg RELEASE_BUILD=${RELEASE_BUILD} "
fi
LATEST_TAG="--tag dynamo:latest-${FRAMEWORK,,}"
if [ ! -z ${TARGET} ]; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment