仅在OpenCL 1.2设备上导入opencl时,无法在Windows上运行可执行文件。此问题在OpenCL 2.0设备上消失了。我将pyopencl用于Python 3.7和OpenCL 1.2。当我使用Pyinstaller时,请确保已启用控制台以获取Powershell的反馈。做./program.exe
时,我收到一条警告,提示It looks like you are importing PyOpenCL from its source directory. This likely won't work.
我正在使用64位PyOpenCL,已经尝试过PyOpenCL 1.2和2.1版本,并且会出现相同的结果。在我下面的控制台中,它在我的原始.py文件中说“第17行”,这就是我导入PyOpenCL的地方,这就是我对PyOpenCL所做的一切。我怀疑是没有正确导入,但是在OpenCL 2.1上可以很好地确定GPU中有多少计算单元,但是当我切换到稍旧的计算机时,它给出了上述错误。在我的控制台输出下面是PyOpenCL __init__.py
的第36行,下面是pyimod03_importers.py
PS D:\program> ./program.exe
D:\program\pyopencl\__init__.py:42: UserWarning: It looks like you are importing PyOpenCL from its source directory. This likely won't work.
Traceback (most recent call last):
File "program.py", line 17, in <module>
File "c:\users\jimmy\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
File "site-packages\pyopencl\__init__.py", line 36, in <module>
ImportError: DLL load failed: The specified module could not be found.
[4280] Failed to execute script program
PS D:\program>
import pyopencl._cl as _cl
exec(bytecode, module.__dict__)
该程序应该启动GUI,但是由于此PyOpenCL导入错误而终止了整个应用程序。非常感谢您的帮助。