Dlib: DLL load failed for CUDA on Python 3.8 for Windows

Created on 28 Mar 2020  Â·  23Comments  Â·  Source: davisking/dlib

Expected Behavior

>>> import dlib
>>> :)

Current Behavior

>>> import dlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing dlib: The specified module could not be found.
>>> :(

Steps to Reproduce

  1. Install CUDA
  2. Install cuDNN
  3. git clone https://github.com/davisking/dlib.git
  4. python setup.py install
  5. python -c"import dlib"

Because of A change in Python 3.8 for Windows, Python no longer searches for DLLs in directories listed in the PATH environment variable and fails to find curand64_10.dll, this is fixed after running os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))

  • Version: 19.19.99
  • Where did you get dlib: this github repo
  • Platform: Python 3.8 64-bit for Windows 10
bug help wanted

Most helpful comment

Let me see if I can do that in the next few days, I have everything needed to reproduce it anyway.

All 23 comments

Urg, windows dynamic loading is such a mess :(

I'm marking this help wanted because I'm not feeling super motivated to figure out how to fix this right now. So if someone wants to make this work I would much appreciate it.

It seems like the solution is to make CMake/setup.py generate a __init__.py that includes the appropriate os.add_dll_directory() call and then imports everything from the compiled dlib library users currently import.

Let me see if I can do that in the next few days, I have everything needed to reproduce it anyway.

Expected Behavior

>>> import dlib
>>> :)

Current Behavior

>>> import dlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing dlib: The specified module could not be found.
>>> :(

Steps to Reproduce

  1. Install CUDA
  2. Install cuDNN
  3. git clone https://github.com/davisking/dlib.git
  4. python setup.py install
  5. python -c"import dlib"

Because of A change in Python 3.8 for Windows, Python no longer searches for DLLs in directories listed in the PATH environment variable and fails to find curand64_10.dll, this is fixed after running os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))

  • Version: 19.19.99
  • Where did you get dlib: this github repo
  • Platform: Python 3.8 64-bit for Windows 10

I followed the same steps but I'm still getting the error of DLL load failed while importing dlib: The specified module could not be found

Well, clearly I failed to work on this. This seems to be a much bigger change than I expected.
@Mouradost do you have the dlls in your CUDA_PATH?

@cashlo Yes I do since I'm using Tensorflow with the GPU here is my CUDA_PATHs

image

For some reason:

Test1:
1 - Open a terminal
2 - Run the python command
3 - Impor dlib

Result: Causes DLL error

Test2:
1 - Open Terminal
2 - Run the python command
3 - import cv2
4 - import dlib

Result: No error, also, i checked the version! 💯

image

I just pushed a change to how dlib is packaged that should fix this. So pull the latest dlib from github and try installing that version.

For some reason:

Test1:
1 - Open a terminal
2 - Run the python command
3 - Impor dlib

Result: Causes DLL error

Test2:
1 - Open Terminal
2 - Run the python command
3 - import cv2
4 - import dlib

Result: No error, also, i checked the version! 💯

image

I just pushed a change to how dlib is packaged that should fix this. So pull the latest dlib from github and try installing that version.

still getting DLL errors
image

What's in your CUDA_PATH environment variable?

What's in your CUDA_PATH environment variable?

image

@Mouradost That doesn't look like the contents of the CUDA_PATH variable, but PATH or something else. I say this because it would be very surprising if all those c:\windows paths were in CUDA_PATH.

@Mouradost That doesn't look like the contents of the CUDA_PATH variable, but PATH or something else. I say this because it would be very surprising if all those c:\windows paths were in CUDA_PATH.

image
my bad sorry

So whats in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin?

So whats in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin?

These are the files in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
image

I don't see cudnn's .dll file in that list. You need to install cudnn.
Which is curious, since cmake must have found a copy of cudnn somewhere on
your computer based on other things you said.

On Sun, Jun 14, 2020 at 4:08 AM mourad lablack notifications@github.com
wrote:

So whats in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin?
These are the files in C:\Program Files\NVIDIA GPU Computing
Toolkit\CUDA\v10.1\bin
[image: image]
https://user-images.githubusercontent.com/17816194/84588343-2be56e00-ae59-11ea-9146-d744a4594f25.png

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/davisking/dlib/issues/2039#issuecomment-643733806,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABPYFRZH72KFTJVMOR5QMLTRWSAQXANCNFSM4LVOATAQ
.

I don't see cudnn's .dll file in that list. You need to install cudnn. Which is curious, since cmake must have found a copy of cudnn somewhere on your computer based on other things you said.
…
On Sun, Jun 14, 2020 at 4:08 AM mourad lablack @.*> wrote: So whats in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin? These are the files in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin [image: image] https://user-images.githubusercontent.com/17816194/84588343-2be56e00-ae59-11ea-9146-d744a4594f25.png — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#2039 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPYFRZH72KFTJVMOR5QMLTRWSAQXANCNFSM4LVOATAQ .

I have it under a different folder on c:\tools\cuda\bin should I add a copy to the C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin ?

it's working awesome thank you @davisking
I wonder could you guys give away a possibility to specify the path for cudnn if it's not moved to the cuda main folder? or directly grab it from the windows paths? like tensorflow do

Where was it? Oh you noted in your other comment. Really we should make the install process record the location of the copy it found rather than expecting the user to do something special.

@Mouradost I just pushed a change to github that should make this work without needing to assume anything about CUDA_PATH. So try the latest dlib on github.

@Mouradost I just pushed a change to github that should make this work without needing to assume anything about CUDA_PATH. So try the latest dlib on github.

Sure I will give you my feedback thank you for your consideration and your help

Where was it? Oh you noted in your other comment. Really we should make the install process record the location of the copy it found rather than expecting the user to do something special.

I had the habit to create a separate folder in the C:\ called tools and I put my cudnn files there which make it easy to find and change only the cudnn files if I want to use different version on cudnn without touching cuda that's why I thought it will be better to have your library allowing for additional paths.

Expected Behavior

>>> import dlib
>>> :)

Current Behavior

>>> import dlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing dlib: The specified module could not be found.
>>> :(

Steps to Reproduce

1. Install CUDA

2. Install cuDNN

3. `git clone https://github.com/davisking/dlib.git`

4. `python setup.py install`

5. `python -c"import dlib"`

Because of A change in Python 3.8 for Windows, Python no longer searches for DLLs in directories listed in the PATH environment variable and fails to find curand64_10.dll, this is fixed after running os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))

* **Version**: 19.19.99

* **Where did you get dlib**: this github repo

* **Platform**: Python 3.8 64-bit for Windows 10

I had a situation that dlib crashed when I did import it, in general I did the following. I changed setup.py and set it to compile Debug, but with Release it didn't work on Win 7 x 4 Py 3.7.

link on setup_for Debug compile
https://drive.google.com/file/d/1Wfy9ou3yYce4wqywY22jPxC9IkN6_Dch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

srikanthreddybethi picture srikanthreddybethi  Â·  4Comments

abhisheksoni27 picture abhisheksoni27  Â·  4Comments

maromcik picture maromcik  Â·  4Comments

alison-carrera-pegasus picture alison-carrera-pegasus  Â·  3Comments

lvella picture lvella  Â·  4Comments