问题描述
在大量搜索此问题的解决方案后,我发现此特定错误尚未针对 Windows 正确记录.所以我决定将这个问题与解决方案一起发布.对不起,如果我在错误的部分发布了这个.我希望这个解决方案能帮助用户在未来解决 PyOpenCL 安装错误.请注意,此处使用的示例适用于支持 AMD OpenCL SDK
SDK 的 ATI Radeon GPU
.对于其他GPU
,请参考各自的参数并根据需要实现.如果安装失败,也不要尝试使用 pip
进行安装.而是从此处下载pyopencl
的压缩副本.
After searching a lot for solutions to this problem, I found that this particular error has not been documented properly for Windows. So I have decided to post this issue along with the solution. Sorry if I am posting this in the wrong section. I hope this solution will help users with the PyOpenCL installation error in the future. Please note that the examples used here are for ATI Radeon GPUs
that supports the AMD OpenCL SDK
SDK. For other GPUs
, please refer to their respective parameters and implement them as necessary. Also do not attempt to install using pip
if the installation fails. Instead download a zipped copy of pyopencl
from here.
所以安装 PyOpenCL 时的错误信息是:
So the error message while installing PyOpenCL is:
在 src/wrapper/wrap_cl.cpp:1:0:
包含的文件中src/wrapper/wrap_cl.hpp:27:19: 致命错误: CL/cl.h: No such File or Directory
错误:命令gcc"失败,退出状态为 1
为了解决这个问题,必须知道默认的 CL/cl.h 通常存储在:C:/Program Files (x86)/.../include/CL
.但是由于 gcc
编译器无法识别 (x86),您可以做的是:
In order to solve this, one must know that the default CL/cl.h is usually stored in:C:/Program Files (x86)/.../include/CL
. But since, (x86) is not identifiable by the gcc
compiler, what you can do is this:
- 复制
C:/Program Files (x86)/AMD APP SDK/2.9-1/include
中的CL
文件夹并将其粘贴到单独的位置,例如下载pyopencl.zip
的目录. - 同时复制
C:/Program Files (x86)/AMD APP SDK/2.9-1/lib
中的x86_64
文件夹并将其粘贴到与CL
文件夹. - 解压文件夹
pyopencl.zip
并转到(pyopencl的位置)/src/wrapper
- 在
wrapper
文件夹中,打开文件wrap_cl.hpp
. - 将
#include
更改为#include
- 接下来转到您在第一步中复制的
CL
并打开文件cl_platform.h
.再次重复第 5 步. - 接下来在
CL
文件夹中找到cl_ext.h
文件并打开它.再次重复第 5 步. - 在
admin
模式下的cmd
窗口中,进入pyopencl
目录并运行命令python configure.py代码>.这将生成一个
siteconf.py
文件,其中包含一些安装参数. - 打开
siteconf.py
文件并将CL_INC_DIR = []
替换为CL_INC_DIR = [r'(CL 文件夹新位置的路径)']
并将CL_LIB_DIR = []
替换为CL_LIB_DIR = [r'(x86_64 文件夹新位置的路径)']
. - 最后在
cmd
中,从pyopencl
目录运行python setup.py install
并享受.
- Copy the
CL
folder insideC:/Program Files (x86)/AMD APP SDK/2.9-1/include
and paste it in a separate location such as the directory where you have downloadedpyopencl.zip
. - Also copy the
x86_64
folder insideC:/Program Files (x86)/AMD APP SDK/2.9-1/lib
and paste it in the same directory as theCL
folder. - Unzip the folder
pyopencl.zip
and go to(location of pyopencl)/src/wrapper
- Inside the
wrapper
folder, open the filewrap_cl.hpp
. - Change the
#include <CL/cl.h>
to#include <cl.h>
- Next go to the
CL
that you copied in the first step and open the filecl_platform.h
. Repeat step 5 once more. - Next find the
cl_ext.h
file inside theCL
folder and open it. Repeat step 5 again. - Inside a
cmd
window inadmin
mode, go to the directory ofpyopencl
and run the commandpython configure.py
. This will generate asiteconf.py
file that will hold some parameters for installation. - Open the
siteconf.py
file and replace theCL_INC_DIR = []
withCL_INC_DIR = [r'(path to the new location of the CL folder)']
and replaceCL_LIB_DIR = []
withCL_LIB_DIR = [r'(path to the new location of the x86_64 folder)']
. - Finally in
cmd
, runpython setup.py install
from thepyopencl
directory and enjoy.
希望这个解决方案可以帮助您在 Windows 8 (x64) 中安装 PyOpenCL
.欢迎任何其他建议.
Hope this solution helps you during the installation of PyOpenCL
in Windows 8 (x64). Any other suggestions are welcome.
推荐答案
进行上述更改后,执行时:
After making changes above, when executing:
python setup.py install
我收到此错误:
building 'pyopencl._cl' extension
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\bin\HostX64\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DPYGPU_PACKAGE=pyopencl -DPYGPU_PYOPENCL=1 -DHAVE_GL=1 -IH:\pyopencl-2018.2\CL -Ipybind11/include -IC:\Users\James\Anaconda3\Include -IC:\Users\James\AppData\Roaming\Python\Python35\Include -IC:\Users\James\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\James\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\James\Anaconda3\lib\site-packages\numpy\core\include -IC:\Users\James\Anaconda3\include -IC:\Users\James\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\Include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\ATLMFC\Include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" /EHsc /Tpsrc/wrap_constants.cpp /Fobuild\temp.win-amd64-3.5\Release\src/wrap_constants.obj /EHsc /DVERSION_INFO=\"2018.2\"
wrap_constants.cpp
h:\pyopencl-2018.2\src\wrap_helpers.hpp(5): fatal error C1083: Cannot open include file: 'pybind11-2.2.4-py3.5.egg/pybind11.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX64\\x64\\cl.exe' failed with exit status 2
我要更改 wrap_helpers.hpp 的路径:
What path do I change wrap_helpers.hpp for:
#include <pybind11.h>
#include <operators.h>
这篇关于PyOpenCL“致命错误:CL/cl.h:没有这样的文件或目录"在 Windows 8 (x64) 中安装时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!