README.md 3.96 KB
Newer Older
xiabo's avatar
xiabo committed
1
2
3
4
# <div align="center"><strong>LMdeploy</strong></div>
## 简介
LMDeploy 由 [MMDeploy](https://github.com/open-mmlab/mmdeploy)[MMRazor](https://github.com/open-mmlab/mmrazor) 团队联合开发,是涵盖了 LLM 任务的全套轻量化、部署和服务解决方案。
这个强大的工具箱提供以下核心功能:
lvhan028's avatar
lvhan028 committed
5

xiabo's avatar
xiabo committed
6
- **高效推理引擎 TurboMind**:基于 [FasterTransformer](https://github.com/NVIDIA/FasterTransformer),我们实现了高效推理引擎 TurboMind,支持 InternLM、LLaMA、vicuna等模型在 NVIDIA GPU 上的推理。
RunningLeon's avatar
RunningLeon committed
7

xiabo's avatar
xiabo committed
8
- **交互推理方式**:通过缓存多轮对话过程中 attention 的 k/v,记住对话历史,从而避免重复处理历史会话。
lvhan028's avatar
lvhan028 committed
9

xiabo's avatar
xiabo committed
10
- **多 GPU 部署和量化**:我们提供了全面的模型部署和量化支持,已在不同规模上完成验证。
lvhan028's avatar
lvhan028 committed
11

xiabo's avatar
xiabo committed
12
- **persistent batch 推理**:进一步优化模型执行效率。
lvhan028's avatar
lvhan028 committed
13

xiabo's avatar
xiabo committed
14
15
persistent batch 推理:进一步优化模型执行效率。
LMdeploy官方github地址:[https://github.com/InternLM/lmdeploy](https://github.com/InternLM/lmdeploy)
16

xiabo's avatar
xiabo committed
17
## 安装
18

xiabo's avatar
xiabo committed
19
### 使用源码编译方式安装
20

xiabo's avatar
xiabo committed
21
22
#### 编译环境准备
提供2种环境准备方式:
23

xiabo's avatar
xiabo committed
24
1. 基于光源pytorch基础镜像环境:镜像下载地址:[https://sourcefind.cn/#/image/dcu/pytorch](https://sourcefind.cn/#/image/dcu/pytorch),根据pytorch、python、dtk及系统下载对应的镜像版本。
25
```shell
xiabo's avatar
xiabo committed
26
27
28
29
pip install -r requirements.txt
pip install transformers==4.33.2
pip install urllib3==1.24
yum install rapidjson
30
31
```

xiabo's avatar
xiabo committed
32
2. 基于现有python环境:安装pytorch,pytorch whl包下载目录:[https://cancon.hpccube.com:65024/4/main/pytorch/dtk23.04](https://cancon.hpccube.com:65024/4/main/pytorch/dtk23.04),根据python、dtk版本,下载对应pytorch的whl包。安装命令如下:
33
```shell
xiabo's avatar
xiabo committed
34
35
36
37
38
pip install torch* (下载的torch的whl包)
pip install -r requirements.txt
pip install transformers==4.33.2
pip install urllib3==1.24
yum install rapidjson
39
40
```

xiabo's avatar
xiabo committed
41
42
#### 源码编译安装
- 代码下载
43
```shell
xiabo's avatar
xiabo committed
44
git clone http://10.0.54.20/xiabo/lmdeploy.git # 根据编译需要切换分支 默认develop分支
45
```
xiabo's avatar
xiabo committed
46
- 提供2种源码编译方式(进入mmcv目录):
47
```
xiabo's avatar
xiabo committed
48
49
50
51
52
53
54
55
56
57
58
59
1. 源码编译安装
mkdir build && cd build
sh ../generate.sh
make -j 32 && make install
cd .. && python3 setup.py install

2. 编译成whl包安装
mkdir build && cd build
sh ../generate.sh
make -j 32 && make install
cd .. && python3 setup.py bdist_wheel
cd dist && pip3 install lmdeploy*
lvhan028's avatar
lvhan028 committed
60
```
xiabo's avatar
xiabo committed
61
## 模型服务
lvhan028's avatar
lvhan028 committed
62

xiabo's avatar
xiabo committed
63
64
65
### 部署 [LLaMA-2](https://github.com/facebookresearch/llama) 服务
请从[这里](https://huggingface.co/meta-llama) 下载 llama2 模型,参考如下命令部署服务:
以7B为例:
lvhan028's avatar
lvhan028 committed
66
```
xiabo's avatar
xiabo committed
67
68
69
70
71
72
73
74
1、模型转换
python3 -m lmdeploy.serve.turbomind.deploy llama2 path/to/chinese-llama2-7b-hf hf path/to/chinese-llama2-7b-hf/tokenizer.model ./workspace_llama
2、运行
- 在命令行界面运行:
python3 -m lmdeploy.turbomind.chat ./workspace_llama
- 在服务器界面运行:
python3 -m lmdeploy.serve.gradio.app ./workspace_llama 10.6.10.67
打开网页输入10.6.10.67:6006
AllentDan's avatar
AllentDan committed
75
```
xiabo's avatar
xiabo committed
76
77
78
### 部署 [internlm](https://huggingface.co/internlm/) 服务
请从[这里](https://huggingface.co/internlm) 下载 llama2 模型,参考如下命令部署服务:
以7B为例:
79
```
xiabo's avatar
xiabo committed
80
81
82
83
84
85
86
87
1、模型转换
python3 -m lmdeploy.serve.turbomind.deploy path/to/internlm-chat-7b internlm-chat-7b hf None ./workspace_intern
2、运行
- 在命令行界面运行:
python3 -m lmdeploy.turbomind.chat ./workspace_intern
- 在服务器界面运行:
python3 -m lmdeploy.serve.gradio.app ./workspace_intern 10.6.10.67
打开网页输入10.6.10.67:6006
88
```
xiabo's avatar
xiabo committed
89
90
91
### 详细可参考 [docs](./docs/zh_cn/serving.md) 
## 版本号查询
- python -c "import lmdeploy; lmdeploy.\_\_version__",版本号与官方版本同步,查询该软件的版本号,例如0.0.6;
92

xiabo's avatar
xiabo committed
93
94
## Known Issue
-
lvhan028's avatar
lvhan028 committed
95

xiabo's avatar
xiabo committed
96
97
## Note
+ 若使用pip install下载安装过慢,可添加pypi清华源:-i https://pypi.tuna.tsinghua.edu.cn/simple/
lvhan028's avatar
lvhan028 committed
98

xiabo's avatar
xiabo committed
99
100
101
## 其他参考
- [README_origin](README_origin.md)
- [README_zh-CN](README_zh-CN.md)