2025-02-11 12:00:27 +08:00
|
|
|
# Installation
|
|
|
|
|
|
2025-02-14 10:22:15 +08:00
|
|
|
This document describes how to install vllm-ascend manually.
|
2025-02-05 10:53:12 +08:00
|
|
|
|
2025-02-14 10:22:15 +08:00
|
|
|
## Requirements
|
2025-02-05 10:53:12 +08:00
|
|
|
|
2025-02-14 10:22:15 +08:00
|
|
|
- OS: Linux
|
|
|
|
|
- Python: 3.10 or higher
|
|
|
|
|
- A hardware with Ascend NPU. It's usually the Atlas 800 A2 series.
|
|
|
|
|
- Software:
|
2025-02-05 10:53:12 +08:00
|
|
|
|
2025-02-14 10:22:15 +08:00
|
|
|
| Software | Supported version | Note |
|
|
|
|
|
| ------------ | ----------------- | ---- |
|
|
|
|
|
| CANN | >= 8.0.0.beta1 | Required for vllm-ascend and torch-npu |
|
|
|
|
|
| torch-npu | >= 2.5.1rc1 | Required for vllm-ascend |
|
|
|
|
|
| torch | >= 2.5.1 | Required for torch-npu and vllm |
|
2025-02-05 10:53:12 +08:00
|
|
|
|
2025-02-14 10:22:15 +08:00
|
|
|
## Configure a new environment
|
|
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
Before installing, you need to make sure firmware/driver and CANN is installed correctly.
|
2025-02-14 10:22:15 +08:00
|
|
|
|
|
|
|
|
### Install firmwares and drivers
|
|
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
To verify that the Ascend NPU firmware and driver were correctly installed, run:
|
2025-02-05 10:53:12 +08:00
|
|
|
|
|
|
|
|
```bash
|
2025-02-17 22:12:07 +08:00
|
|
|
npu-smi info
|
2025-02-14 10:22:15 +08:00
|
|
|
```
|
|
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
Refer to [Ascend Environment Setup Guide](https://ascend.github.io/docs/sources/ascend/quick_install.html) for more details.
|
|
|
|
|
|
|
|
|
|
### Install CANN
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
:::::{tab-set}
|
|
|
|
|
:sync-group: install
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
::::{tab-item} Using pip
|
|
|
|
|
:selected:
|
|
|
|
|
:sync: pip
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
The easiest way to prepare your CANN environment is using container directly:
|
2025-02-14 10:22:15 +08:00
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Update DEVICE according to your device (/dev/davinci[0-7])
|
|
|
|
|
DEVICE=/dev/davinci7
|
|
|
|
|
|
|
|
|
|
docker run --rm \
|
2025-02-05 10:53:12 +08:00
|
|
|
--name vllm-ascend-env \
|
2025-02-14 10:22:15 +08:00
|
|
|
--device $DEVICE \
|
2025-02-05 10:53:12 +08:00
|
|
|
--device /dev/davinci_manager \
|
|
|
|
|
--device /dev/devmm_svm \
|
|
|
|
|
--device /dev/hisi_hdc \
|
|
|
|
|
-v /usr/local/dcmi:/usr/local/dcmi \
|
|
|
|
|
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
|
|
|
|
|
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
|
|
|
|
|
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
|
|
|
|
|
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
2025-02-14 10:22:15 +08:00
|
|
|
-it quay.io/ascend/cann:8.0.0.beta1-910b-ubuntu22.04-py3.10 bash
|
2025-02-05 10:53:12 +08:00
|
|
|
```
|
|
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
You can also install CANN manually:
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
```bash
|
|
|
|
|
# Create a virtual environment
|
|
|
|
|
python -m venv vllm-ascend-env
|
|
|
|
|
source vllm-ascend-env/bin/activate
|
2025-02-05 10:53:12 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
# Install required python packages.
|
|
|
|
|
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
|
2025-02-05 10:53:12 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
# Download and install the CANN package.
|
|
|
|
|
wget https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.0.0/Ascend-cann-toolkit_8.0.0_linux-aarch64.run
|
|
|
|
|
sh Ascend-cann-toolkit_8.0.0_linux-aarch64.run --full
|
|
|
|
|
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
|
|
|
|
|
sh Ascend-cann-kernels-910b_8.0.0_linux-aarch64.run --full
|
|
|
|
|
```
|
2025-02-05 10:53:12 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
::::
|
2025-02-11 14:28:26 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
::::{tab-item} Using Docker
|
|
|
|
|
:sync: docker
|
|
|
|
|
No more extra step if you are using `vllm-ascend` image.
|
|
|
|
|
::::
|
|
|
|
|
:::::
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
Once it's done, you can start to set up `vllm` and `vllm-ascend`.
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
## Setup vllm and vllm-ascend
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
:::::{tab-set}
|
|
|
|
|
:sync-group: install
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
::::{tab-item} Using pip
|
|
|
|
|
:selected:
|
|
|
|
|
:sync: pip
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
You can install `vllm` and `vllm-ascend` from **pre-built wheel**:
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
```bash
|
|
|
|
|
pip install vllm vllm-ascend -f https://download.pytorch.org/whl/torch/
|
|
|
|
|
```
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
or build from **source code**:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
git clone https://github.com/vllm-project/vllm
|
|
|
|
|
cd vllm
|
|
|
|
|
VLLM_TARGET_DEVICE=empty pip install . -f https://download.pytorch.org/whl/torch/
|
|
|
|
|
|
|
|
|
|
git clone https://github.com/vllm-project/vllm-ascend.git
|
|
|
|
|
cd vllm-ascend
|
|
|
|
|
pip install -e . -f https://download.pytorch.org/whl/torch/
|
|
|
|
|
```
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
::::
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
::::{tab-item} Using docker
|
|
|
|
|
:sync: docker
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
You can just pull the **prebuilt image** and run it with bash.
|
2025-02-11 14:28:26 +08:00
|
|
|
|
|
|
|
|
```bash
|
2025-02-17 22:12:07 +08:00
|
|
|
|
2025-02-14 10:22:15 +08:00
|
|
|
|
|
|
|
|
# Update DEVICE according to your device (/dev/davinci[0-7])
|
|
|
|
|
DEVICE=/dev/davinci7
|
2025-02-17 22:12:07 +08:00
|
|
|
# Update the vllm-ascend image
|
|
|
|
|
IMAGE=quay.io/ascend/vllm-ascend:main
|
|
|
|
|
docker pull $IMAGE
|
2025-02-14 10:22:15 +08:00
|
|
|
docker run --rm \
|
|
|
|
|
--name vllm-ascend-env \
|
|
|
|
|
--device $DEVICE \
|
|
|
|
|
--device /dev/davinci_manager \
|
|
|
|
|
--device /dev/devmm_svm \
|
|
|
|
|
--device /dev/hisi_hdc \
|
|
|
|
|
-v /usr/local/dcmi:/usr/local/dcmi \
|
|
|
|
|
-v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
|
|
|
|
|
-v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \
|
|
|
|
|
-v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \
|
|
|
|
|
-v /etc/ascend_install.info:/etc/ascend_install.info \
|
2025-02-17 22:12:07 +08:00
|
|
|
-it $IMAGE bash
|
2025-02-11 14:28:26 +08:00
|
|
|
```
|
|
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
or build IMAGE from **source code**:
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-11 14:28:26 +08:00
|
|
|
```bash
|
|
|
|
|
git clone https://github.com/vllm-project/vllm-ascend.git
|
|
|
|
|
cd vllm-ascend
|
2025-02-14 10:22:15 +08:00
|
|
|
docker build -t vllm-ascend-dev-image:latest -f ./Dockerfile .
|
2025-02-17 22:12:07 +08:00
|
|
|
```
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
::::
|
2025-02-14 10:22:15 +08:00
|
|
|
|
2025-02-17 22:12:07 +08:00
|
|
|
:::::
|
2025-02-14 10:22:15 +08:00
|
|
|
|
|
|
|
|
## Extra information
|
|
|
|
|
|
|
|
|
|
### Verify installation
|
|
|
|
|
|
|
|
|
|
Create and run a simple inference test. The `example.py` can be like:
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
from vllm import LLM, SamplingParams
|
|
|
|
|
|
|
|
|
|
prompts = [
|
|
|
|
|
"Hello, my name is",
|
|
|
|
|
"The president of the United States is",
|
|
|
|
|
"The capital of France is",
|
|
|
|
|
"The future of AI is",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
# Create a sampling params object.
|
|
|
|
|
sampling_params = SamplingParams(max_tokens=100, temperature=0.0)
|
|
|
|
|
# Create an LLM.
|
|
|
|
|
llm = LLM(model="facebook/opt-125m")
|
|
|
|
|
|
|
|
|
|
# Generate texts from the prompts.
|
|
|
|
|
outputs = llm.generate(prompts, sampling_params)
|
|
|
|
|
for output in outputs:
|
|
|
|
|
prompt = output.prompt
|
|
|
|
|
generated_text = output.outputs[0].text
|
|
|
|
|
print(f"Prompt: {prompt!r}, Generated text: {generated_text!r}")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then run:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# export VLLM_USE_MODELSCOPE=true to speed up download if huggingface is not reachable.
|
|
|
|
|
python example.py
|
2025-02-11 14:28:26 +08:00
|
|
|
```
|