Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
Lmdeploy
Commits
b270d465
Commit
b270d465
authored
Jun 03, 2024
by
gaoqiong
Browse files
根据v2.6.0的一些参数变更修改readme
parent
386c0a76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
44 deletions
+49
-44
README.md
README.md
+49
-44
No files found.
README.md
View file @
b270d465
...
@@ -40,21 +40,24 @@ LMdeploy官方github地址:[https://github.com/InternLM/lmdeploy](https://github
...
@@ -40,21 +40,24 @@ LMdeploy官方github地址:[https://github.com/InternLM/lmdeploy](https://github
### 使用源码编译方式安装
### 使用源码编译方式安装
#### 编译环境准备
#### 编译环境准备
下载光源的镜像,起dcoker
(镜像已安装lmdeploy)
下载光源的镜像,起dcoker(镜像已安装lmdeploy)
```
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/
custom:lmdeploy1.0-dtk23.10-torch1.13-py38-latest
docker pull image.sourcefind.cn:5000/dcu/admin/base/
pytorch:2.1.0-centos7.6-dtk24.04-py310
# <Image ID>用上面拉取docker镜像的ID替换
# <Image ID>用上面拉取docker镜像的ID替换
# <Host Path>主机端路径
# <Host Path>主机端路径
# <Container Path>容器映射路径
# <Container Path>容器映射路径
docker run -it --name baichuan --shm-size=1024G -v /opt/hyhal:/opt/hyhal --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 --name baichuan --shm-size=1024G -v /opt/hyhal:/opt/hyhal:ro --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
```
注:
1、docker启动 -v /opt/hyhal:/opt/hyhal 这个变量不能少
#安装gpufusion
#网页侧下载安装包:https://forum.hpccube.com/thread/483
wget https://forum.hpccube.com/download?url=https://forum.hpccube.com/api/v3/attachment.download?sign=3b3a3d6f1a0d840c57857e63f1ffd231&attachmentsId=511&threadId=483&threadId=483
unzip gpufusion.zip -d /opt/dtk
#激活环境
source /opt/dtk/env.sh
source /opt/dtk/cuda/env.sh
2、要是非光源提供镜像,配置环境:(若安装过慢,可以添加源:pip3 install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple/)
#安装其他环境依赖(若安装过慢,可以添加源:pip3 install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple/)
```
#centos7.6环境
#centos7.6环境
pip3 install -r requirements.txt
pip3 install -r requirements.txt
pip3 install urllib3==1.24
pip3 install urllib3==1.24
...
@@ -65,12 +68,24 @@ export NCCL_LIB_DIR=/opt/dtk/cuda/lib64
...
@@ -65,12 +68,24 @@ export NCCL_LIB_DIR=/opt/dtk/cuda/lib64
pip3 install -r requirements.txt
pip3 install -r requirements.txt
pip3 install urllib3==1.24
pip3 install urllib3==1.24
#apt-get 换源,添加清华源
#apt-get 换源,添加清华源
#添加清华源后更新
#vim /etc/apt/sources.list
#添加清华源如下:
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
#deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
#换源完成后进行更新
sudo apt-get update
sudo apt-get update
apt-get install rapidjson-dev
apt-get install rapidjson-dev
# 执行nccl环境变量
# 执行nccl环境变量
export NCCL_LAUNCH_MODE=GROUP
export NCCL_LAUNCH_MODE=GROUP
```
```
注:
1、docker启动 -v /opt/hyhal:/opt/hyhal 这个变量不能少
2、gpufusion wget指令提供的网址可能会有变化,可以进入提供网页下载对应压缩工具包
#### 源码编译安装
#### 源码编译安装
-
代码下载
-
代码下载
...
@@ -81,6 +96,7 @@ export NCCL_LAUNCH_MODE=GROUP
...
@@ -81,6 +96,7 @@ export NCCL_LAUNCH_MODE=GROUP
mkdir build && cd build
mkdir build && cd build
sh ../generate.sh
sh ../generate.sh
make -j 32 && make install
make -j 32 && make install
#假如环境中存在老版本的lmdeploy,需要使用pip uninstall先将老版本卸载
cd .. && python3 setup.py install
cd .. && python3 setup.py install
2. 编译成whl包安装
2. 编译成whl包安装
...
@@ -96,70 +112,59 @@ cd dist && pip3 install lmdeploy*
...
@@ -96,70 +112,59 @@ cd dist && pip3 install lmdeploy*
## 模型服务
## 模型服务
### 模型转换
### 模型转换
```
```
bash
# <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_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_path> 模型路径
# <model_format> 模型的格式 ('llama', 'hf', None。可以不写默认None,代码会根据模型选择格式)
# <model_format> 模型的格式 ('llama', 'hf', None。可以不写默认None,代码会根据模型选择格式,一般选择不写)
# <tokenizer_path> tokenizer模型的路径(默认None,会去model_path里面找对应的其他模型:'tokenizer.model',千问:'qwen.tiktoken')
# <model_format> 保存输出的目标路径(默认./workspace)
# <model_format> 保存输出的目标路径(默认./workspace)
# <tp> 用于张量并行的GPU数量应该是2^n
# <tp> 用于张量并行的GPU数量应该是2^n
lmdeploy convert ${model_name} ${model_path} --model_format ${model_format}
--tokenizer_path ${tokenizer_path}
--dst_path ${dst_path} --tp ${tp}
lmdeploy convert
${
model_name
}
${
model_path
}
--model_format
${
model_format
}
--dst_path
${
dst_path
}
--tp
${
tp
}
```
```
### 运行
### 运行
#### bash界面运行
#### bash界面运行
```
```
bash
# <model_path>:转换后的模型路径
# <model_path>:转换后的模型路径
lmdeploy chat turbomind --model_path ${model_path} --tp ${tp} # tp要和转模型的tp保持一直 # 输入问题后执行2次回车进行推理
#此处的model_path处可以采用转换后的模型,也可以直接使用未转换的hf模型,但是需要注意假如使用的是转换后的模型,tp要和转模型的tp保持一致
lmdeploy chat turbomind
${
model_path
}
--tp
${
tp
}
# 输入问题后执行2次回车进行推理
```
```
#### web页面方式交互:
#### web页面方式交互:
```
```
bash
在bash端运行:
#
在bash端运行:
# <
model_path_or_server> 部署模型的路径或tritonserver URL或restful api URL。前者用于与gradio直接运行服务。后者用于默认情况下使用tritonserver运行。如果输入URL是restful api。请启用另一个标志“restful_api”。
# <
server-name> gradio服务器的ip地址
# <server
_name
> gradio服务器的ip
地址
# <server
-port
> gradio服务器的ip
的端口
# <
server_port> gradio服务器的ip的端口
# <
backend> 用于支持推理的后端,可以是pytorch,也可以选择turbomind
# <
batch_size> 于直接运行Turbomind的batch大小 (默认32)
# <
model-name> 需要推理的模型名,比如:llama-7b, llama-13b, vicuna-7,llama2等
# <tp> 用于张量并行的GPU数量应该是2^n (和模型转换的时候保持一致)
# <tp> 用于张量并行的GPU数量应该是2^n (和模型转换的时候保持一致)
# <restful_api> modelpath_or_server的标志(默认是False)
# <model-format> 推理模型格式,有hf,llama,awq选项
# 更多参数使用lmdeploy serve gradio 可以查询
lmdeploy serve gradio
--model_path_or_server
${model_path
_or_server
} --server
_
name ${ip} --server
_
port ${pord} --ba
tch_size 32
--tp ${tp}
lmdeploy serve gradio
${
model_path
}
--server
-
name
${
ip
}
--server
-
port
${
pord
}
--ba
ckend
turbomind
--model-name
llama2
--model-format
hf
--tp
${
tp
}
```
```
在网页上输入{ip}:{pord}即可进行对话,
**需要保证'{ip}:{pord}'在外部浏览器中的可访问性**
在网页上输入{ip}:{pord}即可进行对话,
**需要保证'{ip}:{pord}'在外部浏览器中的可访问性**
#### 使用api-server
#### 使用api-server
启动server:
启动server:
```
```
bash
在bash端运行:
#在bash端运行:
# --instance_num: turbomind推理实例的个数。模型支持的并发数 默认32
lmdeploy serve api_server
${
model_path
}
--server-name
${
ip
}
--server-port
${
pord
}
--backend
turbomind
--model-name
llama2
--model-format
hf
--tp
${
tp
}
lmdeploy serve api_server ${model_path} --server_name ${server_ip} --server_port ${server_port} --instance_num ${instance_num} --tp ${tp}
```
```
用户将下面命令输出的 http url 复制到浏览器打开,详细查看所有的 API 及其使用方法。 请一定查看http://{server_ip}:{server_port}!!! 请一定查看http://{server_ip}:{server_port}!!! 请一定查看http://{server_ip}:{server_port}!!! 重要的事情说三遍。
用户将下面命令输出的 http url 复制到浏览器打开,详细查看所有的 API 及其使用方法。 请一定查看http://{server_ip}:{server_port}!!! 请一定查看http://{server_ip}:{server_port}!!! 请一定查看http://{server_ip}:{server_port}!!! 重要的事情说三遍。
CLI client
api-server的详细使用可以参照
[
这里
](
docs/zh_cn/serving
)
的文档
restful api 服务可以通过客户端测试,例如
```
# restful_api_url is what printed in api_server.py, e.g. http://localhost:23333
lmdeploy serve api_client api_server_url
```
webui
也可以直接用 webui 测试使用 restful-api。
```
# api_server_url 就是 api_server 产生的,比如 http://localhost:23333
# server_name 和 server_port 是用来提供 gradio ui 访问服务的
# 例子: lmdeploy serve gradio http://localhost:23333 --server_name localhost --server_port 6006
lmdeploy serve gradio api_server_url --server_name ${gradio_ui_ip} --server_port ${gradio_ui_port}
```
api-server的详细使用可以参照
[
这里
](
docs/zh_cn/restful_api.md
)
的文档
codellama模型的部署可以参照
[
codellama
](
docs/zh_cn/supported_models/codellama.md
)
codellama模型的部署可以参照
[
codellama
](
docs/zh_cn/supported_models/codellama.md
)
### AWQ 量化推理
### AWQ 量化推理
本版本支持量化推理功能,步骤如下:
本版本支持量化推理功能,步骤如下:
```
bash
```
bash
#group_size:按照模型量化时候的分组参数,一般为128
#<tp> 用于张量并行的GPU数量应该是2^n
#<dst-path> 保存模型的目标文件夹
#step1:模型转换:
#step1:模型转换:
lmdeploy convert
${
model_name
}
${
model_path
}
--model_format
awq
--group-size
${
group_size
}
--tp
${
tp
}
lmdeploy convert
${
model_name
}
${
model_path
}
--model_format
awq
--group-size
${
group_size
}
--tp
${
tp
}
--dst-path
${
dst_path
}
#step1:模型运行
#step1:模型运行
lmdeploy chat turbomind
./workspace
--tp
${
tp
}
lmdeploy chat turbomind
${
dst_path
}
--tp
${
tp
}
```
```
注意事项:
注意事项:
1.
该版本暂时仅支持tp=1 单卡量化推理,仅支持卡型KM-AI,暂不支持K100/Z100/Z100L;
1.
该版本暂时仅支持tp=1 单卡量化推理,仅支持卡型KM-AI,暂不支持K100/Z100/Z100L;
...
@@ -171,7 +176,7 @@ lmdeploy chat turbomind ./workspace --tp ${tp}
...
@@ -171,7 +176,7 @@ lmdeploy chat turbomind ./workspace --tp ${tp}
### 详细可参考 [docs](./docs/zh_cn/serving.md)
### 详细可参考 [docs](./docs/zh_cn/serving.md)
## 版本号查询
## 版本号查询
-
python -c "import lmdeploy; lmdeploy.
\_\_
version__",版本号与官方版本同步,查询该软件的版本号,例如0.
1.0
;
-
python -c "import lmdeploy;
print(
lmdeploy.
\_\_
version__
)
",版本号与官方版本同步,查询该软件的版本号,例如0.
2.6
;
## Known Issue
## Known Issue
-
无
-
无
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment