欢迎光临散文网 会员登陆 & 注册

ChatGLM2-6B本地部署笔记

2023-08-21 11:54 作者:abysshadow  | 我要投稿

1、官网和源代码

官网:

https://chatglm.cn/

github官网:

https://github.com/THUDM/ChatGLM2-6B

huggingface官网:

https://huggingface.co/THUDM/chatglm2-6b


2、教程开始:

======硬件最低需求=====================================================

1.不同量化等级的模型,对硬件要求不同,windows/linux均可。

2.N卡配置比较简单,推荐使用N卡。(A卡目前可使用ROCm在linux中部署)

3.显存要求:

+++++++++++++++++++++++++

模型                      量化         显存要求

ChatGLM2            FP16         13G

ChatGLM2            INT4            6G

ChatGLM2-32k     FP16         20G 

ChatGLM2-32k     INT4          11G

++++++++++++++++++++++++++


======准备工作=========================================================

1.安装vscode,用于编辑代码:https://code.visualstudio.com/

>>>打开插件库,安装中文语言包

>>>安装markdown all in one,用于看md文件


2.安装cuda v11.8:https://developer.nvidia.com/cuda-11-8-0-download-archive


3.安装python,注意勾选添加至系统变量PATH:https://www.python.org/downloads/


4.安装pytorch: pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

>>>打开powershell或cmd

>>>执行nvidia-smi

>>>执行

python

import torch

torch.cuda.is_available()

>>>查看pytorch和cuda是否正常运行


5.安装git:https://git-scm.com/downloads


6.安装git-lfs:https://git-lfs.com/

>>>打开git bash

>>>执行git lfs install


======环境部署=========================================================

1.创建空文件夹,打开git bash


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


3.进入ChatGLM2-6B文件夹,安装依赖

>>>cd ChatGLM2-6B

>>>pip install -r requirements.txt -i https://mirror.sjtu.edu.cn/pypi/web/simple


4.下载相应模型文件

>>>打开git bash

>>>执行git lfs install 确认lfs正常

>>>git clone https://huggingface.co/THUDM/chatglm2-6b


5.修改 web_demo.py 、web_demo2.py文件

>>>修改模型地址为本地目录

>>>修改代码使其可以局域网访问


6.打开powershell或cmd,输入:

python web_demo.py 

或 streamlit run web_demo2.py


具体流程可看我发布的教程视频:https://www.bilibili.com/video/BV16p4y1g7UE


ChatGLM2-6B本地部署笔记的评论 (共 条)

分享到微博请遵守国家法律