Pixiv - おむたつ/omutatsu
Nano-vLLM 环境搭建
294 字
1 分钟
Nano-vLLM 环境搭建
比较少的人去讲 nano-vllm 的环境搭建,这里简单记录一下:
- 克隆仓库。
git clone https://github.com/GeeeekExplorer/nano-vllm.gitcd nano-vllm- 搭建虚拟环境。
uv venv --seed --python=3.12source .venv/bin/activate- 安装 torch 依赖。
# uv pip install torchuv pip install torch --index-url https://download.pytorch.org/whl/cu126- 安装
flash-attn依赖,这里使用预编译的 wheel 加速环境搭建。每个人的环境不一样,选择符合自己环境的。
# 根据 torch 版本和 cpython 版本选择合适的 wheel# 官方 wheels: https://github.com/Dao-AILab/flash-attention/releases# 更多 wheels: https://github.com/mjun0812/flash-attention-prebuild-wheels/releaseswget https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.9.47/flash_attn-2.8.3+cu126torch2.13-cp312-cp312-linux_x86_64.whluv pip install flash_attn-2.8.3+cu126torch2.13-cp312-cp312-linux_x86_64.whl- 安装 nano-vllm。
uv pip install --no-build-isolation -e .- 下载模型权重,这一步最好关闭梯子。
uv pip install -U huggingface_hubexport HF_ENDPOINT="https://hf-mirror.com"hf download Qwen/Qwen3-0.6B --local-dir ~/huggingface/Qwen3-0.6B- 测试运行。
python example.pyNote
可能遇到的 CUDA 版本问题
如果你遇到报错 “libcudart.so.12: cannot open shared object file: No such file or directory”,大概率是 CUDA 版本不兼容的问题。
如果你安装的 flash-attn 是 "flash_attn-2.8.3+cu126torch2.13-cp312-cp312-linux_x86_64.whl",其依赖 12.x 版本的 CUDA Runtime 和 2.13 版本的 torch。
所以你最好使用 uv pip install torch==2.13 --index-url https://download.pytorch.org/whl/cu126 来安装 torch。
但是你需要先确保你装的 NVIDIA Driver 可以支持到 12.x 版本的 CUDA, 你可以通过 nvidia-smi 进行查看。
支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!
Nano-vLLM 环境搭建
https://llm-tech.com.cn/posts/nano-vllm-setup/