零基础部署chatglm

目录


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

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

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 运行结果

 

 

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2023年5月23日
下一篇 2023年5月23日

相关推荐