-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: python setup.py install (_dlib_pybind11: not found error) / pip install dlib (CUDA disabled error) #2979
Comments
Hard to say, but something about your compiler or cuda install is broken. Which is out of control of dlib. Do this to find out more:
and see why that test program fails to build. It's just a trivial cuda program so you have to figure out why your computer is not capable of building it. All dlib's installer is doing is running that test build and if it fails it prints that message about not being able to use cuda. |
Nothing seems to go wrong. PS C:\Users\Eddie\Downloads\dlib-19.24.3> cd dlib/cmake_utils/test_for_cuda/
PS C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda> mkdir build
目录: C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2024/8/3 14:59 build
PS C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda> cd build
PS C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda\build> cmake ..
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.40.33812.0
-- The CXX compiler identification is MSVC 19.40.33812.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:10 (find_package):
Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake
--help-policy CMP0146" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found CUDA: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5 (found suitable version "12.5", minimum required is "7.5")
-- Configuring done (14.5s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/build
PS C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda\build> cmake --build .
适用于 .NET Framework MSBuild 版本 17.10.4+10fbfbf2e
1>Checking Build System
Building NVCC (Device) object CMakeFiles/cuda_test.dir/Debug/cuda_test_generated_cuda_test.cu.obj
cuda_test.cu
cuda_test.cu
tmpxft_00004358_00000000-10_cuda_test.cudafe1.cpp
Building Custom Rule C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/CMakeLi
sts.txt
CMake is re-running because C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/
build/CMakeFiles/generate.stamp is out-of-date.
the file 'C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/build/CMakeFiles
/cuda_test.dir/cuda_test_generated_cuda_test.cu.obj.depend'
is newer than 'C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/build/CMake
Files/generate.stamp.depend'
result='-1'
CMake Warning (dev) at CMakeLists.txt:10 (find_package):
Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake
--help-policy CMP0146" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done (0.3s)
-- Generating done (0.3s)
-- Build files have been written to: C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_
for_cuda/build
cuda_test.vcxproj -> C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda\build\D
ebug\cuda_test.lib
Building Custom Rule C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/CMakeLi
sts.txt
PS C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda\build> |
You didn't run |
The output of PS C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda\build> cmake --build .
适用于 .NET Framework MSBuild 版本 17.10.4+10fbfbf2e
1>Checking Build System
Building NVCC (Device) object CMakeFiles/cuda_test.dir/Debug/cuda_test_generated_cuda_test.cu.obj
cuda_test.cu
cuda_test.cu
tmpxft_00001e98_00000000-10_cuda_test.cudafe1.cpp
Building Custom Rule C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/CMakeLi
sts.txt
cuda_test.vcxproj -> C:\Users\Eddie\Downloads\dlib-19.24.3\dlib\cmake_utils\test_for_cuda\build\D
ebug\cuda_test.lib
Building Custom Rule C:/Users/Eddie/Downloads/dlib-19.24.3/dlib/cmake_utils/test_for_cuda/CMakeLi
sts.txt |
Hard to say what's wrong with your system. But do |
Unfortunately, the same error mentioned occurs. ImportError: DLL load failed while importing _dlib_pybind11 |
I commented on a closed issue of the same thing. I happened to find the fix. I found the fix for this. At least on windows for me.
I am using the latest from below Visual Studio 2022 Install the CUDA toolkit first and reboot. After install the cuDNN. With system variables like these Now in the directory Move all the 12.6 files from If you're using tensorrt as well then you want to extract the zip and move all files and folders to Then you want to copy the file like the stackoverflow says (for me it was this)
Then
You should see
Then
Run the following command from the source directory
and then another output like
A successful build then ends with
After all is said and done Python 3.11.9 (tags/v3.11.9:de54cf5, Apr 2 2024, 10:12:12) [MSC v.1938 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>> print(dlib.DLIB_USE_CUDA)
True |
I highly appreciate your detailed steps! It works! Based on my different combinations of configurations, these steps are crucial after the installation of CUDA and cuDNN:
But actually, I did not do this. I did the following: Firstly, I added the system variable CMAKE_PRIFIX_PATH whose value is "C:/Program Files/NVIDIA/CUDNN/v9.4". Secondly, reboot. Thirdly, run 'python setup.py install' from the source directory. I searched the internet and found that the bizarre error may be related to the upgrade of Nvidia's cuDNN. When users install cuDNN 8.x - 1.x which are provided as zip files, the tutorials existing on the internet tell users to move the files in the Consequently, I think the Tarball installation guide and your suggestions are correct. |
Yeah I am knew to all this and I found out if making the python whl you dont need to do the cmake. But I guess it does not hurt lol |
Warning: this issue has been inactive for 35 days and will be automatically closed on 2024-11-19 if there is no further activity. If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search. |
I had similar problems and couldn't fix them just by moving the files to parent directories. In the end, what worked for me, was importing os and adding CUDA and CUDNN paths to BOTH if 'ON' == 'ON':
import os
os.environ["PATH"] += os.environ["PATH"] + ";" + r"C:\\Program Files\\NVIDIA\\CUDNN\\v9.4\\bin\\12.6" + ";" + r"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.6\\bin"
os.add_dll_directory('C:\\Program Files\\NVIDIA\\CUDNN\\v9.4\\bin\\12.6')
os.add_dll_directory('C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v12.6\\bin') and for anyone struggling with this, you can edit this file in site-packages, example: |
Warning: this issue has been inactive for 35 days and will be automatically closed on 2024-12-25 if there is no further activity. If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search. |
What Operating System(s) are you seeing this problem on?
Windows
dlib version
19.24.0 19.24.1 19.24.2 19.24.3 19.24.4
Python version
3.7 3.8 3.9 3.10 3.11 3.12
Compiler
MSVC 19
Expected Behavior
import dlib
without errorsdlib.DLIB_USE_CUDA
returns TRUECurrent Behavior
Environment
win11
Cmake 3.29.6
CUDA 12.5
cuDNN 9.2
I have tested my CUDA installation in different ways (including testing in PyTorch). The CUDA works fine.
python setup.py install
errorIf I run
python setup.py install
, the terminal says thedlib
is installed successfully. And the terminal logs:However, the dilb is NOT indeed installed successfully.
When I use
import dlib
in a .py file, the terminal showserror: ImportError: DLL load failed while importing _dlib_pybind11: not found
, as is described in #2977pip install dlib --verbose
errorIf I run
pip install dlib --verbose
, the terminal saysCUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA.
However, the dlib is indeed installed.
I can use
import dlib
in a .py file without error. Butdlib.DLIB_USE_CUDA
returnsfalse
.Steps to Reproduce
run
pip install dlib --verbose
or
run
python setup.py install
following http://dlib.net/compile.html
Anything else?
I have tested using Python 3.7/3.8/3.9/3.10/3.11/3.12 and dlib 19.24.0/19.24.1/19.24.2/19.24.3/19.24.4, all these tests come with the same problem.
The text was updated successfully, but these errors were encountered: