Commit ea7b70e4 authored by xuxzh1's avatar xuxzh1 🎱
Browse files

update readme again!

parent 6e18af9a
......@@ -18,17 +18,21 @@ LLama是一个基础语言模型的集合,参数范围从7B到65B。在数万亿
## 环境配置
提供光源拉取推理的docker镜像:
```
docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:lmdeploy0.0.13_dtk23.04_torch1.13_py38
```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 llama --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=llama_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 /opt/hyhal:/opt/hyhal:ro -v <Host Path>:<Container Path> <Image ID> /bin/bash
#起容器之后安装软件依赖
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
```
镜像版本依赖:
* DTK驱动:dtk23.04
* Pytorch: 1.13
* python: python3.8
* DTK驱动:dtk24.04.1
* Pytorch: 2.1.0
* python: 3.10
## 数据集
......@@ -36,11 +40,11 @@ docker run -it --name llama --shm-size=1024G --device=/dev/kfd --device=/dev/dr
## 推理
### 源码编译安装
```
# 若使用光源的镜像,可以跳过源码编译安装,镜像里面安装好了lmdeploy
```bash
# 若使用光源的镜像,可以跳过源码编译安装,镜像里面安装好了lmdeploy
git clone http://developer.hpccube.com/codes/modelzoo/llama_lmdeploy.git
cd llama_lmdeploy
git submodule init && git submodule update
git submodule init && git submodule updat
cd lmdeploy
mkdir build && cd build
sh ../generate.sh
......@@ -74,11 +78,10 @@ cd .. && python3 setup.py install
>
> 1.LLama-13B:需要在tokenizer_config.json中添加“unk_token”对应的值为"\<unk\>“
>
> 2.LLama-65B:config文件中“architectures”对应的[LlAmaForCausalLM]改成[LlamaForCausalLM]
> 2.LLama-65B:config.json文件中“architectures”对应的[LlAmaForCausalLM]改成[LlamaForCausalLM]
### 运行 LLama-7b
```
# 模型转换
```bash
# <model_name> 模型的名字 ('llama', 'internlm', 'vicuna', 'internlm-chat-7b', 'internlm-chat', 'internlm-chat-7b-8k', 'internlm-chat-20b', 'internlm-20b', 'baichuan-7b', 'baichuan2-7b', 'llama2', 'qwen-7b', 'qwen-14b')
# <model_path> 模型路径
# <model_format> 模型的格式 ('llama', 'hf', 'qwen')
......@@ -86,8 +89,6 @@ cd .. && python3 setup.py install
# <model_format> 保存输出的目标路径(默认./workspace)
# <tp> 用于张量并行的GPU数量应该是2^n
lmdeploy convert --model_name llama --model_path /path/to/model --model_format hf --tokenizer_path None --dst_path ./workspace_llama7b --tp 1
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_llama7b --tp 1 # 输入问题后执行2次回车进行推理
......@@ -101,104 +102,86 @@ lmdeploy chat turbomind --model_path ./workspace_llama7b --tp 1 # 输入问
# <tp> 用于张量并行的GPU数量应该是2^n (和模型转换的时候保持一致)
# <restful_api> modelpath_or_server的标志(默认是False)
lmdeploy serve gradio --model_path_or_server ./workspace_llama7b --server_name {ip} --server_port {pord} --batch_size 32 --tp 1 --restful_api False
lmdeploy serve gradio --model_path_or_server ./workspace_llama7b --server_name {ip} --server_port {port} --batch_size 32 --tp 1 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
在网页上输入{ip}:{port}即可进行对话
```
### 运行 LLama-13b
```
# 模型转换
lmdeploy convert --model_name llama --model_path /path/to/model --model_format hf --tokenizer_path None --dst_path ./workspace_llama13b --tp 1
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_llama13b --tp 1
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_llama13b --server_name {ip} --server_port {pord} --batch_size 32 --tp 1 --restful_api False
lmdeploy serve gradio --model_path_or_server ./workspace_llama13b --server_name {ip} --server_port {port} --batch_size 32 --tp 1 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
在网页上输入{ip}:{port}即可进行对话
```
### 运行 LLama-33b
```
# 模型转换
lmdeploy convert --model_name llama --model_path /path/to/model --model_format hf --tokenizer_path None --dst_path ./workspace_llama33b --tp 4
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_llama33b --tp 4
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_llama33b --server_name {ip} --server_port {pord} --batch_size 32 --tp 4 --restful_api False
lmdeploy serve gradio --model_path_or_server ./workspace_llama33b --server_name {ip} --server_port {port} --batch_size 32 --tp 4 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
在网页上输入{ip}:{port}即可进行对话
```
### 运行 LLama-65b
```
# 模型转换
lmdeploy convert --model_name llama --model_path /path/to/model --model_format hf --tokenizer_path None --dst_path ./workspace_llama65b --tp 8
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_llama65b --tp 8
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_llama65b --server_name {ip} --server_port {pord} --batch_size 32 --tp 8 --restful_api False
lmdeploy serve gradio --model_path_or_server ./workspace_llama65b --server_name {ip} --server_port {port} --batch_size 32 --tp 8 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
在网页上输入{ip}:{port}即可进行对话
```
### 运行 LLama2-7b
```
# 模型转换
lmdeploy convert --model_name llama2 --model_path /path/to/model --model_format hf --tokenizer_path None --dst_path ./workspace_llama2-7b --tp 1
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_llama2-7b --tp 1
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_llama2-7b --server_name {ip} --server_port {pord} --batch_size 32 --tp 1 --restful_api False
lmdeploy serve gradio --model_path_or_server ./workspace_llama2-7b --server_name {ip} --server_port {port} --batch_size 32 --tp 1 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
在网页上输入{ip}:{port}即可进行对话
```
### 运行 LLama2-13b
```
# 模型转换
lmdeploy convert --model_name llama2 --model_path /path/to/model --model_format hf --tokenizer_path None --dst_path ./workspace_llama2-13b --tp 1
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_llama2-13b --tp 1
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_llama2-13b --server_name {ip} --server_port {pord} --batch_size 32 --tp 1 --restful_api False
lmdeploy serve gradio --model_path_or_server ./workspace_llama2-13b --server_name {ip} --server_port {port} --batch_size 32 --tp 1 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
在网页上输入{ip}:{port}即可进行对话
```
### 运行 LLama2-70b
```
# 模型转换
lmdeploy convert --model_name llama2 --model_path /path/to/model --model_format hf --tokenizer_path None --dst_path ./workspace_llama2-70b --tp 8
```bash
# bash界面运行
lmdeploy chat turbomind --model_path ./workspace_llama2-70b --tp 8
# 服务器网页端运行
在bash端运行:
lmdeploy serve gradio --model_path_or_server ./workspace_llama2-70b --server_name {ip} --server_port {pord} --batch_size 32 --tp 8 --restful_api False
lmdeploy serve gradio --model_path_or_server ./workspace_llama2-70b --server_name {ip} --server_port {port} --batch_size 32 --tp 8 --restful_api False
在网页上输入{ip}:{pord}即可进行对话
在网页上输入{ip}:{port}即可进行对话
```
## result
......@@ -246,4 +229,3 @@ https://developer.hpccube.com/codes/modelzoo/llama_lmdeploy
## 参考资料
https://github.com/InternLM/LMDeploy
##
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