Installing PyOpenCL on Windows using Intel's SDK and pip

允我心安 提交于 2020-06-17 09:07:09

问题


Following these instructions, I have downloaded and installed Intel's OpenCL™ SDK (Intel® System Studio) from here. The cl.h file is in the folder

C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\include\CL

however when running

pip install pyopencl

I get the long error message of

  Building wheel for pyopencl (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\python38\python.exe' 'c:\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\fsfar\AppData\Local\Temp\tmpsufv5353'
       cwd: C:\Users\fsfar\AppData\Local\Temp\pip-install-cthadcch\pyopencl
  Complete output (95 lines):
  ---------------------------------------------------------------------------
  Mako is not installed.
  ---------------------------------------------------------------------------
  That is not a problem, as most of PyOpenCL will be just fine
  without it. Some higher-level parts of pyopencl (such as
  pyopencl.reduction) will not function without the templating engine
  Mako [1] being installed. If you would like this functionality to
  work, you might want to install Mako after you finish
  installing PyOpenCL.

  Simply type
  python -m pip install mako
  either now or after the installation completes to fix this.

  [1] http://www.makotemplates.org/
  ---------------------------------------------------------------------------
  Hit Ctrl-C now if you'd like to think about the situation.
  ---------------------------------------------------------------------------
  Continuing in 1 seconds...
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.8
  creating build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\algorithm.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\array.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\bitonic_sort.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\bitonic_sort_templates.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\cache.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\capture_call.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\clmath.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\clrandom.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\cltypes.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\elementwise.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\invoker.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\ipython_ext.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\reduction.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\scan.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\tools.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\version.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\_buffers.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\_cluda.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\_mymako.py -> build\lib.win-amd64-3.8\pyopencl
  copying pyopencl\__init__.py -> build\lib.win-amd64-3.8\pyopencl
  creating build\lib.win-amd64-3.8\pyopencl\characterize
  copying pyopencl\characterize\performance.py -> build\lib.win-amd64-3.8\pyopencl\characterize
  copying pyopencl\characterize\__init__.py -> build\lib.win-amd64-3.8\pyopencl\characterize
  creating build\lib.win-amd64-3.8\pyopencl\compyte
  copying pyopencl\compyte\array.py -> build\lib.win-amd64-3.8\pyopencl\compyte
  copying pyopencl\compyte\dtypes.py -> build\lib.win-amd64-3.8\pyopencl\compyte
  copying pyopencl\compyte\__init__.py -> build\lib.win-amd64-3.8\pyopencl\compyte
  creating build\lib.win-amd64-3.8\pyopencl\compyte\ndarray
  copying pyopencl\compyte\ndarray\gen_elemwise.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray
  copying pyopencl\compyte\ndarray\gen_reduction.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray
  copying pyopencl\compyte\ndarray\setup_opencl.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray
  copying pyopencl\compyte\ndarray\test_gpu_elemwise.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray
  copying pyopencl\compyte\ndarray\test_gpu_ndarray.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray
  copying pyopencl\compyte\ndarray\__init__.py -> build\lib.win-amd64-3.8\pyopencl\compyte\ndarray
  running egg_info
  writing pyopencl.egg-info\PKG-INFO
  writing dependency_links to pyopencl.egg-info\dependency_links.txt
  writing requirements to pyopencl.egg-info\requires.txt
  writing top-level names to pyopencl.egg-info\top_level.txt
  reading manifest file 'pyopencl.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '*.h'
  warning: no files found matching 'doc\_static\*.css'
  warning: no files found matching 'doc\_templates\*.html'
  warning: no files found matching '*.py.in'
  writing manifest file 'pyopencl.egg-info\SOURCES.txt'
  creating build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-airy.cl -> build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-bessel-j-complex.cl -> build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-bessel-j.cl -> build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-bessel-y.cl -> build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-complex.h -> build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-eval-tbl.cl -> build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-hankel-complex.cl -> build\lib.win-amd64-3.8\pyopencl\cl
  copying pyopencl\cl\pyopencl-ranluxcl.cl -> build\lib.win-amd64-3.8\pyopencl\cl
  creating build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123
  copying pyopencl\cl\pyopencl-random123\array.h -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123
  copying pyopencl\cl\pyopencl-random123\openclfeatures.h -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123
  copying pyopencl\cl\pyopencl-random123\philox.cl -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123
  copying pyopencl\cl\pyopencl-random123\threefry.cl -> build\lib.win-amd64-3.8\pyopencl\cl\pyopencl-random123
  running build_ext
  building 'pyopencl._cl' extension
  creating build\temp.win-amd64-3.8
  creating build\temp.win-amd64-3.8\Release
  creating build\temp.win-amd64-3.8\Release\src
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYGPU_PACKAGE=pyopencl -DPYGPU_PYOPENCL=1 -Ipybind11/include -IC:\Users\fsfar\AppData\Local\Temp\pip-build-env-gqyddbnz\overlay\Lib\site-packages\pybind11\include -IC:\Users\fsfar\AppData\Local\Temp\pip-build-env-gqyddbnz\overlay\Lib\site-packages\pybind11\include -IC:\Users\fsfar\AppData\Local\Temp\pip-build-env-gqyddbnz\overlay\Lib\site-packages\numpy\core\include -Ic:\python38\include -Ic:\python38\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /EHsc /Tpsrc/wrap_constants.cpp /Fobuild\temp.win-amd64-3.8\Release\src/wrap_constants.obj -fvisibility=hidden /EHsc /DVERSION_INFO=\"2020.1\"
  cl : Command line warning D9002 : ignoring unknown option '-fvisibility=hidden'
  wrap_constants.cpp
  c:\users\fsfar\appdata\local\temp\pip-install-cthadcch\pyopencl\src\wrap_cl.hpp(57): fatal error C1083: Cannot open include file: 'CL/cl.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
  ----------------------------------------
  ERROR: Failed building wheel for pyopencl
Failed to build pyopencl
ERROR: Could not build wheels for pyopencl which use PEP 517 and cannot be installed directly

P.S.1. A semi-relevant issue also posted here.

P.S.2. According to this and this posts, there should be a siteconf.py file where I can specify the environment variables such as CL_INC_DIR and CL_LIB_DIR. However, I can't find the said file on my hard drive and I'm not sure if one can change the environment variables while using the pip package manager. I tried the

set CL_INC_DIR = [r'C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\include']

in cmd with no avail.

P.S.3. I tried installing with pipwin:

pip install pipwin
pipwin install pyopencl

but when running import pyopencl in python I get the error message of

c:\python38\lib\site-packages\pyopencl\__init__.py in <module>
     37 
     38 try:
---> 39     import pyopencl._cl as _cl
     40 except ImportError:
     41     import os

ImportError: DLL load failed while importing _cl: The specified procedure could not be found.

P.S.4. I tried following the instructions here, but the command

pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy

returns

Looking in indexes: https://pypi.anaconda.org/carlkl/simple
ERROR: Could not find a version that satisfies the requirement mingwpy (from versions: none)
ERROR: No matching distribution found for mingwpy

回答1:


Few years back I experienced similar problem on Ubuntu and below helped me:

pip install --global-option=build_ext --global-option="-I/opt/AMDAPPSDK-3.0/include" --global-option="-L/opt/AMDAPPSDK-3.0/lib/x86_64" pyopencl

Of course the paths will need to be adjusted to your case. If it's still not working try to change paths to use forward slashes like on Unix/Linux - sometimes that is necessary despite being on Windows.

Alternatively you may want to use whl file which is already precompiled. For example here are some: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl

Then to install just do: python -m pip install <pyopencl_package.whl>




回答2:


I went through this exact issue this morning. I was finally able to get it work by following the instructions here: http://www.minho-kim.com/courses/17sp43.635/pyopencl.html.



来源:https://stackoverflow.com/questions/62179484/installing-pyopencl-on-windows-using-intels-sdk-and-pip

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