VMWars中Debian11安装chatglm.cpp,chatglm6b-32k,QAnything全过程

准备工作:

  • 安装Debian11的ios镜像
  • 网络设置
    • 在安装debian11的时候选择国内的清华的源
    • 设置http_proxy,可以加快速度
  • 下载chatglm6b-32k的大模型(不支持function_call的功能)
    • 下载地址:https://www.wisemodel.cn/models/ZhipuAI/chatglm3-6b-32k
    • git clone https://www.wisemodel.cn/ZhipuAI/chatglm3-6b-32k.git (可能会有问题,做的不完善,不行的话,就自己手动的下载就好了)
  • 下载chatglm6b 大模型,可以支持function_call的功能
    • apt install git-lfs (用于git的下载,不然git clone下载下来的数据不全)
    • git lfs install
    • git clone https://www.modelscope.cn/ZhipuAI/chatglm3-6b.git
    • 参考链接: [Windows本地部署ChatGLM3-6B模型] (https://blog.csdn.net/Silver__Wolf/article/details/135817503)
  • 下载chatglm.cpp的github文件到本地
    • 下载地址:https://github.com/li-plus/chatglm.cpp
    • git clone --recursive https://github.com/li-plus/chatglm.cpp.git && cd chatglm.cpp
  • 下载QAnything的github项目到本地
    • 下载地址:https://github.com/netease-youdao/QAnything
  • 安装第三方的库
    • apt install python3
    • apt install cmake
    • apt install gcc
    • apt install libopenblas-dev
    • apt-get install libpthread-stubs0-dev
    • apt-get install libgoogle-perftools-dev
    • apt-get install libpthread-dev

操作步骤

1.安装需要的python依赖包
  • python3 -m pip install -U pip 安装更新pip包
  • python3 -m pip install torch tabulate tqdm transformers accelerate sentencepiece 下载需要的安装包(比较大,10MB/s的网速,是下了大概30分钟左右)
2.将大模型变形
  • 进入chatglm.cpp的目录下
  • python3 chatglm_cpp/convert.py -i xxxx(替换成自己下载的模型的文件夹) -t q4_0 -o chatglm-ggml.bin (表示将模型转换为chatglm-ggml.bin的文件,并且用4bit的进度,相对于cpu来说,这个速度会比较快,位数越多,速度越慢)
3.设置swap的大小,内存要给够,设置个20G的内存(32G内存的可以忽略这步)
  • 参考网页:https://ayw.ink/3439.html
  • 注意:内存不够,会导致cmake --build会卡在75%报错,从而导致后续的编译失败
  • apt install util-linux (可以使用swapoff设置交换内存)
  • sudo swapon -s 查看swapon的状态
  • sudo fallocate -l 20G /swapfile 创建一个20G的swap交换内存,并且命名为/swapfile
  • sudo chmod 600 /swapfile 设置这个文件为读和写的权限
  • sudo mkswap /swapfile 将交换内存生效
  • sudo echo ‘/swapfile none swap sw 0 0’ | sudo tee -a /etc/fstab 开机自动挂载交换内存
  • sudo swapon -s 查看交换内存状态,或使用free -h 查看
4.Build chatglm.cpp项目
  • 进入chatglm.cpp 目录下
  • cmake -B build (用来检查依赖项的)
  • cmake --build build -j --config Release
5.执行example示例进行处理
5.1 streamlimit run chatglm3_demo.py
  • 进入chatglm.cpp目录,执行pip install .
  • 拷贝: cp ./build/lib.linux-x86_64-cpython-310/chatglm_cpp/_C.cpython-310-x86_64-linux-gnu.so ./chatglm_cpp/_C.cpython-310-x86_64-linux-gnu.so (根据实际情况进行处理)
    • 执行 python chatglm3_demo.py 即可
  • 问题:
  • 1.huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form ‘repo_name’ or ‘namespace/repo_name’: ‘/home/gxe/chatglm_cpp/chatglm-ggml.bin’. Use repo_type argument if needed
    • 估计是找到的这个bin文件是错误的,需要在chatglm3_demo.py文件中进行修改
    • 修改文件中的MODEL_PATH为绝对路径试试看
  • 2.我发现我让查询天气的时候并没有生效,有点奇怪,显示自己不能联网,不知道结果是什么
    • 查看可以下代码 和 system下的function_call文件,似乎没有什么问题才是

问题

  • 在设置swapoff的时候,系统提示没有swapoff的指令
    • apt install util-linux 包,但还是提示说没有这个swapoff的指令,不应该呀
    • 具体的参考方式是:https://ayw.ink/3439.html
  • cmake --build 阶段报错,Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
  • 执行python3 chatglm3_demo.py 时 ModuleNotFoundError: No module named ‘chatglm_cpp._C’
    • 进入chatglm.cpp目录下,执行pip install .
    • 执行后,内存要足够,会生成一个文件 在build,拷贝处理: cp ./build/lib.linux-x86_64-cpython-310/chatglm_cpp/_C.cpython-310-x86_64-linux-gnu.so ./chatglm_cpp/_C.cpython-310-x86_64-linux-gnu.so
    • 执行正常
  • 执行
  • 8
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值