python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

03-24 1267阅读

【ChatGLM2-6B】环境部署

完整部署过程:

  1. Anacond安装

    Python&aconda系列:Anacond、Miniconda的下载安装配置教程详解

  2. CUDA、cuDNN安装

    python&anconda系列(亲测有效):window11系统CUDA、cuDNN 安装以及环境变量配置

  3. Pytorch安装

    Python&anconda系列(亲测有效):安装pytorch以及报错AssertionError: Torch not compiled with CUDA enabled解决方法

  4. 【ChatGLM2-6B】下载并启动

    python&anconda系列:ChatGLM:本地化搭建大模型实例

可能遇到的问题

Anacond系列:
  • python&anconda系列:无法加载文件C:\Users\xxx\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本

  • python&anconda系列:Invoke-Expression ,Invoke-Expression -Command $activateCommand或power shell激活虚拟环境报错失

  • Python&aconda系列:关于Anaconda:conda在Powershell上激活(assert last_idx is not None)

  • Python&aconda系列:【python环境搭建】conda 安装过程中无法激活 python 虚拟环境问题

  • Python&aconda系列:Unable to create process using ‘D:\Anaconda3\python.exe D:\Anaconda3\Scripts\conda-s

  • Python&aconda系列:cmd/powershell/anaconda prompt提示“系统找不到指定的路径”(亲测有效)

    Pytorch系列
    • Python&aconda系列:Torch not compiled with CUDA enabled 报错的归纳总结



      【ChatGLM2-6B】问题解决

      一. cannot import name ‘Doc‘ from ‘typing_extensions‘

      问题描述

      在运行ChatGLM2-6B大语言模型和使用P-Tuning训练的时候,出现如下错误

      cannot import name 'Doc' from 'typing_extensions'
      
      问题原因

      因为安装的typing_extensions版本不正确,需要重新安装

      解决方案

      运行: pip install typing_extensions==4.8.0

      如果出现: Requirement already satisfied: typing_extensions==4.8.0 in /xxx

      需要运行: pip install typing_extensions==4.8.0 --force-reinstall

      –force-reinstall参数会先缷载再重新安装

      二. ImportError: cannot import name ‘_illegal’ from 'sympy.core.numbers’错

      根据提供的引用内容,出现ImportError: cannot import name ‘_illegal’ from 'sympy.core.numbers’错误可能是由于sympy库版本不兼容或安装不完整导致的。解决此问题的方法是重新安装或升级sympy库。

      你可以尝试以下解决方案:
      卸载sympy库:
      pip uninstall sympy
      
      重新安装sympy库:
      pip install sympy
      
      如果上述方法无效,可以尝试升级sympy库:
      pip install --upgrade sympy
      

      请注意,确保你的Python环境中没有其他与sympy库相关的问题,例如依赖项缺失或其他冲突的库。

      三. DLL load failed while importing _imaging: 找不到指定的模块的解决方法 Python 文件命名引发的“module has no attribute“错误

      DLL load failed while importing _imaging: 找不到指定的模块的解决方法

      卸载当前版本,安装6.2.1版本

      pip uninstall pillow
      
      pip install pillow==6.2.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/****
      

      Python 文件命名引发的"module has no attribute"错误

      保存py文件命名时,一定要注意,不能与导入的模块重名

      因为import dgl,会先在当前目录下查找有没有dgl模块,即dgl.py文件。找到了就导入,也就是说这里导入的就是自己。自然就无法使用turtle模块的对象。

      四. python 报错 ModuleNotFoundError: No module named ‘chardet‘ 解决方法

      报错信息

      错误信息:

      ModuleNotFoundError: No module named 'chardet'
      

      错误截图:

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      解决办法一

      通过如下命令安装chardet模块:

      pip install chardet
      

      运行上面的命令后如果出现以下错误,多数被墙,截图如下:

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      解决方法二

      手动下载chardet模块,下载地址如下:

      https://github.com/chardet/chardet
      

      将下载的文件解压到相应的目录中,比如:E:\Python\chardet,截图如下:

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      通过命令行进入到chardet目录,执行setup.py文件进行安装,命令如下:

      python setup.py install
      

      命令截图如下:

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      安装结束后,查看是否已经安装成功

      pip list
      

      五. chatglm2-b部署报错问题‘Textbox‘ object has no attribute ‘style‘

      我们在部署chatglm2-b的时候可能出现’Textbox’ object has no attribute 'style’的问题

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      这是因为安装的第三方库gradio版本太高,降低版本即可。

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      安装3.50.0或者3.49.0都可以。

      六. RuntimeError: CUDA out of memory. Tried to allocate 128.00 MiB (GPU 0; 8.00 GiB total capacity; 1

      下载下来的源代码,在web_demo.py文件中的第6-7行:

      tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True)
      
      model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True, device='cuda')
      

      修改后:

      tokenizer = AutoTokenizer.from_pretrained("E:\ChatGLM2-6B-main\model", trust_remote_code=True)
      
      model = AutoModel.from_pretrained("E:\ChatGLM2-6B-main\model", trust_remote_code=True).half().quantize(4).cuda()
      

      其中E:\ChatGLM2-6B-main\model为我电脑模型下载位置,更改为你自己的即可。

      half().quantize(4).cuda() 这个需要根据你电脑实际显卡GPU进行更改。

      # 6G 显存可以 4 bit 量化
      model = AutoModel.from_pretrained("model", trust_remote_code=True).half().quantize(4).cuda()
      
      # 10G 显存可以 8 bit 量化
      model = AutoModel.from_pretrained("model", trust_remote_code=True).half().quantize(8).cuda()
      
      # 14G 以上显存可以直接不量化,
      model = AutoModel.from_pretrained("model", trust_remote_code=True).half().cuda() 
      

      笔者是8G内存,是不是可以这样改

      trust_remote_code=True).half().quantize(6).cuda()
      

      答案是否定的,因为会报错

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      只能是4或8,源码里有写,否则会报错

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      七. 提出了问题,回答空白

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      科学上网后

      python&anconda系列:【ChatGLM2-6B】运行问题、【ChatGLM2-6B】环境部署

      只是一闪,还是空白(这是笔者尝试了好多次抓的截图),可能笔者用的是免费的科学上网工具吧




      太空眼睛

      【ChatGLM2-6B】问题解决cannot import name ‘Doc‘ from ‘typing_extensions‘

      岁岁平安·年年岁岁·岁岁年年

      DLL load failed while importing _imaging: 找不到指定的模块的解决方法 Python 文件命名引发的“module has no attribute“错误

      whatday

      python 报错 ModuleNotFoundError: No module named ‘chardet‘ 解决方法

      我不会深度学习

      chatglm2-b部署报错问题‘Textbox‘ object has no attribute ‘style‘

      sen1112

      【AI-ChatGLM2】ChatGLM2-6B Wind+GPU本地部署流程

VPS购买请点击我

文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

目录[+]