Skip to content

Commit e264987

Browse files
authored
[Doc] Add install doc (vllm-project#49)
Add official install guide. Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
1 parent 46977f9 commit e264987

File tree

3 files changed

+174
-28
lines changed

3 files changed

+174
-28
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ By using vLLM Ascend plugin, popular open-source models, including Transformer-l
3939
* PyTorch >= 2.4.0, torch-npu >= 2.4.0
4040
* vLLM (the same version as vllm-ascend)
4141

42-
Find more about how to setup your environment step by step in [here](docs/installation.md).
42+
Find more about how to setup your environment step by step in [here](docs/source/installation.md).
4343

4444
## Getting Started
4545

@@ -68,7 +68,7 @@ Run the following command to start the vLLM server with the [Qwen/Qwen2.5-0.5B-I
6868
vllm serve Qwen/Qwen2.5-0.5B-Instruct
6969
curl http://localhost:8000/v1/models
7070
```
71-
**Please refer to [official docs](./docs/index.md) for more details.**
71+
**Please refer to [official docs](https://vllm-ascend.readthedocs.io/en/latest/) for more details.**
7272

7373
## Contributing
7474
See [CONTRIBUTING](docs/source/developer_guide/contributing.md) for more details, which is a step-by-step guide to help you set up development environment, build and test.

README.zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ vLLM 昇腾插件 (`vllm-ascend`) 是一个让vLLM在Ascend NPU无缝运行的
3939
* PyTorch >= 2.4.0, torch-npu >= 2.4.0
4040
* vLLM (与vllm-ascend版本一致)
4141

42-
[此处](docs/installation.md),您可以了解如何逐步准备环境。
42+
[此处](docs/source/installation.md),您可以了解如何逐步准备环境。
4343

4444
## 开始使用
4545

@@ -69,7 +69,7 @@ vllm serve Qwen/Qwen2.5-0.5B-Instruct
6969
curl http://localhost:8000/v1/models
7070
```
7171

72-
**请参阅 [官方文档](./docs/index.md)以获取更多详细信息**
72+
**请参阅 [官方文档](https://vllm-ascend.readthedocs.io/en/latest/)以获取更多详细信息**
7373

7474
## 贡献
7575
有关更多详细信息,请参阅 [CONTRIBUTING](docs/source/developer_guide/contributing.zh.md),可以更详细的帮助您部署开发环境、构建和测试。

docs/source/installation.md

Lines changed: 170 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,65 @@
11
# Installation
22

3-
## Dependencies
4-
| Requirement | Supported version | Recommended version | Note |
5-
| ------------ | ------- | ----------- | ----------- |
6-
| Python | >= 3.9 | [3.10](https://www.python.org/downloads/) | Required for vllm |
7-
| CANN | >= 8.0.RC2 | [8.0.RC3](https://www.hiascend.com/developer/download/community/result?module=cann&cann=8.0.0.beta1) | Required for vllm-ascend and torch-npu |
8-
| torch-npu | >= 2.4.0 | [2.5.1rc1](https://gitee.com/ascend/pytorch/releases/tag/v6.0.0.alpha001-pytorch2.5.1) | Required for vllm-ascend |
9-
| torch | >= 2.4.0 | [2.5.1](https://github.com/pytorch/pytorch/releases/tag/v2.5.1) | Required for torch-npu and vllm required |
3+
This document describes how to install vllm-ascend manually.
104

11-
## Prepare Ascend NPU environment
5+
## Requirements
126

13-
Below is a quick note to install recommended version software:
7+
- OS: Linux
8+
- Python: 3.10 or higher
9+
- A hardware with Ascend NPU. It's usually the Atlas 800 A2 series.
10+
- Software:
1411

15-
### Containerized installation
12+
| Software | Supported version | Note |
13+
| ------------ | ----------------- | ---- |
14+
| CANN | >= 8.0.0.beta1 | Required for vllm-ascend and torch-npu |
15+
| torch-npu | >= 2.5.1rc1 | Required for vllm-ascend |
16+
| torch | >= 2.5.1 | Required for torch-npu and vllm |
1617

17-
You can use the [container image](https://hub.docker.com/r/ascendai/cann) directly with one line command:
18+
## Configure a new environment
19+
20+
Before installing the package, you need to make sure firmware/driver and CANN is installed correctly.
21+
22+
### Install firmwares and drivers
23+
24+
To verify that the Ascend NPU firmware and driver were correctly installed, run `npu-smi` info
25+
26+
> Tips: Refer to [Ascend Environment Setup Guide](https://ascend.github.io/docs/sources/ascend/quick_install.html) for more details.
27+
28+
### Install CANN (optional)
29+
30+
The installation of CANN wouldn’t be necessary if you are using a CANN container image, you can skip this step.If you want to install vllm-ascend on a bare environment by hand, you need install CANN first.
1831

1932
```bash
20-
docker run \
33+
# Create a virtual environment
34+
python -m venv vllm-ascend-env
35+
source vllm-ascend-env/bin/activate
36+
37+
# Install required python packages.
38+
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple attrs numpy==1.24.0 decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions
39+
40+
# Download and install the CANN package.
41+
wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.0.0/Ascend-cann-toolkit_8.0.0_linux-aarch64.run
42+
sh Ascend-cann-toolkit_8.0.0_linux-aarch64.run --full
43+
wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.0.0/Ascend-cann-kernels-910b_8.0.0_linux-aarch64.run
44+
sh Ascend-cann-kernels-910b_8.0.0_linux-aarch64.run --full
45+
```
46+
47+
Once it's done, you can read either **Set up using Python** or **Set up using Docker** section to install and use vllm-ascend.
48+
49+
## Set up using Python
50+
51+
> Notes: If you are installing vllm-ascend on an arch64 machine, The `-f https://download.pytorch.org/whl/torch/` command parameter in this section can be omitted. It's only used for find torch package on x86 machine.
52+
53+
Please make sure that CANN is installed. It can be done by **Configure a new environment** step. Or by using an CANN container directly:
54+
55+
```bash
56+
# Setup a CANN container using docker
57+
# Update DEVICE according to your device (/dev/davinci[0-7])
58+
DEVICE=/dev/davinci7
59+
60+
docker run --rm \
2161
--name vllm-ascend-env \
22-
--device /dev/davinci1 \
62+
--device $DEVICE \
2363
--device /dev/davinci_manager \
2464
--device /dev/devmm_svm \
2565
--device /dev/hisi_hdc \
@@ -28,28 +68,134 @@ docker run \
2868
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
2969
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
3070
-v /etc/ascend_install.info:/etc/ascend_install.info \
31-
-it quay.io/ascend/cann:8.0.rc3.beta1-910b-ubuntu22.04-py3.10 bash
71+
-it quay.io/ascend/cann:8.0.0.beta1-910b-ubuntu22.04-py3.10 bash
3272
```
3373

34-
You do not need to install `torch` and `torch_npu` manually, they will be automatically installed as `vllm-ascend` dependencies.
74+
Then you can install vllm-ascend from **pre-built wheel** or **source code**.
75+
76+
### Install from Pre-built wheels (Not support yet)
3577

36-
### Manual installation
78+
1. Install vllm
3779

38-
Or follow the instructions provided in the [Ascend Installation Guide](https://ascend.github.io/docs/sources/ascend/quick_install.html) to set up the environment.
80+
Since vllm on pypi is not compatible with cpu, we need to install vllm from source code.
3981

40-
## Building
82+
```bash
83+
git clone --depth 1 --branch v0.7.1 https://github.com/vllm-project/vllm
84+
cd vllm
85+
VLLM_TARGET_DEVICE=empty pip install . -f https://download.pytorch.org/whl/torch/
86+
```
4187

42-
### Build Python package from source
88+
2. Install vllm-ascend
89+
90+
```bash
91+
pip install vllm-ascend -f https://download.pytorch.org/whl/torch/
92+
```
93+
94+
### Install from source code
95+
96+
1. Install vllm
97+
98+
```bash
99+
git clone https://github.com/vllm-project/vllm
100+
cd vllm
101+
VLLM_TARGET_DEVICE=empty pip install . -f https://download.pytorch.org/whl/torch/
102+
```
103+
104+
2. Install vllm-ascend
105+
106+
```bash
107+
git clone https://github.com/vllm-project/vllm-ascend.git
108+
cd vllm-ascend
109+
pip install -e . -f https://download.pytorch.org/whl/torch/
110+
```
111+
112+
## Set up using Docker
113+
114+
> Tips: CANN, torch, torch_npu, vllm and vllm_ascend are pre-installed in the Docker image already.
115+
116+
### Pre-built images (Not support yet)
117+
118+
Just pull the image and run it with bash.
43119

44120
```bash
45-
git clone https://github.com/vllm-project/vllm-ascend.git
46-
cd vllm-ascend
47-
pip install -e .
121+
docker pull quay.io/ascend/vllm-ascend:latest
122+
123+
# Update DEVICE according to your device (/dev/davinci[0-7])
124+
DEVICE=/dev/davinci7
125+
126+
docker run --rm \
127+
--name vllm-ascend-env \
128+
--device $DEVICE \
129+
--device /dev/davinci_manager \
130+
--device /dev/devmm_svm \
131+
--device /dev/hisi_hdc \
132+
-v /usr/local/dcmi:/usr/local/dcmi \
133+
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
134+
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
135+
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
136+
-v /etc/ascend_install.info:/etc/ascend_install.info \
137+
-it quay.io/ascend/vllm-ascend:0.7.1rc1 bash
48138
```
49139

50-
### Build container image from source
140+
### Build image from source
141+
142+
If you want to build the docker image from main branch, you can do it by following steps:
143+
51144
```bash
52145
git clone https://github.com/vllm-project/vllm-ascend.git
53146
cd vllm-ascend
54-
docker build -t vllm-ascend-dev-image -f ./Dockerfile .
147+
148+
docker build -t vllm-ascend-dev-image:latest -f ./Dockerfile .
149+
150+
# Update DEVICE according to your device (/dev/davinci[0-7])
151+
DEVICE=/dev/davinci7
152+
153+
docker run --rm \
154+
--name vllm-ascend-env \
155+
--device $DEVICE \
156+
--device /dev/davinci_manager \
157+
--device /dev/devmm_svm \
158+
--device /dev/hisi_hdc \
159+
-v /usr/local/dcmi:/usr/local/dcmi \
160+
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
161+
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
162+
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
163+
-v /etc/ascend_install.info:/etc/ascend_install.info \
164+
-it vllm-ascend-dev-image:latest bash
165+
```
166+
167+
## Extra information
168+
169+
### Verify installation
170+
171+
Create and run a simple inference test. The `example.py` can be like:
172+
173+
```python
174+
from vllm import LLM, SamplingParams
175+
176+
prompts = [
177+
"Hello, my name is",
178+
"The president of the United States is",
179+
"The capital of France is",
180+
"The future of AI is",
181+
]
182+
183+
# Create a sampling params object.
184+
sampling_params = SamplingParams(max_tokens=100, temperature=0.0)
185+
# Create an LLM.
186+
llm = LLM(model="facebook/opt-125m")
187+
188+
# Generate texts from the prompts.
189+
outputs = llm.generate(prompts, sampling_params)
190+
for output in outputs:
191+
prompt = output.prompt
192+
generated_text = output.outputs[0].text
193+
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
194+
```
195+
196+
Then run:
197+
198+
```bash
199+
# export VLLM_USE_MODELSCOPE=true to speed up download if huggingface is not reachable.
200+
python example.py
55201
```

0 commit comments

Comments
 (0)