记一次vllm在5090上的安装

前言

直接最新的cuda 12.8 + vllm 0.12.0 + pytorch 2.9.0 跑不起来, 报错torch.AcceleratorError: CUDA error: the provided PTX was compiled with an unsupported toolchain.

降级vllm似乎无效, 寻求网上解决办法

找到一篇RTX5090本地部署vLLM,纯显卡运行Qwen3-32B-AWQ,推理速度2400tps(20250502)

那就按着来装, 再逐个升级看看是哪个依赖的问题

vllm安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#切换至目标文件夹:
#安装torch
pip3 install --force-reinstall torch==2.7.1 torchvision torchaudio-i https://pypi.tuna.tsinghua.edu.cn/simple
#安装VLLM
pip install vllm==0.9.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
#安装后可以手动更新一下新版的torch和triton.
MAX_JOBS=52 pip install flash-attn==2.8.1
MAX_JOBS=52 pip install triton==3.3.1
MAX_JOBS=52 pip install flashinfer==0.2.7.post1

#如果pip安装flashinfer出错,请使用下面的代码编译安装
git clone https://github.com/flashinfer-ai/flashinfer.git --recursive
cd flashinfer
python -m pip install -v .

记得使用清华源安装, MAX_JOBS应该是和线程数有关, 会增加内存占用, 8时会占满90g内存

flash-attn安装

MAX_JOBS=52 pip install flash-attn==2.8.1时卡住了, cpu并没有跑起来编译

随机考虑手动编译安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
pip install ninja -i https://pypi.tuna.tsinghua.edu.cn/simple
# 1. 克隆主仓库(使用镜像)
git clone https://gh-proxy.org/https://github.com/Dao-AILab/flash-attention
# 2. 进入目录
cd flash-attention
# 3. 配置 Git 自动替换子模块的 URL(关键步骤)
git config url."https://gh-proxy.org/https://github.com/".insteadOf "https://github.com/"
# 4. 现在更新子模块,所有 GitHub 依赖会通过镜像下载
git submodule update --init --recursive

pip install wheel==0.41.3 -i https://pypi.tuna.tsinghua.edu.cn/simple

export MAX_JOBS=2 # 4时爆90g内存了
python setup.py install

最后输出

1
2
Using /root/autodl-tmp/miniconda3/lib/python3.12/site-packages
Finished processing dependencies for flash-attn==2.8.3

就应该可以了, 然后继续安装

flashinfer安装

1
2
3
4
5
root@autodl-container-1e0644ba61-0c156f6d:~/flash-attention# pip install flashinfer==0.2.7.post1
DEPRECATION: Loading egg at /root/autodl-tmp/miniconda3/lib/python3.12/site-packages/flash_attn-2.8.3-py3.12-linux-x86_64.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330
Looking in indexes: http://mirrors.aliyun.com/pypi/simple
ERROR: Could not find a version that satisfies the requirement flashinfer==0.2.7.post1 (from versions: none)
ERROR: No matching distribution found for flashinfer==0.2.7.post1

阿里镜像居然没有

所以就直接编译安装

1
2
3
4
#如果pip安装flashinfer出错,请使用下面的代码编译安装
git clone https://github.com/flashinfer-ai/flashinfer.git --recursive
cd flashinfer
python -m pip install -v .

然后发现vllm版本太低了

算了直接装最新的, 发现其实是因为flash attention没有安装, 需要手动编译vllm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
pip install --upgrade --force-reinstall vllm xformers outlines outlines-core

pip install ninja

# 1. 卸载现有的 vLLM (防止版本冲突)
pip uninstall vllm -y

# 2. 克隆 vLLM 官方源码仓库
git clone https://github.com/vllm-project/vllm.git vllm_source

# 3. 进入目录并从源码编译安装
# 这一步最关键:pip 会调用 setup.py,根据当前机器的 CUDA 版本和 GPU 架构 (sm_100/120)
# 重新编译 _vllm_fa2_C.abi3.so 等底层内核。
cd vllm_source
pip install .

# 4. (安装完成后) 清理源码目录
cd ..
rm -rf vllm_source

如果发现没有使用flash attention, 可以export VLLM_ATTENTION_BACKEND=FLASH_ATTN强制启用

作者

Noah Shen

发布于

2025-12-17

更新于

2025-12-17

许可协议

评论