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

岁酱吖の 提交于 2019-12-21 20:27:17

问题


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.

So the error message while installing PyOpenCL is:

In file included from src/wrapper/wrap_cl.cpp:1:0:
src/wrapper/wrap_cl.hpp:27:19: fatal error: CL/cl.h: No Such File or Directory
error: command 'gcc' failed with exit status 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. But since, (x86) is not identifiable by the gcc compiler, what you can do is this:

  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.

Hope this solution helps you during the installation of PyOpenCL in Windows 8 (x64). Any other suggestions are welcome.


回答1:


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

>>>




回答2:


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>



回答3:


@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.



来源:https://stackoverflow.com/questions/28568845/pyopencl-fatal-error-cl-cl-h-no-such-file-or-directory-error-during-installa

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