Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b7fbfe3
feat: no parallelism so do some reverting of earthfile
hhzhang16 Apr 11, 2025
e5598d4
feat: copy files to sdk/cli/bin
hhzhang16 Apr 12, 2025
44bd0ac
feat: split cargo build and copying of files so that they can cache
hhzhang16 Apr 12, 2025
3a64d20
feat: fix earthfile!
hhzhang16 Apr 14, 2025
c3fe46b
Merge branch 'main' of github.com:ai-dynamo/dynamo into hannahz/earth…
hhzhang16 Apr 14, 2025
0d4c52b
Merge branch 'main' into hannahz/earthfile-improvements
hhzhang16 Apr 14, 2025
fb937ff
ci: use wheels instead of .
hhzhang16 Apr 14, 2025
42f4251
Merge branch 'hannahz/earthfile-improvements' of github.com:ai-dynamo…
hhzhang16 Apr 14, 2025
d12a06c
ci: earthfile improvements
hhzhang16 Apr 14, 2025
18eafed
ci: replace cp with symlinks
hhzhang16 Apr 15, 2025
42807cd
feat: remove README from Cargo.toml
hhzhang16 Apr 15, 2025
3f5b1ea
ci: cache build steps, slim down final image to 585MB
hhzhang16 Apr 15, 2025
95e913d
Merge branch 'main' into hannahz/earthfile-improvements
hhzhang16 Apr 15, 2025
babf871
ci: add cuda to dynamo base docker
hhzhang16 Apr 15, 2025
34d7162
ci: add Earthfile for vLLM (patched) and add dynamo-base-docker-llm E…
hhzhang16 Apr 16, 2025
6309c92
Merge branch 'main' of github.com:ai-dynamo/dynamo into hannahz/earth…
hhzhang16 Apr 16, 2025
530d886
ci: install cuda in dynamo base docker llm
hhzhang16 Apr 16, 2025
5b8eede
[wip] feat: add nixl
hhzhang16 Apr 16, 2025
0c0a46d
feat: move cuda setup to an Earthly function
hhzhang16 Apr 16, 2025
527dad7
ci: working container/Earthfile for NIXL
hhzhang16 Apr 16, 2025
36bff6e
feat: cut vLLM docker iamge down to 13GB
hhzhang16 Apr 17, 2025
5ef2587
Merge branch 'main' of github.com:ai-dynamo/dynamo into hannahz/earth…
hhzhang16 Apr 18, 2025
225d51c
feat: fix all-docker
hhzhang16 Apr 18, 2025
5b0e15f
feat: update docker server and image tag args
hhzhang16 Apr 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 81 additions & 21 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ dynamo-base:
ENV VIRTUAL_ENV=/opt/dynamo/venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"

