Chen LinCai陈林材

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

clcon 4 days ago


2023年12月13日08:15:34部署日志: 安装过程 进入ubuntu wsl -d Ubuntu-22.04 mkvirtualenv chatglm cd /mnt/g (我的g盘,你看情况) git clone 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