ChatGLM2-6B icon indicating copy to clipboard operation
ChatGLM2-6B copied to clipboard

[BUG/Help] 在 Windows 上运行,加载了 Linux 共享库

Open wizardforcel opened this issue 2 years ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Current Behavior

这个BUG不影响运行,但是总觉得那里不对。

Load parallel cpu kernel failed C:\Users\Administrator\.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization_kernels_parallel.so

Expected Behavior

编译并加载 DLL

Steps To Reproduce

PS D:\src\chatglm2-6b-int4> python .\cli_demo.py
Load parallel cpu kernel failed C:\Users\Administrator\.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization_kernels_parallel.so: Traceback (most recent call last):
  File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization.py", line 148, in __init__
    kernels = ctypes.cdll.LoadLibrary(kernel_file)
  File "D:\Python310\lib\ctypes\__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "D:\Python310\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

Load cpu kernel C:\Users\Administrator\.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization_kernels.so failed: Traceback (most recent call last):
  File "C:\Users\Administrator/.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization.py", line 165, in __init__
    kernels = ctypes.cdll.LoadLibrary(kernel_file)
  File "D:\Python310\lib\ctypes\__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "D:\Python310\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 不是有效的 Win32 应用程序。

欢迎使用 ChatGLM2-6B 模型,输入内容即可进行对话,clear 清空对话历史,stop 终止程序

用户:你好

ChatGLM:你好👋!我是人工智能助手 ChatGLM2-6B,很高兴见到你,欢迎问我任何问题。

用户:你能做什么?

ChatGLM:我是一个大型语言模型,可以进行自然语言处理和生成,以及理解和回答各种问题。以下是我的一些能力:

1. 对话:我们可以进行文字聊天,讨论各种话题,我会尽力理解你的问题,并给出相应的回答。

2. 文本生成:我可以根据你的问题生成各种文本,如文章、摘要、翻译等。

3. 翻译:我也可以帮助你进行语言翻译,跨越多种语言的障碍。

4. 问题解答:回答各种问题,涉及各种领域,我会尽力提供准确和有用的答案。

5. 机器学习:我还在不断学习进步,可以通过机器学习算法,对各种数据进行分类、分析和预测。

希望我的能力对你有所帮助。如果你有任何问题,请随时告诉我。

用户:

Environment

- OS: Windows10
- Python: 3.10.10
- Transformers: 4.13.0
- PyTorch: 2.0.1+cu117
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) : True
- GCC: 6.3.0

Anything else?

No response

wizardforcel avatar Aug 15 '23 06:08 wizardforcel

已经解决,你这个issue我把python 64位和MinGW gcc 64位对上就变成以下这个issue。

FileNotFoundError: Could not find module 'C:\Users\Administrator.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4\quantization_kernels_parallel.so' (or one of its dependencies). Try using the full path with constructor syntax.

然后修改quantization.py 的 kernels = ctypes.cdll.LoadLibrary(kernel_file), 改成kernels = ctypes.CDLL(kernel_file,winmode=0) 。因为我在本地load model, 由于这个quantization.py 在.cache目录(C:\Users\Administrator.cache\huggingface\modules\transformers_modules\chatglm2-6b-int4)里面会自动更新,需要修改我存在本地的model(E:\modelscope\chatglm2-6b-int4)的quantization.py。

另外:这个编译出来的so其实是dll。

szhowardhuang avatar Jan 05 '24 13:01 szhowardhuang