Commit 6bdce1b6 authored by xuxz's avatar xuxz
Browse files

update readme.md

parent f7acca8e
[submodule "lmdeploy"]
path = lmdeploy
url = http://developer.hpccube.com/codes/aicomponent/lmdeploy.git
branch = dtk23.10-v0.1.0
\ No newline at end of file
url = http://10.6.10.68/dcutoolkit/deeplearing/lmdeploy.git
branch = dtk24.04-v0.2.6
\ No newline at end of file
......@@ -22,27 +22,27 @@ Qwen的构建采用了类似LLaMA的架构。与标准transformer的主要差异
## 环境配置
提供[光源](https://www.sourcefind.cn/#/service-details)拉取推理的docker镜像:
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:lmdeploy1.0-dtk23.10-torch1.13-py38-latest
```bash
docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-ubuntu20.04-dtk24.04.1-py3.10
# <Image ID>用上面拉取docker镜像的ID替换
# <Host Path>主机端路径
# <Container Path>容器映射路径
docker run -it --name qwen --shm-size=1024G --device=/dev/kfd --device=/dev/dri/ --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --ulimit memlock=-1:-1 --ipc=host --network host --group-add video -v <Host Path>:<Container Path> <Image ID> /bin/bash
docker run -it --network=host --name=qwen_lmdeploy --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=1024G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v <Host Path>:<Container Path> <Image ID> /bin/bash
```
镜像版本依赖:
* DTK驱动:dtk23.10
* Pytorch: 1.13
* python: python3.8
* DTK驱动:24.04.1
* Pytorch: 2.1.0
* python: python3.10
## 数据集
## 推理
### 源码编译安装
```
```bash
# 若使用光源的镜像,可以不用源码编译,镜像里面安装好了lmdeploy,可跳过源码编译安装
# 获取源码,编译并安装
git clone http://developer.hpccube.com/codes/modelzoo/Qwen_lmdeploy.git
git clone -b v1.4 http://developer.hpccube.com/codes/modelzoo/Qwen_lmdeploy.git
cd qwen_lmdeploy
git submodule init && git submodule update
cd lmdeploy
......@@ -51,10 +51,10 @@ sh ../generate.sh
make -j 32
make install
cd .. && python3 setup.py install
```
### 模型下载
SCNet模型下载
[Qwen-7B-chat](http://113.200.138.88:18080/aimodels/Qwen-7B-Chat)
......@@ -63,97 +63,76 @@ SCNet模型下载
[Qwen-72B-Chat](http://113.200.138.88:18080/aimodels/Qwen-72B-Chat)
### 运行前
### 运行 Qwen-7B-chat
```bash
source /opt/dtk/cuda/env.sh
```
# 模型转换
# <model_name> 模型的名字 ('llama', 'internlm', 'vicuna', 'wizardlM', 'internlm-chat-7b', 'internlm-chat', 'internlm-chat-7b-8k', 'internlm-chat-20b', 'internlm-20b', 'baichuan-7b', 'baichuan2-7b', 'puyu', 'llama2', 'qwen-7b', 'qwen-14b', 'qwen-72b', 'codellama', 'solar', 'ultralm', 'ultracm', 'yi')
# <model_path> 模型路径
# <model_format> 模型的格式 ('llama', 'hf', None。可以不写默认None,代码会根据模型选择格式)
# <tokenizer_path> tokenizer模型的路径(默认None,会去model_path里面找对应的其他模型:'tokenizer.model',千问:'qwen.tiktoken')
# <model_format> 保存输出的目标路径(默认./workspace)
# <tp> 用于张量并行的GPU数量应该是2^n
lmdeploy convert --model_name qwen-7b --model_path /path/to/model --dst_path ./workspace_qwe7b --tp 1
### 运行 Qwen-7B-chat
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_qwe7b --tp 1 # 输入问题后执行2次回车进行推理
lmdeploy chat turbomind path_to_Qwen-7B-chat # 输入问题后执行2次回车进行推理
# 服务器网页端运行
在bash端运行:
# <model_path_or_server> 部署模型的路径或tritonserver URL或restful api URL。前者用于与gradio直接运行服务。后者用于默认情况下使用tritonserver运行。如果输入URL是restful api。请启用另一个标志“restful_api”。
# <server_name> gradio服务器的ip地址
# <server_port> gradio服务器的ip的端口
# <batch_size> 于直接运行Turbomind的batch大小 (默认32)
# <server-name> gradio服务器的ip地址
# <server-port> gradio服务器的ip的端口
# <tp> 用于张量并行的GPU数量应该是2^n (和模型转换的时候保持一致)
# <restful_api> modelpath_or_server的标志(默认是False)
lmdeploy serve gradio --model_path_or_server ./workspace_qwe7b --server_name {ip} --server_port {pord} --batch_size 32 --tp 1 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
# <backend> 后端支持turbomind/pytorch
lmdeploy serve gradio path_to_Qwen-7B-chat --server-name {ip} --server-port {port} --backend turbomind --tp 1
在网页上输入{ip}:{port}即可进行对话
```
### 运行 Qwen-14B-chat
```
# 模型转换
lmdeploy convert --model_name qwen-14b --model_path /path/to/model --dst_path ./workspace_qwen14b --tp 2
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_qwen14b --tp 2
lmdeploy chat turbomind path_to_Qwen-14B-chat --tp 2
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_qwen14b --server_name {ip} --server_port {pord} --batch_size 32 --tp 2 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
# 在bash端运行:
lmdeploy serve gradio path_to_Qwen-14B-chat --server-name {ip} --server-port {port} --backend turbomind --tp 2
在网页上输入{ip}:{port}即可进行对话
```
### 运行 Qwen-72B-chat
```
# 模型转换
lmdeploy convert --model_name qwen-72b --model_path /path/to/model --dst_path ./workspace_qwen72b --tp 8
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_qwen72b --tp 8
lmdeploy chat turbomind path_to_Qwen-72B-chat --tp 8
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_qwen72b --server_name {ip} --server_port {pord} --batch_size 32 --tp 8 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
#在bash端运行:
lmdeploy serve gradio path_to_Qwen-72B-chat --server-name {ip} --server-port {port} --backend turbomind --tp 8
在网页上输入{ip}:{port}即可进行对话
```
### api-server方式运行实例
启动server:
```shell
# --instance_num: turbomind推理实例的个数。可理解为支持的最大并发数
```bash
# --tp: 在 tensor parallel时,使用的GPU数量
lmdeploy serve api_server ./workspace_qwen72b --server_name ${server_ip} --server_port ${server_port} --tp 8
lmdeploy serve api_server path_to_Qwen-72B-chat --server-name {ip} --server-port {port} --tp 8
```
浏览器上打开 `http://{server_ip}:{server_port}`,即可访问 swagger,查阅 RESTful API 的详细信息。
浏览器上打开 `http://{server-name}:{server-port}`,即可访问 swagger,查阅 RESTful API 的详细信息。
可以用命令行,在控制台与 server 通信(在新启的命令行页面下执行):
```shell
# restful_api_url 就是 api_server 产生的,即上述启动server的http://{server_ip}:{server_port}
```bash
# restful_api_url 就是 api_server 产生的,即上述启动server的http://{server-name}:{server-port}
lmdeploy serve api_client restful_api_url
```
或者,启动 gradio,在 webui 的聊天对话框中,与服务交流:
```shell
```bash
# restful_api_url 就是 api_server 产生的,比如 http://localhost:23333
# server_ip 和 server_port 是用来提供 gradio ui 访问服务的
# 例子: lmdeploy serve gradio http://localhost:23333 --server_name localhost --server_port 6006 --restful_api True
lmdeploy serve gradio restful_api_url --server_name ${server_ip} --server_port ${server_port} --restful_api True
# server-name 和 server-port 是用来提供 gradio ui 访问服务的
# 例子: lmdeploy serve gradio http://localhost:23333 --server-name localhost --server-port 6006
lmdeploy serve gradio restful_api_url --server-name {ip} --server-port {port}
```
**需要保证'{server_ip}:{server_port}'在外部浏览器中的可访问性**
**需要保证'{server-name}:{server-port}'在外部浏览器中的可访问性**
关于 RESTful API的详细介绍,请参考[这份](https://developer.hpccube.com/codes/aicomponent/lmdeploy/-/blob/dtk23.10-v0.1.0/docs/zh_cn/restful_api.md)文档。
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment