I am trying to use PyOpenCL for the first time on Windows 10 (64 bit) to accelerate some code using my GPU. When trying to import pyopencl I get the error:
File "C:\Users\me\Anaconda3\lib\site-packages\pyopencl\__init__.py", line 39, in <module>
import pyopencl._cl as _cl
ImportError: DLL load failed: The specified module could not be found."
I am using Python 3.6.8 and have the pyopencl 2018.2.5+cl21 package installed.
I have also just installed the latest CUDA toolkit cuda.10.1.105 and Visual Studio as recommended during the CUDA toolkit installation.
The OpenCl.dll file in the Windows\system32 folder, is the 2.2.1.0 file version. I checked this by going into Computer Management clicking on my Nvidia GeForce GTX 1050 display adaptor.
From other post recommednations, I have tried substituting the OpenCl.dll file by others found in my system (see photo) without results. I have then reverted to the original file located in that folder.
Image for search results of 'OpenCl.dll'
I have also downloaded from and installed pyopencl‑2018.2.5+cl21‑cp36‑cp36m‑win_amd64.whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopencl, without success. The error keeps popping up.
I am completely new to OpenCL, CUDA etc. Please forgive me if the error is easy to solve. Thank you for your help and please let me know if you need any other information.
Related
I have a MacBook Pro with M1 Max processor, macOS 12.4. I was following the Pytorch tutorial for their library torchrec (CPU only). When I try to import the library torchrec I am prompt with the following error
OSError: dlopen(/opt/homebrew/Caskroom/miniforge/base/envs/dlrm_env2/lib/python3.10/site-packages/fbgemm_gpu/
fbgemm_gpu_py.so, 0x0006): tried: '/opt/homebrew/Caskroom/miniforge/base/envs/
dlrm_env2/lib/python3.10/site-packages/fbgemm_gpu/fbgemm_gpu_py.so' (not a mach-o file)
Any suggestion in how to solve it? I tried to create a new environment and install again the library but still I am prompt with the same error.
I am able to successfully install Dlib with CUDA support in Windows 10 but getting an error during "import dlib" in my python code of computer vision project.
Environment: Windows 10, Python 3.7.6 (Anaconda), CUDA 11, CuDNN 10.2
Error Message:
>>> import dlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\dlib-19.20.99-py3.7-win-amd64.egg\dlib\__init__.py", line 12, in <module>
from _dlib_pybind11 import *
ImportError: DLL load failed: The specified module could not be found.
This can be solved by copying the cudnn64_7.dll (available here: https://developer.nvidia.com/cudnn)
into the %CUDA_PATH%/bin directory (probably something like this: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin)
I am able to find and fix this issue. CUDA 11 installation wasn't able to add few of the directories into the PATH environment variable (Windows 10). It was truncated due to the max length of 2048 characters. I have removed a few of the unused software paths from PATH value and after reinstallation, dlib 19.20 is working with CUDA 11 now.
I created an issue on DLIB Github under the following link which has more information regarding error logs and snapshots for this issue.
https://github.com/davisking/dlib/issues/2097
In my environment, the problem was due to an error somewhere in the build process that resulted code to load CuDNN dynamic libraries not being included in the generated file dlib/__init__.py despite having no build error. In my case the file always included this strange block of code:
if 'OFF' == 'ON':
add_lib_to_dll_path('cudnn-NOTFOUND')
add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5/lib/x64/cudart.lib')
The second line's cudnn-NOTFOUND gave a clue of what happened with my build.
As I followed instructions on this page, copying all the binaries and include files to the right places within the CUDA directory, I only needed to modify the code to (similar to what Epic Chen's answer suggests but I got rid of the if clause and the bad code line):
add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.5/lib/x64/cudart.lib')
That workaround fixed the problem for me.
My configuration is CUDA 11.5, CuDNN 8.3.1.22, dlib compiled using Visual Studio 2019. The environment variable CMAKE_PREFIX_PATH to the CuDNN directory to get the compiler to find the include files and libraries.
If you are using Anaconda, uninstall dlib and reinstall dlib.
In anaconda command prompt, type
pip uninstall dlib
After successfully uninstalling, type
pip install dlib
It helped me fix the problem.
Try to check the __init__.py file which the error message indicate as below.
Your path is not the same as me.
In the __init__.py file, the if statement should be 'ON' == 'ON'
Besides, the following library paths must be correct. Your version may not be the same as me.
I am currently trying to install OpenCV on my Windows 10 pc using these documentations: https://pysource.com/2019/03/15/how-to-install-python-3-and-opencv-4-on-windows/
python pip -m install opencv_python‑4.0.1+contrib‑cp37‑cp37m‑win_amd64.whl
https://solarianprogrammer.com/2016/09/17/install-opencv-3-with-python-3-on-windows/
python pip -m install opencv_python‑4.0.1+contrib‑cp37‑cp36m‑win_amd64.whl
Both documentations installed everything just fine but every time I am trying to execute the command
python
import cv2
I get the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: module not found.
I searched for this error and found different approaches, for example reinstalling it manually via this site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
But it didn't help. Also I checked for the python dll but it is in my current folder. Updating the environment settings didn't help as well.
I found then something about the Visual C++ Redistributables to be updated, but before installing something out of the blue, I'd like to know if that really might be the problem and where to download the redistributables to as I am not working with visual studio just the cmd command prompt.
Also I found something about deinstalling python3 and installing python2.7 instead. Would that really be necessary?
This problem occured due to different reasons, mentioned in other stackoverflow posts.
Through
this post I checked my windows 10 version, found out that it was Windows 10 Pro N and the media package was missing. So I installed it and activated it.
But the dll problem still occured. Further search and I found
this post.
Again I checkd in my program list and downloaded the Visual C++ 2015 redistribution package.
After a few restarts and further windows updates it finally worked.
Thanks to everyone for their help!
Im trying to access and interact with a website using selenium and the chrome driver. I downloaded the chrome driver from here,
specifically I downloaded version 2.45 and the linux64 version because I'm on raspberry pi. I also installed geckodriver the arm version for linux. I unzipped both of these files and moved them to my /usr/bin folder because that is where my python 3 path is. Here is my code:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.google.com")
I run this code and the error message I get is
Traceback (most recent call last):
File "/home/pi/test with selenium.py", line 2, in <module>
driver = webdriver.Chrome()
File "/home/pi/.local/lib/python3.5/site-
packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/home/pi/.local/lib/python3.5/site-
packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
I checked to make sure chromedriver is an executable file and it is, I know this from looking under properties and permissions and it says anyone can execute the file. I tried installing homebrew (I'm not sure if I did it right) and running brew install chromedriver, still didn't work. Another solution I read online thought I had the wrong chromedriver file for my operation system, but I am pretty sure I do. This is my first time using selenium, so hopefully, I'm not doing it completely wrong. Any help is appreciated!
I finally managed to get chromedriver to work on raspberry pi! The first thing I was doing wrong was using the latest version of chromedriver (version 2.45) which only works for Chrome versions 70-72. Currently (December 2018) the highest version of Chromium (open source Chrome) available on raspberry pi is 65 (source). So that meant that chromedriver versions 2.36 - 2.38 SHOULD work, yet they didn't. Why they still gave me that OS Error, I still don't understand. However I found a useful reddit post (yes, reddit) which I will link here. Basically, instead of downloading chromedriver from their offical website I needed to download it from here. This website has chromedriver for arm, rather than just linux 64 bit. So I clicked on chromedriver 65 in armhf (updates), and downloaded the .deb file seen on the right side of the page. Then I opened it by double clicking and my raspberry pi unzipped the .deb file and gave me a file named chromedriver located in /usr/lib/chromium-browser. I ran
sudo mv /usr/lib/chromium-browser/chromedriver /usr/bin in terminal to move the chromedriver file to my python directory. Now this piece of selenium code worked perfectly in python and on raspberry pi:
from selenium import webdriver
driver = webdriver.Chrome()
Again, I wouldn't have solved this without the helpful reddit post I will link again here. All of the steps I described above are described in the reddit post, I'm just trying to get the word out!
This error message...
OSError: [Errno 8] Exec format error
...implies that the ChromeDriver binary which was invoked was not in proper format.
Your main issue is the incompatibility of the ChromeDriver binary format with respect to the underlying Operating System.
As you are on linux64 bit version on Raspberry Pi you need to download chromedriver_linux64.tar.gz from chromedriver.storage.googleapis.com, untar it and provide the absolute path of the GeckoDriver through the argument executable_path as follows:
from selenium import webdriver
browser= webdriver.Chrome(executable_path='/path/to/chromedriver')
Additional Consideration
Perform the additional clean up tasks:
ChromeDriver is present in the specified location.
ChromeDriver is having executable permission for non-root users.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
(WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
(LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
Take a System Reboot.
Execute your Test as a non-root user.
Google's chromedriver_linux64.zip contains an amd64/x86-64 binary only, which is the root issue here.
For Raspberry Pi users: Pre-built ARM64 linux chromedriver binaries that will work on Raspberry Pi and others are available in most Electron releases. Hopefully this helps.
I took a driver from one of my old projects.
And I was getting the same error.
It turns out that I was trying to run windows chrome driver in Linux.
Dumb me!
I'm making a program using Python2.7 and Kivy1.9.2-dev, and trying to package it with PyInstaller-3.0 for different systems as a single executable.
The systems I'm trying to package it for are these:
64-bit Linux Mint 17.3
32-bit Linux Mint 17 (also tried while upgrading to 17.1 and 17.3)
32-bit Windows XP SP3
Raspbian (Raspberry Pi)
On all these systems the program is working well when just run with Python, uncompiled. (so, all Kivy dependencies are fine, too).
However, out of the executables made with PyInstaller, only the one made on 64-bit Linux works as one file. The Windows and Raspbian executables mostly work (I'll write about it later), but the one made on 32-bit Linux still doesn't run. It gives the following error when run (I tried running it on both 32 and 64-bit Linux):
Traceback (most recent call last):
File "<string>", line 11, in <module>
File "/media/Data/Programming/Python/installers/PyInstaller-3.0/PyInstaller/loader/pyimod03_importers.py", line 363, in load_module
exec(bytecode, module.__dict__)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 48, in <module>
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/extern/__init__.py", line 60, in load_module
ImportError: The 'six' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
pyi_rth_pkgres returned -1
Here's what I'm confused about:
Inside my "/usr/local/lib/python2.7/dist-packages/" there is no "pkg_resources" folder, but the above indicates that it, apparently, is there... It even reads the files there successfully. Is it something that gets created just when the executable starts?
I don't specifically use "six" for anything, before this error I didn't even know it existed.
"Six" IS installed on my system, as confirmed by the Package Manager and by Pip. It's located in "/usr/local/lib/python2.7/dist-packages/". I guess PyInstaller can't find it for some reason (as, I believe, if everything is packaged correctly it doesn't have to be there on the system where the executable is run.)
So, my question is pretty typical, what may cause this problem for PyInstaller (just in case, I DID run the "setup.py install" for it), and how to get around/fix it?
Thanks!
PS: On a side note, I mentioned the problems with Windows and Raspbian executables. On Windows, the exe only runs when there is "zlib1.dll" present in the same folder (even if specifically packaged into the exe with PyInstaller, it doesn't work), and on Raspbian I only got the program working without using "--onefile" (with "--onefile", it seems PyInstaller doesn't package any Python binaries into the executable, like libpython.2.7.so, and maybe others too)
Well, adding 'six' into hidden packages, as Clement suggested, didn't work, but started a sequence of trial-and-error that finally led to a solution.
After the test with "hiddenimports" didn't work I tried just importing 'six' into my Python code. And the compiled executable no longer showed this error! However, it now said that the package named 'packaging' is required... Which I didn't have installed.
To put it short, starting from the initial problem, I did this:
Installed 'packaging' using 'pip':
sudo pip install packaging
Added these imports into my main Python code:
import six
import packaging
import packaging.version
import packaging.specifiers
(all the imports added were trial-and-error, done until the PyInstaller-made executable finally worked).
Seems a bit hack-y, as making the executable for a 64-bit Linux didn't require any of these imports, but at least it now works, and the executable size is basically unaffected.
For the following setup (anaconda):
PyInstaller: 3.2
Python: 3.5.2
Platform: Windows-10-10.0.10240-SP0
Numpy: 1.11.1
And the following mwe.py:
import numpy
print ("hello world")
I had to do the following to fix:
pip install packaging
Build with the following bat file (^ is the BAT line continuation):
pyinstaller --noconfirm ^
--hidden-import six ^
--hidden-import packaging ^
--hidden-import packaging.version ^
--hidden-import packaging.specifiers ^
--hidden-import packaging.requirements ^
mwe.py
I had a similar problem. Try to add "six" as well as "kivy" to the hidden_packages in your spec file. If it doesn't work, make sure that setuptools is installed in its 19.2 version. It seemed to be the problem for me on Windows. Hope it helps.