Nano-vLLM 环境搭建

294 字
1 分钟
Nano-vLLM 环境搭建

比较少的人去讲 nano-vllm 的环境搭建,这里简单记录一下:

  1. 克隆仓库。
Terminal window
git clone https://github.com/GeeeekExplorer/nano-vllm.git
cd nano-vllm
  1. 搭建虚拟环境。
Terminal window
uv venv --seed --python=3.12
source .venv/bin/activate
  1. 安装 torch 依赖。
Terminal window
# uv pip install torch
uv pip install torch --index-url https://download.pytorch.org/whl/cu126
  1. 安装 flash-attn 依赖,这里使用预编译的 wheel 加速环境搭建。每个人的环境不一样,选择符合自己环境的。
Terminal window
# 根据 torch 版本和 cpython 版本选择合适的 wheel
# 官方 wheels: https://github.com/Dao-AILab/flash-attention/releases
# 更多 wheels: https://github.com/mjun0812/flash-attention-prebuild-wheels/releases
wget 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.whl
uv pip install flash_attn-2.8.3+cu126torch2.13-cp312-cp312-linux_x86_64.whl
  1. 安装 nano-vllm。
Terminal window
uv pip install --no-build-isolation -e .
  1. 下载模型权重,这一步最好关闭梯子。
Terminal window
uv pip install -U huggingface_hub
export HF_ENDPOINT="https://hf-mirror.com"
hf download Qwen/Qwen3-0.6B --local-dir ~/huggingface/Qwen3-0.6B
  1. 测试运行。
Terminal window
python example.py
Note

可能遇到的 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/
作者
Ming
发布于
2026-08-12
许可协议
CC BY-NC-SA 4.0
Profile Image of the Author
Ming
你是来找 Ming 学习的吗
🎉 欢迎来到 Ming 的博客
这里是我的个人博客,分享 AI Infra、LLM 等技术内容。欢迎关注交流!
分类
标签
站点统计
文章
19
分类
8
标签
16
总字数
55,114
运行时长
0
最后活动
0 天前

目录