本文介绍了PyOpenCL“致命错误:CL/cl.h:没有这样的文件或目录"在 Windows 8 (x64) 中安装时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大量搜索此问题的解决方案后,我发现此特定错误尚未针对 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:

  1. 复制 C:/Program Files (x86)/AMD APP SDK/2.9-1/include 中的 CL 文件夹并将其粘贴到单独的位置,例如下载 pyopencl.zip 的目录.
  2. 同时复制 C:/Program Files (x86)/AMD APP SDK/2.9-1/lib 中的 x86_64 文件夹并将其粘贴到与CL 文件夹.
  3. 解压文件夹pyopencl.zip并转到(pyopencl的位置)/src/wrapper
  4. wrapper 文件夹中,打开文件 wrap_cl.hpp.
  5. #include 更改为 #include
  6. 接下来转到您在第一步中复制的 CL 并打开文件 cl_platform.h.再次重复第 5 步.
  7. 接下来在CL文件夹中找到cl_ext.h文件并打开它.再次重复第 5 步.
  8. admin 模式下的cmd 窗口中,进入pyopencl 目录并运行命令python configure.py.这将生成一个 siteconf.py 文件,其中包含一些安装参数.
  9. 打开 siteconf.py 文件并将 CL_INC_DIR = [] 替换为 CL_INC_DIR = [r'(CL 文件夹新位置的路径)'] 并将 CL_LIB_DIR = [] 替换为 CL_LIB_DIR = [r'(x86_64 文件夹新位置的路径)'].
  10. 最后在 cmd 中,从 pyopencl 目录运行 python setup.py install 并享受.
  1. Copy the CL folder inside C:/Program Files (x86)/AMD APP SDK/2.9-1/include and paste it in a separate location such as the directory where you have downloaded pyopencl.zip.
  2. Also copy the x86_64 folder inside C:/Program Files (x86)/AMD APP SDK/2.9-1/lib and paste it in the same directory as the CL folder.
  3. Unzip the folder pyopencl.zip and go to (location of pyopencl)/src/wrapper
  4. Inside the wrapper folder, open the file wrap_cl.hpp.
  5. Change the #include <CL/cl.h> to #include <cl.h>
  6. Next go to the CL that you copied in the first step and open the file cl_platform.h. Repeat step 5 once more.
  7. Next find the cl_ext.h file inside the CL folder and open it. Repeat step 5 again.
  8. Inside a cmd window in admin mode, go to the directory of pyopencl and run the command python configure.py. This will generate a siteconf.py file that will hold some parameters for installation.
  9. Open the siteconf.py file and replace the CL_INC_DIR = [] with CL_INC_DIR = [r'(path to the new location of the CL folder)'] and replace CL_LIB_DIR = [] with CL_LIB_DIR = [r'(path to the new location of the x86_64 folder)'].
  10. Finally in cmd, run python setup.py install from the pyopencl 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) 中安装时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:24