John Kornick
John Kornick

Reputation: 295

Python pyopencl DLL load failed even with latest drivers

I've installed the latest CUDA and driver for my GPU. I'm using Python 2.7.10 on Win7 64bit. I tried installing pyopencl from:

a. the unofficial windows binaries at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl

b. by compiling my own after getting the sources from https://pypi.python.org/pypi/pyopencl

The installation was successful on both cases but I get the same error message once I try to import it:

>>> import pyopencl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pyopencl-2015.1-py2.7-win-amd64.egg\pyope
cl\__init__.py", line 30, in <module>
    import pyopencl._cl as _cl
ImportError: DLL load failed: The specified procedure could not be found.
>>>

I have Visual C++ Redistributable for Visual Studio 2015 installed from https://www.microsoft.com/en-us/download/details.aspx?id=48145 .

I also tried with 2 different versions of the GPU driver (including latest). Same thing. A lot of people seem to get the same error and on some forums I read that by updating the GPU drivers to latest, it works fine. But not for me.

Anyone knows how to fix this?

Upvotes: 9

Views: 7052

Answers (5)

Foad S. Farimani
Foad S. Farimani

Reputation: 14016

I had the same problem here, the way I resolved it was:

  • Make sure you have downloaded and installed the right OpenCL SDK. For example

  • Open the Windows Command Prompt cmd and set the LIB and INCLUDE environment variables. For example

    • Intel:

      • set INCLUDE=C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\include
      • set LIB=C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\lib\x64
    • NVIDIA:

      • set LIB=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\lib\x64
      • set INCLUDE=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include
  • now run pip install pyopencl --no-cache-dir

  • open Python and test import pyopencl

there might be a way to install PyOpenCL via pipwin or by using the --global-option to set the include and library folders. But I haven't succeeded so far.

P.S. The above mentioned NVIDIA OpenCL SDK (i.e., CUDA toolkit) turns out to be very outdated. please don't use it. If you have that installed, please uninstall and install the newer versions.

Upvotes: 1

I had the same problem in my Lenovo yoga 720. It has NVidia Geforce GTX1050 and intel i7 630 CPU/GPU.

I installed a long time ago update drivers and SDK for Nvidia CUDA. But now I what to run python OpenGL and I install intel SDK also. Pip install pyopencl without problems but import pyopengl give me dll load failure.

Solution was to change Windows\system32\opencl.dll to a new one. The old one was NVidia signed (you can see it in properties of file opencl.dll). The new one is Microsoft signed version 2.1.1.0 Khronos OpenCL ICD

I hope this is useful for you. Solution arrived after a long time trying a lot of things... but nothing worked except the new opencl.dll file

Upvotes: 0

Falak Falcon Ahmed
Falak Falcon Ahmed

Reputation: 1

Try both the versions 1.2 and 2.1 I was trying with later and got this issue. Switched the whl and it works but used the Intel GPU. NVidia OpenCL.dll is 2.0 and that is not working still.

Just checked the cl.get_platforms array and found them 0. Intel 1. NVidia

  1. pyopencl.Platform Intel(R) OpenCL & pyopencl.Device Intel(R) Core(TM) ... Intel(R) OpenCL
  2. pyopencl.Platform NVIDIA CUDA & pyopencl.Device Quadro ... NVIDIA CUDA

Upvotes: 0

Venti
Venti

Reputation: 21

I had this same problem and discovered it was caused by AMD OpenCL.dll not having a function introduced in OpenCL 2.1. The Gohlke site only has OpenCL 2.1 and 1.2, while AMD drivers support 2.0.

Because I wanted 2.0, the easy fix was to manually replace the AMD System32/OpenCL.dll with the one from Intel SDK with experimental 2.1 support.

Upvotes: 2

doqtor
doqtor

Reputation: 8484

I'm affraid there isn't one right answer to this problem. Each case is different. It depends on what is installed in the OS. To track down such problems I normally use Dependency Walker.

In this specific case I would open _cl.pyd (usually in C:\Python27\Lib\site-packages\pyopencl) in Dependency Walker to check if there aren't any missing dependencies or if for example OpenCL.dll is actually the one which should be used. OpenCL.dll may be installed by other programs and their path added to PATH. Also OpenCL.dll in System32 may be too old. Basically trial and error renaming all but one OpenCL.dll into OpenCL.dll.bak and/or removing paths from PATH may get you there.

Upvotes: 2

Related Questions