chatglm.cpp
chatglm.cpp copied to clipboard
Python Module 调用失败
Macbook M1 pro 16G
编译成功
cmake -B build 成功
cmake --build build -j 成功
python convert.py -i ~/models/THUDM/chatglm2-6b -t f16 -o chatglm2-ggml-f16.bin 成功
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████| 7/7 [00:08<00:00, 1.28s/it]
Dumping model state: 100%|██████████████████████████████████████████████████████████████████████| 199/199 [00:35<00:00, 5.66it/s]
运行测试成功
./build/bin/main -m chatglm2-ggml-f16.bin -i
________ __ ________ __ ___
/ ____/ /_ ____ _/ /_/ ____/ / / |/ /_________ ____
/ / / __ \/ __ `/ __/ / __/ / / /|_/ // ___/ __ \/ __ \
/ /___/ / / / /_/ / /_/ /_/ / /___/ / / // /__/ /_/ / /_/ /
\____/_/ /_/\__,_/\__/\____/_____/_/ /_(_)___/ .___/ .___/
/_/ /_/
Prompt > 你好!
ChatGLM2 > 你好👋!我是人工智能助手 ChatGLM2-6B,很高兴见到你,欢迎问我任何问题。
成功速度很快
Python Binding 有问题
pip install .
.....
Successfully built chatglm-cpp
Installing collected packages: chatglm-cpp
Successfully installed chatglm-cpp-0.2.0
运行 web_demo.py 失败
python web_demo.py -m chatglm2-ggml-f16.bin
Traceback (most recent call last):
File "/Users/suifei/works/chatglm.cpp/web_demo.py", line 5, in <module>
import chatglm_cpp
File "/Users/suifei/works/chatglm.cpp/chatglm_cpp/__init__.py", line 5, in <module>
import chatglm_cpp._C as _C
ModuleNotFoundError: No module named 'chatglm_cpp._C'
请问下这个是什么原因导致的,python module 调用失败
System environment
Apple M1 Pro 16 GB macOS(13.4.1 (22F82))
The compilation was successful
cmake -B build #Success
cmake --build build -j #Success
python convert.py -i ~/models/THUDM/chatglm2-6b -t f16 -o chatglm2-ggml-f16.bin #Success
Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████| 7/7 [00:08<00:00, 1.28s/it]
Dumping model state: 100%|██████████████████████████████████████████████████████████████████████| 199/199 [00:35<00:00, 5.66it/s]
The test was successful
./build/bin/main -m chatglm2-ggml-f16.bin -i
________ __ ________ __ ___
/ ____/ /_ ____ _/ /_/ ____/ / / |/ /_________ ____
/ / / __ \/ __ `/ __/ / __/ / / /|_/ // ___/ __ \/ __ \
/ /___/ / / / /_/ / /_/ /_/ / /___/ / / // /__/ /_/ / /_/ /
\____/_/ /_/\__,_/\__/\____/_____/_/ /_(_)___/ .___/ .___/
/_/ /_/
Prompt > hello!
ChatGLM2 > Hello! How can I assist you today?
The success rate is fast.
To install the Python binding from source, run:
pip install .
.....
Successfully built chatglm-cpp
Installing collected packages: chatglm-cpp
Successfully installed chatglm-cpp-0.2.0
An error occurred while running web_demo.py.
python web_demo.py -m chatglm2-ggml-f16.bin
Traceback (most recent call last):
File "/Users/suifei/works/chatglm.cpp/web_demo.py", line 5, in <module>
import chatglm_cpp
File "/Users/suifei/works/chatglm.cpp/chatglm_cpp/__init__.py", line 5, in <module>
import chatglm_cpp._C as _C
ModuleNotFoundError: No module named 'chatglm_cpp._C'
What is the reason for the failure of the Python module call?
+1
尝试把编译的出来so放到当前的chatglm_cpp目录下面
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
尝试把编译的出来so放到当前的chatglm_cpp目录下面
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
问题已解决/The problem has been resolved.
cd chatgml.cpp
cp ./build/lib.linux-x86_64-cpython-39/chatglm_cpp/_C.cpython-39-x86_64-linux-gnu.so ./chatglm_cpp/
看起来是本地的 chatglm_cpp 目录跟安装的包名冲突了,我调整下目录结构
python setup.py build_ext --inplace
你好,我在mac上运行api方式启动,报错。 mac上并没有找到响应的so文件。 我把build目录下的全部内容都copy到chatglm_cpp下也没有用
ModuleNotFoundError: No module named 'chatglm_cpp._C'
其实把你的python脚本放到chatglm.cpp这个目录的外面执行就好了。
我观察到pip install .之后,在我自己的python目录下python3.8/site-packages是有chatglm_cpp目录的,证明其实已经安装成功了。 然后我在python3.8/site-packages这个目录执行python,输入import chatglm_cpp就不会报错了。但是在chatglm.cpp这个目录,我执行python,然后输入chatglm_cpp就报错了。所以也不知道为啥,反正在chatglm.cpp这个目录外面执行python就没问题了。
你好,我在mac上运行api方式启动,报错。 mac上并没有找到响应的so文件。 我把build目录下的全部内容都copy到chatglm_cpp下也没有用
``` ModuleNotFoundError: No module named 'chatglm_cpp._C' ```
上面有人回答了,不要在chatglm.cpp目录下运行,到其他目录,chatglm.cpp下也有个chatglm_cpp目录,在python里面import的时候会优先去这个目录下找,所以报找不到的错误了
Hi, after resolving the error
ModuleNotFoundError: No module named 'chatglm_cpp._C'
It still wont run :
ImportError: cannot import name 'computed_field' from 'pydantic' (/Users/edwardnone/miniconda3/lib/python3.10/site-packages/pydantic/__init__.cpython-310-darwin.so)
Anybody successfully run this ? (m2 pro)
将chatglm.cpp 下的chatglm_cpp 换个名称。