美文网首页
部署通一千问-Qwen-7B-Chat

部署通一千问-Qwen-7B-Chat

作者: 一个人一匹马 | 来源:发表于2024-01-31 18:12 被阅读0次

1、模型要求

  • python 3.8及以上版本
  • pytorch 1.12及以上版本,推荐2.0及以上版本
  • 建议使用CUDA 11.4及以上(GPU用户、flash-attention用户等需考虑此选项)

2、conda创建环境

  • 创建python3.10的虚拟环境
conda create -n qw python=3.10
  • 激活虚拟环境
conda activate qw

3、源码拉取及依赖安装

  • 拉取代码及安装依赖
git clone https://github.com/QwenLM/Qwen
pip install -r requirements.txt
  • 如果你的显卡支持fp16或bf16精度,我们还推荐安装flash-attention来提高你的运行效率以及降低显存占用。(flash-attention只是可选项,不安装也可正常运行该项目)
git clone -b v1.0.8 https://github.com/Dao-AILab/flash-attention
cd flash-attention && pip install .
# 下方安装可选,安装可能比较缓慢。
# pip install csrc/layer_norm
# pip install csrc/rotary

4、安装本地模型

  • 拉取模型
cd Qwen
git clone https://www.modelscope.cn/qwen/Qwen-7B-Chat.git

5、修改openai_api.py的模型路径

  • 将Qwen/Qwen-7B-Chat替换为自己的路径/data/Qwen/Qwen-7B-Chat
  • 将默认的服务地址 127.0.0.1修改为 0.0.0.0 代表绑定所有地址

6、安装openai_api.py需要的依赖

  • 安装依赖
pip install fastapi uvicorn openai "pydantic>=2.3.0" sse_starlette

7、启动服务

  • 启动接口服务
python openai_api.py

8、集成到one api平台

  • 新增渠道 把qwen相关配置写上

9、集成到fastGPT平台

  • 修改fastGPT的config.json,添加qwen的配置项

相关文章

网友评论

      本文标题:部署通一千问-Qwen-7B-Chat

      本文链接:https://www.haomeiwen.com/subject/vsiwndtx.html