一個IT宅男

在wsl的Ubuntu下部署ChatGLM3-6B-32K

2023年12月13日08:15:34部署日志:

安装过程


进入ubuntu wsl -d Ubuntu-22.04

mkvirtualenv chatglm

cd /mnt/g (我的g盘,你看情况)

git clone <https://github.com/THUDM/ChatGLM3>
cd ChatGLM3
pip install -r requirements.txt

2,安装正确版本torch

nvidia-smi返回结果: NVIDIA-SMI 545.23.07 Driver Version: 546.12 CUDA Version: 12.3

CUDA 12.3官方https://pytorch.org/get-started/locally/查询后给的命令:

pip3 install torch torchvision torchaudio

你根据自己显卡的情况自己查询安装命令行。

3,启动chatglm演示(web+api):

有2个文件夹演示我们先要用到的,一个是composite_demo(一些问答的演示,和工具的调用),还有一个是openai_api_demo 它模拟了openai的接口,方便被第三方调用,非常重要

cd composite_demo

pip install -r requirements.txt

修改client.py里的一处chatglm3-6b为chatglm3-6b-32k

执行:streamlit run demo_main.py

运行对话模型演示

或者把api开起来:

所有调用openai_api.py和openai_api_request.py全部THUDM/chatglm3-6b需要修改为THUDM/chatglm3-6b-32k

cd openai_api_demo

pip install -r requirements.txt

修改openai_api.py和openai_api_request.py文件 :chatglm3-6b为chatglm3-6b-32k

启动接口 : python openai_api.py

遇到问题

1,警告:Explicitly passing a revision is encouraged when loading a model with custom code to ensure no malicious code has been contributed in a newer revision.

调用中加revision="v1.1.0"

https://huggingface.co/THUDM/chatglm-6b#change-log

tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True,revision="v1.1.0")

2,web_demo.py页面不回答问题,是gradio版本问题:

pip install gradio==3.39.0

transformers 库版本推荐为 4.27.1

赞(2)
未經允許不得轉載:Lincai Chen's Blog » 在wsl的Ubuntu下部署ChatGLM3-6B-32K

評論 6

  1. #1

    请问你用的Ubuntu的镜像源是什么?我安装依赖项出现一大堆无效请求的。。

    nyd4个月前 (03-29)回复
    • 我就这样 wsl --install -d Ubuntu-22.04

      clc4个月前 (03-30)回复
      • 我想问的是明明我安装了python3,为什么运行的虚拟环境是python2.7?you must use /root/.virtualenvs/chatglm/bin/python2)

        nyd4个月前 (04-03)回复
  2. #2

    在执行streamlit run demo_main.py时,出现Traceback (most recent call last):
    File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
    File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
    File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
    ModuleNotFoundError: No module named 'apt_pkg',但我能在/usr/lib/python3/dist-packages目录下找到这个模块且路径已设置正确,我用了很多方法都无法解决这个问题,现在我使用的环境是python3.10.14。

    nyd4个月前 (04-08)回复
  3. #3

    模型在哪里,chatglm3-6b-32k 对应的模型在哪里

    qushen3个月前 (05-12)回复