PyOpenCL “fatal error: CL/cl.h: No such file or directory” error during installation in Windows 8 (x64)

此生再无相见时 提交于 2019-12-04 14:41:13

After 2 days of tries and errors I made it. PyOpenCL is installed. Here is my hardware:

ATI Radeon 7970 with installed Catalyst and most import: INSTALLED AMD APP SDK (2.9.1)

Software installed before starting with PyOpenCL:

1. Python 2.7.9 (x86)

2. Numpy (x86)

3. pywin32

4. Visual Studio 2008

5. Mako ( -> easy_install Mako )

6. Boost

The most important step according to me is the getting the SITECONF.py file right. To get it:

Run "python configure.py" in the pyopencl directory to get a sample 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:

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']

So, my siteconf.py file:

  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. I hope this was helpful! And the dreamed result:

>>> import pyopencl as 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:

#include <pybind11.h>
#include <operators.h>

@James, I got the same problem as you did. 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. Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!