4

I'm on Windows 10 running python 3.5.4 through Anaconda with pyopencl 2017.2 from conda-forge, installed through Anaconda. My system is an i5 4670K with an R9 290 running driver version 17.11.1 with OpenCL Version 23.20.788.0.

When trying to import the pyopencl module I experience the following error

    >>> import pyopencl as cl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[my home folder]\Anaconda3\lib\site-packages\pyopencl\__init__.py", line 37, in <module>
    import pyopencl.cffi_cl as _cl
  File "[my home folder]\Anaconda3\lib\site-packages\pyopencl\cffi_cl.py", line 39, in <module>
    from pyopencl._cffi import ffi as _ffi
ImportError: DLL load failed: The specified module could not be found.

The error appears to occur when loading _cffi.pyd. This error has similarities with problems shown in previous threads:

Python pyopencl Import Error

cffi load failure when trying to import PyOpenCL

pyopencl import error cffi.so undefined symbol

However, in spite of the installation completing (seemingly) without error, me installing the OCL SDK:s from both AMD and Intel the problem persists. I also updated my grahics card drivers.

I tried using Dependency Walker to check dependencies of _cffi.pyd, as described in the following thread:

Python pyopencl DLL load failed even with latest drivers

This did turn up a lot of circular dependencies and missing dependencies under opencl.dll with names beginning in API-MS-WIN and EXT-MS-WIN. The dependency errors persisted when renaming the opencl.dll in /System32 and using the one in \Anaconda3\Library\bin instead.

Doing a bit of searching I found this thread:

Dependency Walker: missing dlls

which basically says the missing dependencies are nothing to worry about.

Bazooka
  • 51
  • 1
  • 5

3 Answers3

3

I was also having this problem and my research led me to this document that helped install a compatible version: https://media.readthedocs.org/pdf/mot/master/mot.pdf

The error is because you do not have a compatible version of pyopencl and opencl driver for AMD or Intel.

Quote:

Installing a precompiled binary wheel (.whl) is the easiest way to install PyOpenCL, but only works if the wheel is compiled for your specific Python implementation. At Christoph Gohlke website (http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl) you can find a range of PyOpenCL binary packages. If there is a compatible one for your system, download that version. You can see if it is compatible if the Python version and OpenCl version in the binary name matches that of your installed Python and driver supported versions. Note that many drivers, such as nVIDIA’s only support OpenCL 1.2, so in that case take the wheel with “+cl12” in the name, and not e.g. “+cl21”. For example if you have 64-bit Windows system with Python 3.5 and your GPU or CPU drivers support OpenCL 1.2 you need to download the wheel with “+cl12”, win-amd64 and cp35m in the name (note the format, cp<version>m, the m is important). (To check which Python version you have you can run python --version in the command line).

This should help you

Medhavi Monish
  • 329
  • 2
  • 8
0

I was having the same issue on my Intel HD Graphics 4400 GPU. It worked before (I can't remember exactly how I got it to work earlier). At some point I got the exact same pyopencl import error as Asker described.

After some trying I installed the Intel OpenCL driver from here: https://software.intel.com/en-us/articles/opencl-drivers. During installation it showed that my regular Intel HD 4400 driver needed to be uninstalled first, which the installation tool did for me. Then the OpenCL driver got installed, and I could use OpenCL on my GPU again. My theory: probably, my setup got corrupted during a Windows update which sometimes tends to update device drivers as well.

biertje72
  • 95
  • 7
0

Download the opencl.dll file from google.

Go to the location where the pyopencl library is installed, specifically where the tools.py is, and paste the DLL file there.

This fixed the error for me.

Aymendps
  • 1,346
  • 4
  • 20
lewis
  • 1