零基础部署chatglm

2 篇文章 0 订阅

目录

ubuntu部署

1. 下载安装anaconda3

2. 创建并虚拟环境

3. 下载安装chatglm

4. 修改代码,减少gpu使用,目前使用6G显存

5.启动web服务

windows部署

1. 下载安装anaconda3

2. 创建并虚拟环境

3. 下载安装chatglm

4. 修改代码,减少gpu使用,目前使用6G显存

5.启动web服务


ubuntu部署

1. 下载安装anaconda3

    wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
    ./Anaconda3-2021.11-Linux-x86_64.sh

2. 创建并虚拟环境

    conda create -n chatglm python==3.10.4
    source activate chatglm
    conda install pip

3. 下载安装chatglm

    git clone --recursive https://github.com/THUDM/ChatGLM-6B
    cd ChatGLM-6B
    pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
    
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple streamlit
  pip install -i https://pypi.tuna.tsinghua.edu.cn/simple streamlit-chat

4. 修改代码,减少gpu使用,目前使用6G显存

    修改web_demo2.py
    修改前
    model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda()
    修改后
    model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().quantize(4).cuda()
    
    如果没有显卡
    修改为
    model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).float()

5.启动web服务

    streamlit run web_demo2.py

windows部署

1. 下载安装anaconda3

    下载地址 https://repo.anaconda.com/archive/Anaconda3-2021.11-Windows-x86_64.exe
    安装 Anaconda3-2021.11-Windows-x86_64.exe

2. 创建并虚拟环境

    conda create -n chatglm python==3.10.4
    activate chatglm
    conda install pip

3. 下载安装chatglm

    git clone --recursive https://github.com/THUDM/ChatGLM-6B
    cd ChatGLM-6B
    pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
    
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple streamlit
  pip install -i https://pypi.tuna.tsinghua.edu.cn/simple streamlit-chat

4. 修改代码,减少gpu使用,目前使用6G显存

    修改web_demo2.py
    修改前
    model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().cuda()
    修改后
    model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).half().quantize(4).cuda()
    
    如果没有显卡
    修改为
    model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True).float()

5.启动web服务

    streamlit run web_demo2.py

6. 问题报错

运行时报报一个这个错,但是icetk已经安装,许久无法解决,应该是torch相关库的版本问题,最后的解决办法,给到下面

ImportError: This modeling file requires the following packages that were not found in your environment: icetk. Run `pip install icetk`

重新安装torch库就可以了 

pip uninstall torch torchvision torchaudio

pip install torch torchvision torchaudio

7 运行结果

  • 10
    点赞
  • 72
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

telllong

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值