[英]PyOpenCL “fatal error: CL/cl.h: No such file or directory” error during installation in Windows 8 (x64)
After searching a lot for solutions to this problem, I found that this particular error has not been documented properly for Windows. 在仔细搜索了这个问题的解决方案之后,我发现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. 我希望这个解决方案将来会帮助用户解决PyOpenCL安装错误。 Please note that the examples used here are for ATI Radeon GPUs
that supports the AMD OpenCL SDK
SDK. 请注意,此处使用的示例适用于支持AMD OpenCL SDK
SDK的ATI Radeon GPUs
。 For other GPUs
, please refer to their respective parameters and implement them as necessary. 对于其他GPUs
,请参考各自的参数并根据需要实施。 Also do not attempt to install using pip
if the installation fails. 如果安装失败,也不要尝试使用pip
进行安装。 Instead download a zipped copy of pyopencl
from here . 而是从这里下载pyopencl
的压缩副本。
So the error message while installing PyOpenCL is: 所以安装PyOpenCL时的错误信息是:
In file included from src/wrapper/wrap_cl.cpp:1:0: 在src / wrapper / wrap_cl.cpp中包含的文件中:1:0:
src/wrapper/wrap_cl.hpp:27:19: fatal error: CL/cl.h: No Such File or Directory src / wrapper / wrap_cl.hpp:27:19:致命错误:CL / cl.h:没有这样的文件或目录
error: command 'gcc' failed with exit status 1 错误:命令'gcc'失败,退出状态为1
In order to solve this, one must know that the default CL/cl.h is usually stored in: C:/Program Files (x86)/.../include/CL
. 为了解决这个问题,必须知道默认的CL / cl.h通常存储在: C:/Program Files (x86)/.../include/CL
。 But since, (x86) is not identifiable by the gcc
compiler, what you can do is this: 但是,因为(x86)无法通过gcc
编译器识别,你可以做的是:
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
. 复制C:/Program Files (x86)/AMD APP SDK/2.9-1/include
的CL
文件夹并将其粘贴到一个单独的位置,例如您下载pyopencl.zip
的目录。 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. 同时复制C:/Program Files (x86)/AMD APP SDK/2.9-1/lib
的x86_64
文件夹,并将其粘贴到与CL
文件夹相同的目录中。 pyopencl.zip
and go to (location of pyopencl)/src/wrapper
解压缩文件夹pyopencl.zip
并转到(location of pyopencl)/src/wrapper
wrapper
folder, open the file wrap_cl.hpp
. 在wrapper
文件夹中,打开文件wrap_cl.hpp
。 #include <CL/cl.h>
to #include <cl.h>
将#include <CL/cl.h>
更改为#include <cl.h>
CL
that you copied in the first step and open the file cl_platform.h
. 接下来转到您在第一步中复制的CL
并打开文件cl_platform.h
。 Repeat step 5 once more. 再次重复步骤5。 cl_ext.h
file inside the CL
folder and open it. 接下来找到CL
文件夹中的cl_ext.h
文件并将其打开。 Repeat step 5 again. 再次重复步骤5。 cmd
window in admin
mode, go to the directory of pyopencl
and run the command python configure.py
. 在admin
模式下的cmd
窗口内,转到pyopencl
目录并运行命令python configure.py
。 This will generate a siteconf.py
file that will hold some parameters for installation. 这将生成一个siteconf.py
文件,该文件将包含一些安装参数。 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)']
. 打开siteconf.py
文件并将CL_INC_DIR = []
替换为CL_INC_DIR = []
CL_INC_DIR = [r'(path to the new location of the CL folder)']
并用CL_LIB_DIR = [r'(path to the new location of the x86_64 folder)']
替换CL_LIB_DIR = []
CL_LIB_DIR = [r'(path to the new location of the x86_64 folder)']
。 cmd
, run python setup.py install
from the pyopencl
directory and enjoy. 最后在cmd
,从pyopencl
目录运行python setup.py install
并享受。 Hope this solution helps you during the installation of PyOpenCL
in Windows 8 (x64). 希望此解决方案可以帮助您在Windows 8(x64)中安装PyOpenCL
。 Any other suggestions are welcome. 欢迎任何其他建议。
After 2 days of tries and errors I made it. 经过2天的尝试和错误,我做到了。 PyOpenCL is installed. PyOpenCL已安装。 Here is my hardware: 这是我的硬件:
ATI Radeon 7970 with installed Catalyst and most import: INSTALLED AMD APP SDK (2.9.1) ATI Radeon 7970已安装Catalyst且大部分已导入:安装的AMD APP SDK(2.9.1)
Software installed before starting with PyOpenCL: 在使用PyOpenCL开始之前安装的软件:
1. Python 2.7.9 (x86) 1. Python 2.7.9(x86)
2. Numpy (x86) 2. Numpy(x86)
3. pywin32 3. pywin32
4. Visual Studio 2008 4. Visual Studio 2008
5. Mako ( -> easy_install Mako ) 5. Mako( - > easy_install Mako)
6. Boost 6.提升
The most important step according to me is the getting the SITECONF.py file right. 根据我的说法,最重要的一步是获取SITECONF.py文件。 To get it: 为拿到它,为实现它:
Run "python configure.py" in the pyopencl directory to get a sample siteconfig.py. 在pyopencl目录中运行“python configure.py”以获取示例siteconfig.py。
Here is my file after modification. 这是我修改后的文件。 Please note that if you wanna use nVidia, CL_INC_DIR = [] and CL_LIB_DIR = [] are going to be different and perhaps look something like this: 请注意,如果你想使用nVidia,CL_INC_DIR = []和CL_LIB_DIR = []会有所不同,或许看起来像这样:
CL_INC_DIR = [r'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v4.1\\include'] CL_INC_DIR = [r'C:\\ Program Files \\ NVIDIA GPU Computing Toolkit \\ CUDA \\ v4.1 \\ include']
CL_LIB_DIR = [r'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v4.1\\lib\\x64'] CL_LIB_DIR = [r'C:\\ Program Files \\ NVIDIA GPU Computing Toolkit \\ CUDA \\ v4.1 \\ lib \\ x64']
So, my siteconf.py file: 那么,我的siteconf.py文件:
BOOST_INC_DIR = [r'C:\C++ Projects\boost_1_55_0']
BOOST_LIB_DIR = [r'C:\C++ Projects\boost_1_55_0\stage\lib']
BOOST_COMPILER = 'gcc43'
BOOST_PYTHON_LIBNAME = ['boost_python']
USE_SHIPPED_BOOST = True
CL_TRACE = False
CL_ENABLE_GL = True
CL_ENABLE_DEVICE_FISSION = True
CL_INC_DIR = [r'C:\Program Files (x86)\AMD APP SDK\2.9-1\include']
CL_LIB_DIR = [r'C:\Program Files (x86)\AMD APP SDK\2.9-1\lib\x86_64']
CL_LIBNAME = ['OpenCL']
CXXFLAGS = ['/EHsc']
LDFLAGS = ['/FORCE']
You can find many examples online where the Microsoft SDK is also put in CL_INC_DIR = [] and CL_LIB_DIR = [] , however I don't intend to use OpenCL on my i3 processor, so did not build the pyopencl with the MS files. 您可以在线找到许多示例,其中Microsoft SDK也放在CL_INC_DIR = []和CL_LIB_DIR = []中,但是我不打算在我的i3处理器上使用OpenCL,因此没有使用MS文件构建pyopencl。 I hope this was helpful! 我希望这可以帮到你! And the dreamed result: 而梦想的结果是:
>>> import pyopencl as cl >>>将pyopencl导入为cl
>>> >>>
After making changes above, when executing: 在进行上述更改后,执行时:
python setup.py install
I am getting this error: 我收到此错误:
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
What path do I change wrap_helpers.hpp for: 我更改wrap_helpers.hpp的路径是什么:
#include <pybind11.h>
#include <operators.h>
@James, I got the same problem as you did. @James,我遇到了和你一样的问题。 Here is what I' ve done to get throught it. 以下是我为完成它所做的工作。
1. run pip install pybind11
2. add the "PythonInstallPath/include/pybind11" in the right place within
the wrap_helpers.hpp file.
3. go back to pyopencl directory, and run pip setup.py install.
finnally, I got pyopencl. 最后,我得到了pyopencl。 Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.