安装指南
本教程面向使用 roll & Ascend 的开发者,帮助完成昇腾环境下 roll 的安装。
昇腾环境安装
请根据已有昇腾产品型号及 CPU 架构等按照 快速安装昇腾环境指引 进行昇腾环境安装。
警告
CANN 最低版本为 8.2.RC1,安装 CANN 时,请同时安装 Kernel 算子包以及 nnal 加速库软件包。
Python 环境创建
1# 创建名为 roll 的 python 3.10 的虚拟环境
2conda create -y -n roll python=3.10
3# 激活虚拟环境
4conda activate roll
Torch 安装创建
1# 安装 torch 的 CPU 版本
2pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu
3
4# 安装 torch_npu
5pip install torch_npu==2.5.1
vllm & vllm-ascend 安装
1# vllm
2git clone -b v0.8.4 --depth 1 https://github.com/vllm-project/vllm.git
3cd vllm
4
5VLLM_TARGET_DEVICE=empty pip install -v -e .
6cd ..
1# vllm-ascend
2git clone -b v0.8.4rc2 --depth 1 https://github.com/vllm-project/vllm-ascend.git
3cd vllm-ascend
4
5export COMPILE_CUSTOM_KERNELS=1
6pip install -e .
7cd ..
如果在安装 vllm-ascend 时遇到类似以下问题:
1RuntimeError: CMake configuration failed: Command '['/pathto/miniconda3/envs/roll/bin/python3.10', '-m', 'pybind11', '--cmake']' returned non-zero exit status 2.
可尝试在 vllm-ascend 目录下 setup.py 文件 151-158 行进行如下修改并重新进行编译:
1try:
2 # if pybind11 is installed via pip
3 pybind11_cmake_path = (subprocess.check_output(
4 [python_executable, "-m", "pybind11",
5 "--cmakedir"]).decode().strip())
6except subprocess.CalledProcessError as e:
7 # else specify pybind11 path installed from source code on CI container
8 raise RuntimeError(f"CMake configuration failed: {e}")
安装 roll
使用以下指令安装 roll 及相关依赖:
1git clone https://github.com/alibaba/ROLL.git
2cd ROLL
3
4# Install roll dependencies
5pip install -r requirements_common.txt
6pip install deepspeed==0.16.0
其他第三方库说明
Software |
Description |
|---|---|
transformers |
v4.52.4 |
flash_attn |
not supported |
transformer-engine[pytorch] |
not supported |
支持通过 transformers 使能 --flash_attention_2, transformers 需等于 4.52.4版本。
不支持通过 flash_attn 使能 flash attention 加速。
暂不支持 transformer-engine[pytorch]。
1pip install transformers==4.52.4