NVIDIA Dynamo源码编译

发布于:2025-03-22 ⋅ 阅读:(150) ⋅ 点赞:(0)

Ref

https://github.com/PyO3/maturin

Rust 程序设计语言

代码库:

https://github.com/ai-dynamo/dynamo

https://github.com/ai-dynamo/nixl

dynamo/container/Dockerfile.vllm

相关whl包

官方提供了4个whl包

ai_dynamo # 这个包ubuntu 22.04也可以用,ubuntu 24.04可以直接安装不用重新编译。包含的是sdk部分。绝大多数是Python,少量bin。

ai_dynamo_runtime # 包含llm和runtime部分

ai_dynamo_vllm # VLLM的修改版本,有DynamoNixlConnector作为kv_connector, 还有KvMetrics的发送。apply container/deps/vllm/vllm_v0.7.2-dynamo-kv-disagg-patch.patch to vLLM[v0.7.2] source code

nixl # 通信库

上述包可以直接基于pip install在pypi上下载和安装。但是需要ubuntu 24.04系统。

构建ai_dynamo

Install uvuv

curl -LsSf https://astral.sh/uv/install.sh | sh

在顶层目录:

uv build --wheel --out-dir /workspace/dist

构建ai_dynamo_runtime

参考https://github.com/ai-dynamo/dynamo/tree/main/lib/bindings/python

下载rust环境:

国内服务器最好设置环境变量,否则rustup-init.sh运行时的下载极其慢:

export RUSTUP_DIST_SERVER='https://mirrors.ustc.edu.cn/rust-static'
export RUSTUP_UPDATE_ROOT='https://mirrors.ustc.edu.cn/rust-static/rustup'
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
wget https://static.rust-lang.org/rustup/rustup-init.sh
./rustup-init.sh

安装依赖:

这里假设你已经有一个Python conda环境,否则可以安装miniconda设置环境,或者按照推荐使用uv环境。

pip install maturin
apt install protobuf-compiler

下载源码:

git clone --recursive https://github.com/ai-dynamo/dynamo.git
git clone --recursive https://github.com/ai-dynamo/nixl.git

在目录dynamo/lib/bindings/python运行

maturin build

即可在target/wheels/生成whl包。

或者:

uv build --wheel --out-dir /workspace/dist

构建nixl

依赖安装

sudo apt install -y build-essential cmake pkg-config
pip install meson ninja pybind11

在nixl源码目录执行(路径根据你的需求修改):

INSTALL_DIR=/root/nixl
UCX_INSTALL_DIR=/root/ucx

./util/build.sh $INSTALL_DIR $UCX_INSTALL_DIR

或者参考readme.md和util/build.sh分别构建ucx和nixl

首先构建ucx

wget https://github.com/openucx/ucx/releases/download/v1.18.0/ucx-1.18.0.tar.gz
tar xzf ucx-1.18.0.tar.gz
cd ucx-1.18.0
./contrib/configure-release --prefix=/root/ucx
make -j8
make install

构建nixl wheel包

在nixl源码路径,设置编译好的ucx路径

ref https://mesonbuild.com/meson-python/how-to-guides/meson-args.html

python -m pip wheel --config-settings=setup-args="-Ducx_path=/root/ucx" .
# or 
pip install build
python -m build -Csetup-args="-Ducx_path=/root/ucx" .

 或者:

uv build --wheel --out-dir /workspace/dist

构建ai_dynamo_vllm

下载VLLM 0.7.2的分支,然后打patch dynamo\container\deps\vllm\vllm_v0.7.2-dynamo-kv-disagg-patch.patch,然后源码编译VLLM。

相当于直接编译VLLM,参考vllm doc和其他博客

Installation — vLLM

https://github.com/vllm-project/vllm/blob/main/.github/workflows/scripts/build.sh 

https://zhuanlan.zhihu.com/p/692200573

# for cuda12.1, pytorch 2.5.1
# v0.0.28.post3 build for PyTorch 2.5.1
pip3 install -U xformers==v0.0.28.post3 --index-url https://download.pytorch.org/whl/cu121
git clone --recursive -b v0.7.2 https://github.com/vllm-project/vllm.git
git apply dynamo/container/deps/vllm/vllm_v0.7.2-dynamo-kv-disagg-patch.patch

python setup.py bdist_wheel

注意事项

需要确保你的网络通畅,否则编译过程下载各种代码库和软件包失败导致编译失败。


网站公告

今日签到

点亮在社区的每一天
去签到