SETUP_CUDA:
FUNCTION
RUN apt-get update && \
apt-get install -y --no-install-recommends wget ca-certificates && \
rm -rf /var/lib/apt/lists/*

# Install CUDA
RUN wget --tries=3 --waitretry=5 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb && \
dpkg -i cuda-keyring_1.1-1_all.deb && \
apt-get update && \
apt-get install -y --no-install-recommends \
cuda-toolkit-12-8 \
nvidia-driver-535 \
&& rm -rf /var/lib/apt/lists/* \
&& rm cuda-keyring_1.1-1_all.deb

# Set CUDA environment variables
ENV CUDA_HOME=/usr/local/cuda-12.8
ENV CUDA_ROOT=/usr/local/cuda-12.8
ENV CUDA_PATH=/usr/local/cuda-12.8
ENV CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-12.8
ENV PATH=$CUDA_HOME/bin:$PATH
ENV LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
ENV CUDA_COMPUTE_CAP=80

rust-base:
FROM +dynamo-base
# Rust build/dev dependencies
Expand All @@ -72,32 +97,18 @@ rust-base:
libclang-dev \
git

RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb && \
apt install -y ./cuda-keyring_1.1-1_all.deb && \
apt update && \
apt install -y cuda-toolkit nvidia-utils-535 nvidia-driver-535 && \
rm cuda-keyring_1.1-1_all.deb

# Set CUDA compute capability explicitly
ENV CUDA_COMPUTE_CAP=80

ENV CUDA_HOME=/usr/local/cuda
ENV CUDA_ROOT=/usr/local/cuda
ENV CUDA_PATH=/usr/local/cuda
ENV CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda
ENV PATH=$CUDA_HOME/bin:$PATH
ENV LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
DO +SETUP_CUDA

ENV RUSTUP_HOME=/usr/local/rustup
ENV CARGO_HOME=/usr/local/cargo
ENV PATH=/usr/local/cargo/bin:$PATH
ENV RUST_VERSION=1.86.0
ENV RUSTARCH=x86_64-unknown-linux-gnu

RUN wget --tries=3 --waitretry=5 "https://static.rust-lang.org/rustup/archive/1.28.1/x86_64-unknown-linux-gnu/rustup-init" && \
RUN wget --tries=3 --waitretry=5 "https://static.rust-lang.org/rustup/archive/1.28.1/${RUSTARCH}/rustup-init" && \
echo "a3339fb004c3d0bb9862ba0bce001861fe5cbde9c10d16591eb3f39ee6cd3e7f *rustup-init" | sha256sum -c - && \
chmod +x rustup-init && \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain 1.86.0 --default-host x86_64-unknown-linux-gnu && \
./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${RUSTARCH} && \
rm rustup-init && \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME

Expand Down Expand Up @@ -136,8 +147,8 @@ dynamo-build:

dynamo-base-docker:
ARG IMAGE=dynamo-base-docker
ARG CI_REGISTRY_IMAGE=my-registry
ARG CI_COMMIT_SHA=latest
ARG DOCKER_SERVER=my-registry
ARG IMAGE_TAG=latest

FROM ubuntu:24.04
WORKDIR /workspace
Expand Down Expand Up @@ -167,18 +178,67 @@ dynamo-base-docker:
uv pip install /tmp/wheels/*.whl && \
rm -rf /tmp/wheels

SAVE IMAGE --push $CI_REGISTRY_IMAGE/$IMAGE:$CI_COMMIT_SHA
SAVE IMAGE --push $DOCKER_SERVER/$IMAGE:$IMAGE_TAG

dynamo-base-docker-llm:
ARG IMAGE=dynamo-base-docker-llm
ARG DOCKER_SERVER=my-registry
ARG IMAGE_TAG=latest

FROM +dynamo-base-docker

# Install minimal NIXL dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libnuma1 \
libibverbs1 \
librdmacm1 \
&& rm -rf /var/lib/apt/lists/*

# Copy NIXL setup from artifacts
COPY ./container+nixl-base/nixl /usr/local/nixl
COPY ./container+nixl-base/nixl_src /opt/nixl
COPY ./container+nixl-base/pkgconfig /usr/lib/pkgconfig

# Set NIXL environment variables
ENV LD_LIBRARY_PATH=/usr/local/nixl/lib/x86_64-linux-gnu/:${LD_LIBRARY_PATH}
ENV PYTHONPATH=/usr/local/nixl/lib/python3/dist-packages/:/opt/nixl/test/python/:${PYTHONPATH}
ENV UCX_TLS=^cuda_ipc
ENV NIXL_PLUGIN_DIR=/usr/local/nixl/lib/x86_64-linux-gnu/plugins

# Copy and install the pre-built vllm wheel
COPY ./container+vllm-build/ai_dynamo_vllm-*.whl /workspace
RUN . /opt/dynamo/venv/bin/activate && \
pip install /workspace/ai_dynamo_vllm-*.whl && \
rm -rf /workspace/ai_dynamo_vllm-*.whl

# Verify both Dynamo and vllm are properly installed
RUN python3 -c "import dynamo; import vllm" || (echo "Failed to import Dynamo or vllm" && exit 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use the virtual environment Python for import verification.

The verification command uses python3 which might not be the virtual environment Python. Use the activated environment's Python instead.

-    RUN python3 -c "import dynamo; import vllm" || (echo "Failed to import Dynamo or vllm" && exit 1)
+    RUN . /opt/dynamo/venv/bin/activate && python -c "import dynamo; import vllm" || (echo "Failed to import Dynamo or vllm" && exit 1)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN python3 -c "import dynamo; import vllm" || (echo "Failed to import Dynamo or vllm" && exit 1)
RUN . /opt/dynamo/venv/bin/activate && python -c "import dynamo; import vllm" || (echo "Failed to import Dynamo or vllm" && exit 1)
🤖 Prompt for AI Agents
In Earthfile at line 216, the import verification uses `python3` which may not
point to the virtual environment's Python interpreter. Change the command to use
the Python executable from the activated virtual environment, typically
referenced by `$(which python)` or `$VIRTUAL_ENV/bin/python`, to ensure the
imports are checked within the correct environment.


SAVE IMAGE --push $DOCKER_SERVER/$IMAGE:$IMAGE_TAG

############### ALL TARGETS ##############################
all-test:
BUILD ./deploy/dynamo/operator+test

all-docker:
cloud-components:
ARG DOCKER_SERVER=my-registry
ARG IMAGE_TAG=latest
BUILD ./deploy/dynamo/operator+docker --DOCKER_SERVER=$DOCKER_SERVER --IMAGE_TAG=$IMAGE_TAG
BUILD ./deploy/dynamo/api-store+docker --DOCKER_SERVER=$DOCKER_SERVER --IMAGE_TAG=$IMAGE_TAG

base-images:
ARG DOCKER_SERVER=my-registry
ARG IMAGE_TAG=latest
BUILD +dynamo-base-docker --DOCKER_SERVER=$DOCKER_SERVER --IMAGE_TAG=$IMAGE_TAG
BUILD +dynamo-base-docker-llm --DOCKER_SERVER=$DOCKER_SERVER --IMAGE_TAG=$IMAGE_TAG

all-docker:
ARG DOCKER_SERVER=my-registry
ARG IMAGE_TAG=latest
BUILD +cloud-components --DOCKER_SERVER=$DOCKER_SERVER --IMAGE_TAG=$IMAGE_TAG
BUILD +base-images --DOCKER_SERVER=$DOCKER_SERVER --IMAGE_TAG=$IMAGE_TAG

all-lint:
BUILD ./deploy/dynamo/operator+lint

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ Although not needed for local development, deploying your Dynamo pipelines to Ku
Here's how to build it:

```bash
./container/build.sh
docker tag dynamo:latest-vllm <your-registry>/dynamo-base:latest-vllm
docker login <your-registry>
docker push <your-registry>/dynamo-base:latest-vllm
export DOCKER_SERVER=<your-registry>
export IMAGE_TAG=<your-tag>

earthly --push +dynamo-base-docker --DOCKER_SERVER=$DOCKER_SERVER --IMAGE_TAG=$IMAGE_TAG
```

After building, you can use this image by setting the `DYNAMO_IMAGE` environment variable to point to your built image:
```bash
export DYNAMO_IMAGE=<your-registry>/dynamo-base:latest-vllm
export DYNAMO_IMAGE=$DOCKER_SERVER/dynamo-base-docker-llm:$IMAGE_TAG
```

> [!NOTE]
Expand Down
166 changes: 166 additions & 0 deletions container/Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION 0.8

vllm-build:
ARG VLLM_REF="0.7.2"
ARG VLLM_PATCH="vllm_v${VLLM_REF}-dynamo-kv-disagg-patch.patch"
ARG VLLM_PATCHED_PACKAGE_NAME="ai_dynamo_vllm"
ARG VLLM_PATCHED_PACKAGE_VERSION="${VLLM_REF}.post1"

FROM nvcr.io/nvidia/cuda:12.8.1-runtime-ubuntu24.04
WORKDIR /workspace

# Install minimal required packages
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
python3-pip \
patch \
&& rm -rf /var/lib/apt/lists/*

# Create and activate virtual environment
RUN python3.12 -m venv /opt/venv
ENV VIRTUAL_ENV=/opt/venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"

# Copy the vllm subdirectory and requirements
COPY deps/vllm/ vllm/
COPY deps/requirements.txt /tmp/requirements.txt

# Install minimal requirements
RUN pip install --no-cache-dir pip wheel

RUN mkdir -p /workspace/dist
RUN mkdir /tmp/vllm && \
pip download --only-binary=:all: --no-deps --dest /tmp/vllm vllm==v${VLLM_REF} && \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the version specifier in pip download command.

The PyPI version format doesn't include the 'v' prefix. This will cause the download to fail.

Apply this diff to fix the version specifier:

-        pip download --only-binary=:all: --no-deps --dest /tmp/vllm vllm==v${VLLM_REF} && \
+        pip download --only-binary=:all: --no-deps --dest /tmp/vllm vllm==${VLLM_REF} && \
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pip download --only-binary=:all: --no-deps --dest /tmp/vllm vllm==v${VLLM_REF} && \
pip download --only-binary=:all: --no-deps --dest /tmp/vllm vllm==${VLLM_REF} && \
🤖 Prompt for AI Agents
In container/Earthfile at line 50, the pip download command incorrectly includes
a 'v' prefix in the version specifier for vllm, which is not valid for PyPI
versions. Remove the 'v' prefix from the version specifier so that it reads
vllm==${VLLM_REF} instead of vllm==v${VLLM_REF} to ensure the download succeeds.

cd /tmp/vllm && \
wheel unpack *.whl && \
cd vllm-${VLLM_REF}/ && \
patch -p1 < /workspace/vllm/${VLLM_PATCH} && \
# Rename the package
mv vllm-${VLLM_REF}.dist-info ${VLLM_PATCHED_PACKAGE_NAME}-${VLLM_PATCHED_PACKAGE_VERSION}.dist-info && \
sed -i "s/^Name: vllm/Name: ${VLLM_PATCHED_PACKAGE_NAME}/g" ${VLLM_PATCHED_PACKAGE_NAME}-${VLLM_PATCHED_PACKAGE_VERSION}.dist-info/METADATA && \
sed -i "s/^Version: ${VLLM_REF}/Version: ${VLLM_PATCHED_PACKAGE_VERSION}/g" ${VLLM_PATCHED_PACKAGE_NAME}-${VLLM_PATCHED_PACKAGE_VERSION}.dist-info/METADATA && \
# Update wheel tag
sed -i 's/Tag: cp38-abi3-linux_x86_64/Tag: cp38-abi3-manylinux1_x86_64/g' ${VLLM_PATCHED_PACKAGE_NAME}-${VLLM_PATCHED_PACKAGE_VERSION}.dist-info/WHEEL && \
sed -i "s/-cp38-abi3-linux_x86_64.whl/-cp38-abi3-manylinux1_x86_64.whl/g" ${VLLM_PATCHED_PACKAGE_NAME}-${VLLM_PATCHED_PACKAGE_VERSION}.dist-info/RECORD && \
wheel pack . --dest-dir /workspace/dist

# Save the built wheel as an artifact using a wildcard pattern
SAVE ARTIFACT /workspace/dist/ai_dynamo_vllm-*.whl

uv-source:
FROM ghcr.io/astral-sh/uv:latest
SAVE ARTIFACT /uv

nixl-source:
FROM ubuntu:24.04
WORKDIR /workspace

# Install git and ca-certificates for SSL verification
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Clone NIXL
ARG NIXL_COMMIT
RUN git clone https://github.com/ai-dynamo/nixl.git && \
cd nixl && \
git checkout ${NIXL_COMMIT}

# Save NIXL source as artifact
SAVE ARTIFACT /workspace/nixl /nixl

nixl-base:
FROM nvcr.io/nvidia/cuda-dl-base:25.01-cuda12.8-devel-ubuntu24.04
WORKDIR /opt/nixl
ARG NIXL_COMMIT

# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
ca-certificates \
cmake \
ninja-build \
python3 \
python3.12 \
python3.12-dev \
python3.12-venv \
autoconf \
automake \
libtool \
pkg-config \
libnuma1 \
libibverbs1 \
librdmacm1 \
curl \
meson \
&& rm -rf /var/lib/apt/lists/*

# Copy uv from artifact
COPY +uv-source/uv /bin/uv

# Create and activate virtual environment
RUN mkdir /opt/dynamo && \
uv venv /opt/dynamo/venv --python 3.12 && \
. /opt/dynamo/venv/bin/activate && \
uv pip install pip

ENV VIRTUAL_ENV=/opt/dynamo/venv
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
RUN uv pip install pybind11

# Build UCX
ARG UCX_VERSION=v1.18.0
RUN cd /usr/local/src && \
curl -fSsL "https://github.com/openucx/ucx/tarball/${UCX_VERSION}" | tar xz && \
cd openucx-ucx* && \
./autogen.sh && \
./configure --prefix=/usr/local \
--enable-shared \
--disable-static \
--disable-doxygen-doc \
--enable-optimizations \
--enable-cma \
--enable-devel-headers \
--with-cuda=/usr/local/cuda-12.8 \
--with-verbs \
--with-dm \
--enable-mt \
--with-mlx5-dv && \
make -j$(nproc) && \
make install && \
ldconfig

# Copy NIXL source from artifact
COPY +nixl-source/nixl ./

# Build NIXL
RUN mkdir build && \
meson setup build/ --prefix=/usr/local/nixl && \
cd build/ && \
ninja && \
ninja install

# Save artifacts
SAVE ARTIFACT /usr/local/nixl /nixl
SAVE ARTIFACT /opt/nixl /nixl_src
SAVE ARTIFACT /usr/lib/pkgconfig /pkgconfig
Loading