vllm源码编译
官方推荐使用 uv 创建 venv
虚拟环境中先安装 pyproject.toml 中 requires 依赖,安装 requirements 目录下 common.txt cuda.txt 依赖
在 setup.py 文件中可以指定cmake每次使用固定目录,默认每次随机不同的临时目录
class cmake_build_ext(build_ext):
def finalize_options(self):
super().finalize_options()
self.build_temp = os.path.join(os.getcwd(), "build")
提前下载依赖代码并切换版本
mkdir -p .deps
git clone https://github.com/NVIDIA/cutlass.git .deps/cutlass-src
git clone https://github.com/vllm-project/flash-attention.git .deps/vllm-flash-attn-src
git clone https://github.com/vllm-project/FlashMLA.git .deps/flashmla-src
git clone https://github.com/deepseek-ai/DeepGEMM.git .deps/deepgemm-src
git clone https://github.com/IST-DASLab/qutlass.git .deps/qutlass-src
git clone https://github.com/triton-lang/triton.git .deps/triton_kernels-src
grep -RInA8 -B4 "GIT_REPOSITORY" CMakeLists.txt cmake/external_projects
grep -RInA8 -B4 "GIT_REPOSITORY" CMakeLists.txt cmake/external_projects
git -C .deps/cutlass-src checkout <tag-or-commit>
安装:
cd /root/code/vllm
export VLLM_TARGET_DEVICE=cuda
export CMAKE_BUILD_TYPE=RelWithDebInfo
# export CMAKE_BUILD_TYPE=Debug # 调试版本
# export CMAKE_ARGS="-DCMAKE_CUDA_FLAGS_DEBUG='-G -lineinfo'" # 指定kernel调试
# 指定 blackwell 架构
export TORCH_CUDA_ARCH_LIST="12.0"
# 指定并发数,防止编译时oom
export MAX_JOBS=2
export NVCC_THREADS=2
export VERBOSE=1
uv pip install -e . --no-build-isolation -v

浙公网安备 33010602011771号