gpt4 book ai didi

python - pyopencl 导入错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:42:22 25 4
gpt4 key购买 nike

我在 Windows 10 上运行 python 3.5.4 通过 Anaconda 和来自 conda-forge 的 pyopencl 2017.2,通过 Anaconda 安装。我的系统是i5 4670K,运行驱动版本是R9 29017.11.1 与 OpenCL 版本23.20.788.0.

尝试导入 pyopencl 模块时遇到以下错误

    >>> import pyopencl as cl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "[my home folder]\Anaconda3\lib\site-packages\pyopencl\__init__.py", line 37, in <module>
import pyopencl.cffi_cl as _cl
File "[my home folder]\Anaconda3\lib\site-packages\pyopencl\cffi_cl.py", line 39, in <module>
from pyopencl._cffi import ffi as _ffi
ImportError: DLL load failed: The specified module could not be found.

错误似乎是在加载 _cffi.pyd 时发生的。此错误与之前线程中显示的问题有相似之处:

Python pyopencl Import Error

cffi load failure when trying to import PyOpenCL

pyopencl import error cffi.so undefined symbol

然而,尽管安装完成(看似)没有错误,但我从 AMD 和 Intel 安装 OCL SDK:s 时问题仍然存在。我还更新了我的显卡驱动程序。

我尝试使用 Dependency Walker 检查 _cffi.pyd 的依赖项,如以下线程中所述:

Python pyopencl DLL load failed even with latest drivers

这确实在 opencl.dll 下出现了很多循环依赖和缺失的依赖,名称以 API-MS-WINEXT-MS-获胜。重命名 /System32 中的 opencl.dll 并改用 \Anaconda3\Library\bin 中的文件时,依赖项错误仍然存​​在。

经过一番搜索,我发现了这个主题:

Dependency Walker: missing dlls

这基本上说明缺少的依赖项无需担心。

最佳答案

我也遇到了这个问题,我的研究使我找到了帮助安装兼容版本的文档:https://media.readthedocs.org/pdf/mot/master/mot.pdf

错误是因为您没有适用于 AMD 或 Intel 的 pyopencl 和 opencl 驱动程序的兼容版本。

引用:

Installing a precompiled binary wheel (.whl) is the easiest way to install PyOpenCL, but only works if the wheel is compiled for your specific Python implementation. At Christoph Gohlke website (http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl) you can find a range of PyOpenCL binary packages. If there is a compatible one for your system, download that version. You can see if it is compatible if the Python version and OpenCl version in the binary name matches that of your installed Python and driver supported versions. Note that many drivers, such as nVIDIA’s only support OpenCL 1.2, so in that case take the wheel with “+cl12” in the name, and not e.g. “+cl21”. For example if you have 64-bit Windows system with Python 3.5 and your GPU or CPU drivers support OpenCL 1.2 you need to download the wheel with “+cl12”, win-amd64 and cp35m in the name (note the format, cp<version>m, the m is important). (To check which Python version you have you can run python --version in the command line).

这对你有帮助

关于python - pyopencl 导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47161850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com