当前位置:   article > 正文

ChatGLM部署+pytorch安装_chatglm.cpp 源码部署

chatglm.cpp 源码部署

前言

前几天跟着教程在自己电脑上部署了ChatGLM,总结一下整个过程

一、源码及模型下载

git lfs install
git clone https://huggingface.co/THUDM/chatglm-6b
  • 1
  • 2

二、环境搭建

1、新建conda环境

conda create -n GML python= 3.10
  • 1

2、安装requirements里面的包

pip install -r requirements.txt
  • 1

3、pytorch(GPU)安装

见另一篇博文

4、可能出现意外的包

transformers 和 protobuf 库下载

pip install protobuf==3.20.0 transformers==4.27.1 icetk cpm_kernels
  • 1

因为要使用 Web 显示 所以也需要加载 gradio库

pip install gradio
  • 1

chardet

pip install chardet
  • 1

总之缺什么包就自己补什么

5、源码修改

新建一个文件夹,命名为model
hugging face下载的内容放到该目录中

然后,web_demo.py中
修改为

tokenizer = AutoTokenizer.from_pretrained("model", trust_remote_code=True)
model = AutoModel.from_pretrained("model", trust_remote_code=True).half().quantize(8).cuda()
  • 1
  • 2

显存小的8改为4
运行该文件

在这里插入图片描述
成功

结尾

我的显存是16G,其实INT4 状态下只需要6G的显存,部署成本不高。效果尚可,在本地上跑成这样知足了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/273844
推荐阅读
相关标签
  

闽ICP备14008679号