Skip to content

Commit bb1bd5b

Browse files
committed
add offline vllm nb
1 parent 9ecdd48 commit bb1bd5b

File tree

11 files changed

+99
-0
lines changed

11 files changed

+99
-0
lines changed

neuron/vLLM/01-offline_inference_neuron.ipynb renamed to neuron/vLLM/01-offline-inference_neuron/01-offline_inference_neuron.ipynb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
"\n"
1414
]
1515
},
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {},
19+
"source": [
20+
"# 1. 사전 필수 단계\n",
21+
"- 아래를 클릭하셔서 사전 단계를 수행 하세요.\n",
22+
" - [AWS Inferentia2 설치 및 실행 가이드](Readme.md)"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"metadata": {},
28+
"source": [
29+
"# 2. 배치 추론 실행"
30+
]
31+
},
1632
{
1733
"cell_type": "code",
1834
"execution_count": null,
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# AWS Inferentia 기반 위에 vLLM offline 추론하기
2+
3+
Last Update: Mar 31, 2024
4+
5+
---
6+
7+
이 튜토리얼은 inf2.48xlarge 로 vLLM 에서 Offline 추론을 위한 가이드 입니다.
8+
아래의 내용은 [vLLM Project Git Repo](https://github.com/vllm-project/vllm)[examples/offline_inference_neuron.py](https://github.com/vllm-project/vllm/blob/main/examples/offline_inference_neuron.py) 를 노트북에서 실행한 예시 입니다.
9+
10+
11+
<p>
12+
13+
# 1. 기본 사전 단계
14+
## Quota 준비
15+
- 먼저 AWS 계정에 아래에 해당되는 기본적인 [Quota](https://docs.aws.amazon.com/servicequotas/latest/userguide/intro.html) 가 필요 합니다. [inf2.48xlarge](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/arch/neuron-hardware/inf2-arch.html) 는 vCPU 가 192개 필요하므로 Running On-Demand Inf Instances 가 192 개 이상 있어야 합니다.
16+
- ![quota.jpg](../../tutorial/inference-Llama-2-13b/img/quota.jpg)
17+
18+
# 2. 기본 환경
19+
- vLLM 의 공식 가이드,[vLLM Installation on Neuron](https://docs.vllm.ai/en/latest/getting_started/neuron-installation.html#) , 을 아래에 실행 합니다. 다만, 2024년 3월 31일 현재 소스로 부터 vLLM 설치가 에러가 발생하여 pip install vllm 으로 설치 합니다.
20+
21+
## 2.1. Launch the Instance (inf2.48xlarge EC2 생성)
22+
- Region: us-east-1, Subnet: us-east-1c, AZ: use1-az6 에서 진행 했음.
23+
- AMI, Instance Type 지정.
24+
- ![install_ec2_inf2-hf.png](../../hf-optimum/01-Chatbot-Llama-2-13B-Inf2/img/install_ec2_inf2-hf.png)
25+
- [중요] <u>Storage 는 200 GB 로 수정해주세요.</u>
26+
- Trouble Shooting: Error
27+
- inf2.48xlarge EC2 런칭시에 아래와 같은 에러:
28+
- Failed to start the instance i-04c1XXXXXXXX The requested configuration is currently not supported. Please check the documentation for supported configurations.
29+
- 솔루션
30+
- 위의 이유는 해당 Region 및 Availability Zone (AZ) 에 해당 EC2 가 부족하여 발생하는 에러 입니다. EC2 생성시에 Network 부분의 Subnet 을 바꾸어서 해보세요. 그래도 에러가 발생하면 AWS Account 팀에 문의 바랍니다.
31+
32+
## 2.2 EC2 Connection
33+
- 편하신 방법으로 EC2 에 SSH 로 연결하시면 됩니다. 저는 로컬에서 VS Code Remote Connection 으로 연결 하였습니다.
34+
- ![VSCode.png](../../tutorial/inference-Llama-2-13b/img/VSCode.png)
35+
36+
37+
## 2.3 필요 Neuron Driver 및 필요 패키지 설치
38+
- vLLM 의 공식 가이드,[vLLM Installation on Neuron](https://docs.vllm.ai/en/latest/getting_started/neuron-installation.html#) 의 참조해서 설치 하신 후에 아래와 같이 버전을 확인 합니다.
39+
40+
- Step 1. Install drivers and tools
41+
- ![neuronx_version.jpg](img/neuronx_version.jpg)
42+
- Step 2. Install transformers-neuronx and its dependencies
43+
- ![torch_transformer_version.jpg](img/torch_transformer_version.jpg)
44+
- Step 3. Install vLLM from pip (Source 로 부터 설치는 Mar 31, 2024 현재 에러가 발생하여 PIP 로 설치 합니다.)
45+
- 아래 PIP 로 실행
46+
```
47+
pip install vllm
48+
```
49+
- 이후에 아래와 같이 설치 됩니다. (_C 모듈 설치 됨)
50+
- ![pip_install.jpg](img/pip_install.jpg)
51+
- Step 4. neuron 모듈을 수동으로 카피 (이 과정은 추후에 버그 수정이 되면 안해도 됩니다.)
52+
- 아래 파일을 다운로드 받고, vllm.model_executor.models.neuron 의 폴더 내용을 아래의 그림과 같이 복사 합니다. 그리고 neuron 폴더 안에 __init__.py 파일을 생성 해주어야 합니다.
53+
- https://github.com/vllm-project/vllm/archive/refs/tags/v0.3.3.tar.gz
54+
- ![neuron_folder.jpg](img/neuron_folder.jpg)
55+
56+
57+
58+
# 3.코드 실행
59+
## 3.1 examples/offline_inference_neuron.py 실행
60+
- VS Code 열기
61+
- ![vs_code_ide.jpg](img/vs_code_ide.jpg)
62+
- 터미널을 열고, 설치된 가상 환경으로 진입후에 해당 파일을 실행 함.
63+
- ![run_py_code.jpg](img/run_py_code.jpg)
64+
65+
## 3.2 examples/offline_inference_neuron.py 내용을 Jupyter Notebook 에서 실행
66+
- VS Code에 Jupyter Extension 설치
67+
- ![install_jupyter.jpg](img/install_jupyter.jpg)
68+
- Jupyter Kenel 선택
69+
- ![select_jupyter_kernel.jpg](img/select_jupyter_kernel.jpg)
70+
- Python (touch-neuronx) 선택
71+
- ![select_neuronx.jpg](img/select_neuronx.jpg)
72+
- 아래를 클릭하여 노트북을 샐행 하세요.
73+
- [01-offline_inference_neuron.ipynb](01-offline_inference_neuron.ipynb)
74+
75+
76+
77+
78+
<p>
79+
80+
---
81+
82+
- 여기까지 오셨으면 성공 하셨습니다. 축하 드립니다. ^^
83+
- Contributor: 문곤수 (Gonsoo Moon)
94.2 KB
Loading
27.8 KB
Loading
33.1 KB
Loading
134 KB
Loading
251 KB
Loading
40.2 KB
Loading
31.6 KB
Loading
26.5 KB
Loading

0 commit comments

Comments
 (0)