个人使用ChatGLM-6B遇到的部分问题汇总
本文目录
- 写在最前
- 个人windows电脑部署时遇到
- KeyError: 'chatglm'
- 问题原因:transformers版本有问题
- 解决方法
- OSError/AssertionError/Failed to load cpm_kernels
- 问题原因:配置内容没有修改、依赖包不完整
- 解决方法
写在最前
项目的github网址(https://github.com/THUDM/ChatGLM-6B)中有解决问题专用的Issues模块
建议遇到问题先将部分报错写在这里进行查询,大概率能找到问题的解决方法
本文章只用于记录个人在使用过程中遇到的问题,供以后回忆之用。
个人windows电脑部署时遇到
以下都是在运行cli_demo.py遇到
KeyError: ‘chatglm’
# 出现异常描述
(ai) Q:\Python\project\ChatGLM\ChatGLM-6B-main>python cli_demo.py
Traceback (most recent call last):File "cli_demo.py", line 7, in <module>tokenizer = AutoTokenizer.from_pretrained("THUDM/ChatGLM-6B", trust_remote_code=True)File "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\transformers\models\auto\tokenization_auto.py", line 362, in from_pretrainedconfig = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)File "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\transformers\models\auto\configuration_auto.py", line 371, in from_pretrainedconfig_class = CONFIG_MAPPING[config_dict["model_type"]]
KeyError: 'chatglm'
问题原因:transformers版本有问题
推荐版本是4.27.1 ,但是好像不太行
解决方法
- 在出现这个问题之前,我先遇到了一个问题提示找不到模型,然后我查了以后有人说是因为transformer版本太低,然后我就把版本提升到4.3以上的一个版本,然后就出现了上所示问题
- 重新去github上找人答疑时,有人说需要版本得是transformers 4.28.1,我就死马当活马医重新pip install,发现解决了,进入下一个问题
OSError/AssertionError/Failed to load cpm_kernels
(ai) Q:\Python\project\ChatGLM\ChatGLM-6B-main>python cli_demo.py
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.
Explicitly passing a `revision` is encouraged when loading a configuration with custom code to ensure no malicious code has been contributed in a newer revision.
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.
--- Logging error ---
Traceback (most recent call last):File "C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization.py", line 19, in <module>from cpm_kernels.kernels.base import LazyKernelCModule, KernelFunction, round_upFile "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\cpm_kernels\__init__.py", line 1, in <module>from . import libraryFile "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\cpm_kernels\library\__init__.py", line 2, in <module>from . import cudaFile "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\cpm_kernels\library\cuda.py", line 7, in <module>cuda = Lib.from_lib("cuda", ctypes.WinDLL("nvcuda.dll"))File "q:\ide\python\cpython37\lib\ctypes\__init__.py", line 356, in __init__self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。During handling of the above exception, another exception occurred:Traceback (most recent call last):File "q:\ide\python\cpython37\lib\logging\__init__.py", line 1034, in emitmsg = self.format(record)File "q:\ide\python\cpython37\lib\logging\__init__.py", line 880, in formatreturn fmt.format(record)File "q:\ide\python\cpython37\lib\logging\__init__.py", line 619, in formatrecord.message = record.getMessage()File "q:\ide\python\cpython37\lib\logging\__init__.py", line 380, in getMessagemsg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:File "cli_demo.py", line 8, in <module>model = AutoModel.from_pretrained("THUDM\ChatGLM-6B", trust_remote_code=True).half().cuda()File "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\transformers\models\auto\auto_factory.py", line 467, in from_pretrainedpretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargsFile "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\transformers\modeling_utils.py", line 2629, in from_pretrainedmodel = cls(config, *model_args, **model_kwargs)File "C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\modeling_chatglm.py", line 1061, in __init__self.quantize(self.config.quantization_bit, self.config.quantization_embeddings, use_quantization_cache=True, empty_init=True)File "C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\modeling_chatglm.py", line 1424, in quantizefrom .quantization import quantize, QuantizedEmbedding, QuantizedLinear, load_cpu_kernelFile "<frozen importlib._bootstrap>", line 983, in _find_and_loadFile "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlockedFile "<frozen importlib._bootstrap>", line 677, in _load_unlockedFile "<frozen importlib._bootstrap_external>", line 728, in exec_moduleFile "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removedFile "C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization.py", line 46, in <module>logger.warning("Failed to load cpm_kernels:", exception)
Message: 'Failed to load cpm_kernels:'
Arguments: (OSError(22, '找不到指定的模块。', None, 126, None),)
No compiled kernel found.
Compiling kernels : C:\Users\user\.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization_kernels_parallel.c
Compiling gcc -O3 -fPIC -pthread -fopenmp -std=c99 C:\Users\user\.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization_kernels_parallel.c -shared -o C:\Users\user\.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quant
ization_kernels_parallel.so
'gcc' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Compile default cpu kernel failed, using default cpu kernel code.
Compiling gcc -O3 -fPIC -std=c99 C:\Users\user\.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization_kernels.c -shared -o C:\Users\user\.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization_kernels.so
'gcc' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Compile default cpu kernel failed.
Failed to load kernel.
Cannot load cpu or cuda kernel, quantization failed:
Traceback (most recent call last):File "cli_demo.py", line 8, in <module>model = AutoModel.from_pretrained("THUDM\ChatGLM-6B", trust_remote_code=True).half().cuda()File "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\transformers\models\auto\auto_factory.py", line 467, in from_pretrainedpretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargsFile "Q:\IDE\Python\vitrual_enviroment\ai\lib\site-packages\transformers\modeling_utils.py", line 2629, in from_pretrainedmodel = cls(config, *model_args, **model_kwargs)File "C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\modeling_chatglm.py", line 1061, in __init__self.quantize(self.config.quantization_bit, self.config.quantization_embeddings, use_quantization_cache=True, empty_init=True)File "C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\modeling_chatglm.py", line 1439, in quantizeself.transformer = quantize(self.transformer, bits, use_quantization_cache=use_quantization_cache, empty_init=empty_init, **kwargs)File "C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization.py", line 464, in quantizeassert kernels is not None
AssertionError
问题原因:配置内容没有修改、依赖包不完整
解决方法
这里有多个问题需要解决
gcc编译器未安装
- 项目的readme有写(位于使用方式/环境安装部分),如果安装时需要用cpu运行,必须安装gcc与openmp
- 下载的地址位于 (https://jmeubank.github.io/tdm-gcc/) 点进去以后因为推荐的是TDM-GCC 10.3.0,因此单击TDM-GCC 10.3.0 release,进去之后再点击(tdm64-gcc-10.3.0-2.exe)下载。
- 下载完成后点击运行文件,点create,然后点下一步,遇到能选openmp的时候记得选上就行
配置内容未修改
- 这里首先,要修改模型文件中的(即THUDM\ChatGLM-6B下的,或是model中的)THUDM/ChatGLM-6B/quantization.py这一文件
from cpm_kernels.kernels.base import LazyKernelCModule, KernelFunction, round_up
这行注释掉,后面会飘红也没关系,不用改- 把kernels = Kernel(…)注释掉,替换为kernels =CPUKernel() # 说实话这一步是否有用我不是很确定,后续重新运行时依然提示
NameError: name 'CPUKernel' is not defined
,但是不影响程序运行 - 再把已缓存的.cache目录下文件删掉!!! ,这里看报错的地方,我的缓存文件在 File “C:\Users\user/.cache\huggingface\modules\transformers_modules\ChatGLM-6B\quantization.py”
- 把.cache后面的huggingface文件夹直接删除
- 最后要记得修改cli_demo.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).float()
以上修改完成后,我的程序就已经可以运行了
个人使用ChatGLM-6B遇到的部分问题汇总相关推荐
- 张俊林:当前炼制“大语言模型”的两个现象
知乎:张俊林 链接:https://zhuanlan.zhihu.com/p/622365988 编辑:深度学习自然语言处理 公众号 先说第一个现象. 自从LLaMA和ChatGLM开源后,再加上各种 ...
- “超越”(MMCU)中文通用大语言模型测试集预发布
近期,中文大语言模型蓬勃发展,但却一直没有出现可应用于评测大模型能力的测试.甲骨易AI研究院提出一种衡量中文大模型处理多任务准确度的测试,并在此基础上制作了一套适配测试中文大模型的数据集,并将其命名为 ...
- minigpt4搭建过程记录,简单体验图文识别乐趣
引言 从3月开始,aigc进入了疯狂的开端,正如4月12日无界 AI直播 在<探索 AIGC 与人类合作的无限可能>中关于梳理的时间线一样,aigc的各种产品如雨后春笋般进入了不可逆的态势 ...
- 实现mini智能助理—模型训练
背景 距离上篇打带你实现自己迷你chatgpt文章,到现在已经过去快两个月.自制mini chatgpt文章一直没有更新,原因有二:1.一直在找合适体量表现不错模型 2.公司内部太卷了,没太多时间好好 ...
- 开源LLM「RWKV」想要打造AI领域的Linux和Android|ChatAI
RWKV想逐步成为最强开源模型,中期计划取代Transformer.能如愿吗? "我们没有护城河,OpenAI也是."近期,谷歌内部人士在Discord社区匿名共享了一份内部文件, ...
- LLMs模型速览(GPTs、LaMDA、GLM/ChatGLM、PaLM/Flan-PaLM、BLOOM、LLaMA、Alpaca)
文章目录 一. GPT系列 1.1 GPTs(OpenAI,2018--2020) 1.2 InstructGPT(2022-3) 1.2.1 算法 1.2.2 损失函数 1.3 ChatGPT(20 ...
- 【ChatGLM vs ChatGPT】怎样实现机器人自动写代码?不少于3000字。
图:a robot is writing code, by Stable Diffusion 禅与计算机程序设计艺术: 总体来看,ChatGLM(6B)和 ChatGPT(175B)在技术领域的问答 ...
- H01-P1201-0.6B金升阳高压模块
■ 背景 HO1-P1201-0.6B 空载输入电流低至8mA,输出电压0±1250V.0±1500V连续线性可调,工作温度范围为-25℃ to 71℃. ▲ 寄送过来的HO1-P1201-06B的样 ...
- 基于python的modbus协议编程_IM5D.6B利用(2.4G)无线模块实现远程控制(基于智能编程任务赛,2019版)...
点击「蓝色微信名」关注更多比赛信息 引 言 在<中国儿童青少年威盛中国芯计算机表演赛>从第十七届活动开始,搭建了一个全新的互联网技术支持平台,实现了网络在线比赛,在全国建立了三十个省级赛 ...
- VideoLan 0.8.6b test 1
VideoLAN Client可以播放 MPEG-1.MPEG-2.MPEG-4.DivX.DVD/VCD.数字卫星频道.数字地球电视频道(digital terrestial television ...
最新文章
- C++ 虚函数与存虚函数
- 使用Apache自带的ab命令测试网站性能(小强性能测试班学员作品)
- 九大排序算法Java实现
- java listeners_Java ActionListeners
- qt执行命令行失败_QT缺少 qtcore4.dll,debug下运行不成功
- CmsEasy 如何安装
- Java并发(9)- 从同步容器到并发容器
- 三种方法进行分水岭分割
- YouCompleteMe自动补全的安装配置与使用
- ArcGIS10.3 Desktop Server 安装教程 附下载地址
- 【U+】通用财务,附加数据库后,软件看不到账套。
- Unity UnityWebRequest使用方法
- python爬取某人所有微博_python爬取微博用户关注和粉丝的公开基本信息
- leetcode刷题笔记(1-10)持续更新中
- 华东师范大学计算机专硕学硕,学硕?专硕?该怎么选择
- BZOJ 5109: [CodePlus 2017]大吉大利,晚上吃鸡! 最短路 拓扑 Dp
- 华为p4不是鸿蒙吗怎么又改为安卓_华为已将“基于安卓10”变成“兼容安卓10”,EMUI就是鸿蒙OS...
- OpenCV检测手指个数
- 电脑版适合什么插件HTML,推荐一些好用的Chrome插件
- 12.寻光集后台管理系统-库存信息(后端)