Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows下Python Binding GPU编译后无法导入chatglm_cpp #181

Open
Jzhnakui opened this issue Nov 8, 2023 · 4 comments
Open

Windows下Python Binding GPU编译后无法导入chatglm_cpp #181

Jzhnakui opened this issue Nov 8, 2023 · 4 comments

Comments

@Jzhnakui
Copy link

Jzhnakui commented Nov 8, 2023

我是windows,一样的报错
G:\fuckkk\chatglm.cpp\build\lib.win-amd64-cpython-310\chatglm_cpp
image
D:\Anaconda3-2021.11\envs\chatglm\Lib\site-packages\chatglm_cpp
image

也不再冲突目录中加载;
image

已经参考
#177
#91
无法解决

@EpicLolia
Copy link

Python3.8之后需要通过os.add_dll_directory手动添加DLL搜索路径。
这里我们需要这两个CUDA的DLL:
image
你只需要在__init__.py文件的import chatglm_cpp._C as _C之前执行os.add_dll_directory(os.environ['CUDA_PATH'] + '/bin')即可。
参考代码如下:

import sys
if sys.version_info >= (3, 8) and sys.platform == "win32":
    import os
    if os.environ.get('CUDA_PATH') is not None:
        os.add_dll_directory(os.environ['CUDA_PATH'] + '/bin')

import chatglm_cpp._C as _C

@M1saka10010
Copy link

if sys.version_info >= (3, 8) and sys.platform == "win32":
import os
if os.environ.get('CUDA_PATH') is not None:
os.add_dll_directory(os.environ['CUDA_PATH'] + '/bin')

经过测试,可以了,不过我这边默认的 cuda path 名字叫 CUDA_PATH_V12_3

@shazhongcheng
Copy link

牛皮

@mark-legend
Copy link

高手

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants