返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
LLM

ChatGLM-6B本地部署

下载项目代码 git clone https://github.com/THUDM/ChatGLM-6B.git 创建虚拟环境,建议使用 conda 管理 conda create -n chatglm python==3.8 安装依赖 conda activate chatglm pip install -r requirements.txt conda install cudatoolkit=

曦远 (DealiAxy)约 4 分钟

下载项目代码

git clone https://github.com/THUDM/ChatGLM-6B.git

创建虚拟环境,建议使用 conda 管理

conda create -n chatglm python==3.8

安装依赖

conda activate chatglm
pip install -r requirements.txt
conda install cudatoolkit=11.7 -c nvidia

PS:没有安装 cudatoolkit 的话,会报 RuntimeError: Library cudart is not initialized 错误

但 issues 里也有人说可以通过使用CPU输出量化模型后直接调用的方式解决,暂未尝试。

issues 地址: https://github.com/THUDM/ChatGLM-6B/issues/115

硬件需求

量化等级最低 GPU 显存(推理)最低 GPU 显存(高效参数微调)
FP16(无量化)13 GB14 GB
INT88 GB9 GB
INT46 GB7 GB

修改一下启动参数

model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda()

使用量化模型

# 按需修改,目前只支持 4/8 bit 量化
model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).quantize(4).half().cuda()

下载模型和启动 Gradio 界面

cd ChatGLM-6B
python web_demo.py

运行效果

image-20230414161717147

_EOF_

ChatGLM-6B本地部署

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…