使用autodl服务器,在A40显卡上运行, Yi-34B-Chat-int4模型,并使用vllm优化加速,显存占用42G,速度18 words/s

1,演示视频

https://www.bilibili.com/video/BV1gu4y1c7KL/

使用autodl服务器,在A40显卡上运行, Yi-34B-Chat-int4模型,并使用vllm优化加速,显存占用42G,速度18 words/s

2,关于A40显卡,48GB 显存,安培架构

2020年,英伟达发布 A40 专业显卡,配备 48GB 显存。

采用了 GA102 GPU,拥有 10752 个 CUDA 核心。而 A40 是用于服务器的。A40 都配备了四个 DP 1.4 接口,都搭载了 48GB 的 GDDR6 显存,最大带宽为 696 GB/s。显卡的功耗为 300W,采用了全新的 8 pin 接口。

环境使用:

CPU :15 核心

内存:80 GB

GPU :NVIDIA A40, 1个

3,关于 Yi-34B 模型

11月24日,零一万物基正式发布并开源微调模型 Yi-34B-Chat,可申请免费商用。同时,零一万物还为开发者提供了 4bit/8bit 量化版模型,Yi-34B-Chat 4bit 量化版模型可以直接在消费级显卡(如RTX3090)上使用。

官方网站:
https://www.lingyiwanwu.com/

模型下载地址:
https://huggingface.co/01-ai/Yi-34B-Chat-8bits

github地址:
https://github.com/01-ai/Yi

下载后占空间:

68G Yi-34B-Chat-8bits

经测试:Yi-34B-Chat-4bits 没有启动成功,8bits启动成功了。

下模型文件花费时间比较多。

3,安装相关依赖,先安装最新的torch版本

bash 复制代码
apt update && apt install -y git-lfs net-tools
#
git clone https://www.modelscope.cn/01ai/Yi-34B-Chat-4bits.git


# 1,安装 torch 模块,防止依赖多次下载
pip3 install torch==2.1.0

# 2,安装 vllm 模块:
pip3 install vllm

# 最后安装 
pip3 install "fschat[model_worker,webui]" auto-gptq optimum

安装完成之后就可以使用fastchat启动了。

4,使用 vllm 进行加速,可以加速 Yi-34B-Chat-4bits 模型

https://docs.vllm.ai/en/latest/getting_started/installation.html

官方网站:https://github.com/vllm-project/vllm

说明模型不支持这个 vllm ,需要切换成 Yi-34B-Chat-4bits 可以启动

复制代码
ValueError: Unknown quantization method: gptq. Must be one of ['awq', 'squeezellm'].

增加参数:fastchat.serve.vllm_worker --quantization awq

就可以切换成 fastchat 的 vllm 模式:

bash 复制代码
# run_all_vllm_yi.sh

# 清除全部 fastchat 服务
ps -ef | grep fastchat.serve | awk '{print$2}' | xargs kill -9
sleep 3

rm -f *.log

# 首先启动 controller :
nohup python3 -m fastchat.serve.controller --host 0.0.0.0 --port 21001 > controller.log 2>&1 &

# 启动 openapi的 兼容服务 地址 8000
nohup python3 -m fastchat.serve.openai_api_server --controller-address http://127.0.0.1:21001 \
  --host 0.0.0.0 --port 8000 > api_server.log 2>&1 &

# 启动 web ui
nohup python -m fastchat.serve.gradio_web_server --controller-address http://127.0.0.1:21001 \
 --host 0.0.0.0 --port 8000 > web_server.log 2>&1 &


# 然后启动模型: 说明,必须是本地ip --load-8bit 本身已经是int4了
# nohup python3 -m fastchat.serve.model_worker  --model-names yi-34b \
#   --model-path ./Yi-34B-Chat-8bits --controller-address http://${IP_ADDR}:21001 \
#   --worker-address http://${IP_ADDR}:8080 --host 0.0.0.0 --port 8080 > model_worker.log 2>&1 &

## 
nohup python3 -m fastchat.serve.vllm_worker --quantization awq --model-names yi-34b \
  --model-path ./Yi-34B-Chat-4bits --controller-address http://127.0.0.1:21001 \
  --worker-address http://127.0.0.1:8080 --host 0.0.0.0 --port 8080 > model_worker.log 2>&1 &

然后在测试下 token 效果:

bash 复制代码
python3 -m fastchat.serve.test_throughput --controller-address http://127.0.0.1:21001 --model-name yi-34b --n-thread 1

throughput: 18.678158839922936 words/s.

5,总结

测试效果还可以,但是偶尔出现英文,需要说明强制转换成中文:

bash 复制代码
curl http://localhost:6006/v1/chat/completions   -H "Content-Type: application/json"   -d '{
     "model": "chatglm3-6b",
     "messages": [{"role": "user", "content": "北京景点,使用中文回答"}],
     "temperature": 0.7
   }'
相关推荐
Percent_bigdata几秒前
百分点科技发布中国首个AI原生GEO产品Generforce,助力品牌决胜AI搜索新时代
人工智能·科技·ai-native
Gloria_niki2 分钟前
YOLOv4 学习总结
人工智能·计算机视觉·目标跟踪
FriendshipT8 分钟前
目标检测:使用自己的数据集微调DEIMv2进行物体检测
人工智能·pytorch·python·目标检测·计算机视觉
海森大数据12 分钟前
三步破局:一致性轨迹强化学习开启扩散语言模型“又快又好”推理新时代
人工智能·语言模型·自然语言处理
Tencent_TCB14 分钟前
云开发CloudBase AI+实战:快速搭建AI小程序全流程指南
人工智能·ai·小程序·ai编程·云开发
Sunhen_Qiletian16 分钟前
基于OpenCV与Python的身份证号码识别案例详解
人工智能·opencv·计算机视觉
AustinCyy22 分钟前
【论文笔记】Introduction to Explainable AI
论文阅读·人工智能
岁月宁静40 分钟前
在富文本编辑器中封装实用的 AI 写作助手功能
前端·vue.js·人工智能
末世灯光41 分钟前
时间序列入门第一问:它和普通数据有什么不一样?(附 3 类典型案例)
人工智能·python·机器学习·时序数据
Yann-企业信息化1 小时前
AI 开发工具对比:Dify 与 Coze Studio(开源版)差异对比
人工智能·开源