Skip to content

Instantly share code, notes, and snippets.

@nguyenhoan1988
Created October 19, 2021 22:05
Show Gist options
  • Save nguyenhoan1988/ed92d58054b985a1b45a521fcf8fa781 to your computer and use it in GitHub Desktop.
Save nguyenhoan1988/ed92d58054b985a1b45a521fcf8fa781 to your computer and use it in GitHub Desktop.
Installing dlib using conda with CUDA enabled

Installing dlib using conda with CUDA enabled

Prerequisite: conda and/or miniconda are already installed

  1. Create a conda environment.
$ conda create -n dlib python=3.8 cmake ipython
  1. Activate the environment.
$ conda activate dlib
  1. Install CUDA and cuDNN with conda using nvidia channel
$ conda install cuda cudnn -c nvidia

Then find the path to the nvcc of this environment. We will use this path for the build step below

$which nvcc
/path/to/your/miniconda3/envs/dlib/bin/
  1. Install dlib. Clone and build dlib from source
$ git clone https://github.com/davisking/dlib.git
$ cd dlib
$ mkdir build
$ cd build
$ cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 -DCUDAToolkit_ROOT=/path/to/your/miniconda3/envs/dlib/bin/
$ cmake --build .
$ cd ..
$ python setup.py install --set DLIB_USE_CUDA=1
  1. Test dlib
(dlib) $ ipython
Python 3.8.12 (default, Oct 12 2021, 13:49:34)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.27.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import dlib

In [2]: dlib.DLIB_USE_CUDA
Out[2]: True

In [3]: print(dlib.cuda.get_num_devices())
1
@sashavor
Copy link

sashavor commented Sep 14, 2022

Is there specific cuda toolkit version that works with dlib? I can't manage to get it to run:

cnn_face_detector = dlib.cnn_face_detection_model_v1('dlib_models/mmod_human_face_detector.dat')
RuntimeError: Error while calling cudaMallocHost(&data, new_size*sizeof(float)) in ./dlib/dlib/cuda/gpu_data.cpp:211. code: 222, reason: the provided PTX was compiled with an unsupported toolchain.

@Amr-YA
Copy link

Amr-YA commented Sep 20, 2022

Surprisingly, this the only way it worked.
Although it froze still while building a sample cuda project and didn't continue till I pressed "space", no idea why or how but it worked.

@sherelynyap
Copy link

helped me a lot, thanks!

@brianholland
Copy link

brianholland commented Oct 12, 2022

Many thanks! Now I'm off to the next glitch:

Same problem, I think, as @sashavor :

dlib '19.24.99', face_recognition_models '0.1.0'
Ubuntu 20.04, python 3.10

import face_recognition_models
import dlib
cnn_face_detection_model = face_recognition_models.cnn_face_detector_model_location()
cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)

I get

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In [1], line 4
     2 import dlib
     3 cnn_face_detection_model = face_recognition_models.cnn_face_detector_model_location()
----> 4 cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)

RuntimeError: Error while calling cudaMallocHost(&data, new_size*sizeof(float)) in file /home/brian/dlib/dlib/cuda/gpu_data.cpp:211. code: 222, reason: the provided PTX was compiled with an unsupported toolchain.

@EylonSho
Copy link

Many thanks! Now I'm off to the next glitch:

Same problem, I think, as @sashavor :

dlib '19.24.99', face_recognition_models '0.1.0' Ubuntu 20.04, python 3.10

import face_recognition_models
import dlib
cnn_face_detection_model = face_recognition_models.cnn_face_detector_model_location()
cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)

I get

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In [1], line 4
     2 import dlib
     3 cnn_face_detection_model = face_recognition_models.cnn_face_detector_model_location()
----> 4 cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)

RuntimeError: Error while calling cudaMallocHost(&data, new_size*sizeof(float)) in file /home/brian/dlib/dlib/cuda/gpu_data.cpp:211. code: 222, reason: the provided PTX was compiled with an unsupported toolchain.

Any suggestion for this issue please?

@gipinze
Copy link

gipinze commented Dec 28, 2022

Hi,

Thanks for your explanation, I used it, mixing it with some other I found around internet to make a new one that worked for me

I used my device CUDA,=11.5 and Cudnn=8.3 and runs in Anaconda with python=3.8 as well

The biggest differences is that, I guess due to the time you uploaded this, with VS 2022 is not possible to compile DLIB, so we need to specify the version and not use the GIF_SUPPORT library

Thanks again for your clear explanation

@deerwinter
Copy link

for windows user who met the
import dlib Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\oceanx\AppData\Local\Programs\Python\Python310\lib\site-packages\dlib-19.24.99-py3.10-win-amd64.egg\dlib\__init__.py", line 19, in <module> from _dlib_pybind11 import * ImportError: DLL load failed while importing _dlib_pybind11: The specified module could not be found.
check your __init__.py , make sure its "on"=="on".

@ankit-g
Copy link

ankit-g commented May 2, 2023

I'm getting this error:

Could not load library libcudnn_cnn_train.so.8. Error: /home/ankit/anaconda3/envs/dlib/bin/../lib/libcudnn_ops_train.so.8: undefined symbol: _Z22cudnnGenericOpTensorNdILi3EE13cudnnStatus_tP12cudnnContext16cudnnGenericOp_t21cudnnNanPropagation_tPKdPKvPK17cudnnTensorStructS8_S8_SB_S8_S8_SB_Pv, version libcudnn_ops_infer.so.8

@mtalhaubaid
Copy link

mtalhaubaid commented Jun 13, 2023

I got this message after installing.

Installed c:\users\asdf\anaconda3\envs\dlib\lib\site-packages\dlib-19.24.99-py3.8-win-amd64.egg
Processing dependencies for dlib==19.24.99
Finished processing dependencies for dlib==19.24.99

But when try to test dlib it gives this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ASDF\anaconda3\envs\dlib\lib\site-packages\dlib-19.24.99-py3.8-win-amd64.egg\dlib\__init__.py", line 19, in <module>
    from _dlib_pybind11 import *
ImportError: DLL load failed while importing _dlib_pybind11: The specified module could not be found.
>>> import dlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ASDF\anaconda3\envs\dlib\lib\site-packages\dlib-19.24.99-py3.8-win-amd64.egg\dlib\__init__.py", line 19, in <module>
    from _dlib_pybind11 import *
ImportError: DLL load failed while importing _dlib_pybind11: The specified module could not be found.
>>> import dlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ASDF\anaconda3\envs\dlib\lib\site-packages\dlib-19.24.99-py3.8-win-amd64.egg\dlib\__init__.py", line 19, in <module>
    from _dlib_pybind11 import *
ImportError: DLL load failed while importing _dlib_pybind11: The specified module could not be found.

@DUDUKorte
Copy link

getting this error:

Could not load library libcudnn_cnn_train.so.8. Error: /home/ankit/anaconda3/envs/dlib/bin/../lib/libcudnn_ops_train.so.8: undefined symbol: _Z22cudnnGenericOpTensorNdILi3EE13cudnnStatus_tP12cudnnContext16cudnnGenericOp_t21cudnnNanPropagation_tPKdPKvPK17cudnnTensorStructS8_S8_SB_S8_S8

i got the exactly same error, anyone knows how to fix it???

@bwajster
Copy link

Does this work on Ubuntu 18.04? Also, can you share the link to install conda?

@mtalhaubaid
Copy link

@bwajster97 I think It should work on ubuntu as well

@lingster
Copy link

lingster commented Feb 8, 2024

if you are running on arch linux and you are getting these errors try temporarily downgrading your cc/gcc compilers like this:

export CXX="/usr/bin/g++-12"
export CC="/usr/bin/gcc-12"

or wherever the correct path you have installed the previous versions of the compiler.

@s2485523800
Copy link

Thanks a lot.
maybe somebody installed cudnn but dlib said not found, you can use " set CMAKE_PREFIX_PATH=path/to/cudnn"( in conda is /Library) to fix this problem

@s2485523800
Copy link

Hi @s2485523800, I am facing this issue, unfortunately, I am not able to set CMAKE_PREFIX_PATH correctly. Could you please help?

maybe you can take a photo about your conda env path,and conda list

@semajbaker
Copy link

thanks. Worked for me too

@giampierobartolomei
Copy link

giampierobartolomei commented Sep 23, 2024

Hi, i followed this tutorial without doing any other installation and it works. Now I need to install PyQt5 library but when i run conda install pyqt=5 (I tried also with -c nvidia, -c conda-forge) it appears this:

`Channels:

  • defaults
  • conda-forge
  • nvidia
    Platform: linux-64
    Collecting package metadata (repodata.json): done
    Solving environment: failed

InvalidSpec: The package "nvidia/linux-64::cuda-compiler==12.6.0=0" is not available for the specified platform
`
I would avoid using pip, because i prefer install all libraries from conda, so what can i do?

this is the conda list:
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
asttokens 2.4.1 pyhd8ed1ab_0 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
bzip2 1.0.8 h4bc722e_7 conda-forge
c-ares 1.33.1 heb4867d_0 conda-forge
ca-certificates 2024.8.30 hbcca054_0 conda-forge
cmake 3.30.3 hf9cb763_0 conda-forge
cuda 12.4.1 0 nvidia
cuda-cccl 12.4.127 0 nvidia
cuda-command-line-tools 12.4.1 0 nvidia
cuda-compiler 12.6.0 0 nvidia
cuda-cudart 12.4.127 0 nvidia
cuda-cudart-dev 12.4.127 0 nvidia
cuda-cudart-static 12.4.127 0 nvidia
cuda-cuobjdump 12.4.127 0 nvidia
cuda-cupti 12.4.127 0 nvidia
cuda-cupti-static 12.4.127 0 nvidia
cuda-cuxxfilt 12.4.127 0 nvidia
cuda-demo-suite 12.4.127 0 nvidia
cuda-documentation 12.4.127 0 nvidia
cuda-driver-dev 12.4.127 0 nvidia
cuda-gdb 12.4.127 0 nvidia
cuda-libraries 12.6.0 0 nvidia
cuda-libraries-dev 12.6.0 0 nvidia
cuda-libraries-static 12.4.1 0 nvidia
cuda-nsight 12.4.127 0 nvidia
cuda-nvcc 12.4.131 0 nvidia
cuda-nvdisasm 12.4.127 0 nvidia
cuda-nvml-dev 12.4.127 0 nvidia
cuda-nvprof 12.4.127 0 nvidia
cuda-nvprune 12.4.127 0 nvidia
cuda-nvrtc 12.4.127 0 nvidia
cuda-nvrtc-dev 12.4.127 0 nvidia
cuda-nvrtc-static 12.4.127 0 nvidia
cuda-nvtx 12.4.127 0 nvidia
cuda-nvvp 12.4.127 0 nvidia
cuda-opencl 12.4.127 0 nvidia
cuda-opencl-dev 12.4.127 0 nvidia
cuda-profiler-api 12.4.127 0 nvidia
cuda-sanitizer-api 12.4.127 0 nvidia
cuda-toolkit 12.4.1 0 nvidia
cuda-tools 12.4.1 0 nvidia
cuda-visual-tools 12.6.0 0 nvidia
cudatoolkit 11.1.74 h6bb024c_0 nvidia
cudnn 8.0.4 cuda11.1_0 nvidia
decorator 5.1.1 pyhd8ed1ab_0 conda-forge
dlib 19.24.99 pypi_0 pypi
executing 2.1.0 pyhd8ed1ab_0 conda-forge
gds-tools 1.9.1.3 0 nvidia
ipython 8.12.2 pyh41d4057_0 conda-forge
jedi 0.19.1 pyhd8ed1ab_0 conda-forge
keyutils 1.6.1 h166bdaf_0 conda-forge
krb5 1.21.3 h659f571_0 conda-forge
ld_impl_linux-64 2.42 h02bd663_0 conda-forge
libcublas 12.4.5.8 0 nvidia
libcublas-dev 12.4.5.8 0 nvidia
libcublas-static 12.4.5.8 0 nvidia
libcufft 11.2.1.3 0 nvidia
libcufft-dev 11.2.1.3 0 nvidia
libcufft-static 11.2.1.3 0 nvidia
libcufile 1.9.1.3 0 nvidia
libcufile-dev 1.9.1.3 0 nvidia
libcufile-static 1.9.1.3 0 nvidia
libcurand 10.3.5.147 0 nvidia
libcurand-dev 10.3.5.147 0 nvidia
libcurand-static 10.3.5.147 0 nvidia
libcurl 8.10.1 hbbe4b11_0 conda-forge
libcusolver 11.6.1.9 0 nvidia
libcusolver-dev 11.6.1.9 0 nvidia
libcusolver-static 11.6.1.9 0 nvidia
libcusparse 12.3.1.170 0 nvidia
libcusparse-dev 12.3.1.170 0 nvidia
libcusparse-static 12.3.1.170 0 nvidia
libedit 3.1.20191231 he28a2e2_2 conda-forge
libev 4.33 hd590300_2 conda-forge
libexpat 2.6.3 h5888daf_0 conda-forge
libffi 3.4.2 h7f98852_5 conda-forge
libgcc 14.1.0 h77fa898_1 conda-forge
libgcc-ng 14.1.0 h69a702a_1 conda-forge
libgomp 14.1.0 h77fa898_1 conda-forge
libnghttp2 1.58.0 h47da74e_1 conda-forge
libnpp 12.2.5.30 0 nvidia
libnpp-dev 12.2.5.30 0 nvidia
libnpp-static 12.2.5.30 0 nvidia
libnsl 2.0.1 hd590300_0 conda-forge
libnvfatbin 12.4.127 0 nvidia
libnvfatbin-dev 12.4.127 0 nvidia
libnvjitlink 12.4.127 0 nvidia
libnvjitlink-dev 12.4.127 0 nvidia
libnvjpeg 12.3.1.117 0 nvidia
libnvjpeg-dev 12.3.1.117 0 nvidia
libnvjpeg-static 12.3.1.117 0 nvidia
libsqlite 3.46.1 hadc24fc_0 conda-forge
libssh2 1.11.0 h0841786_0 conda-forge
libstdcxx 14.1.0 hc0a3c3a_1 conda-forge
libstdcxx-ng 14.1.0 h4852527_1 conda-forge
libuuid 2.38.1 h0b41bf4_0 conda-forge
libuv 1.48.0 hd590300_0 conda-forge
libxcrypt 4.4.36 hd590300_1 conda-forge
libzlib 1.3.1 h4ab18f5_1 conda-forge
matplotlib-inline 0.1.7 pyhd8ed1ab_0 conda-forge
ncurses 6.5 he02047a_1 conda-forge
nsight-compute 2024.1.1.4 0 nvidia
openssl 3.3.2 hb9d3cd8_0 conda-forge
parso 0.8.4 pyhd8ed1ab_0 conda-forge
pexpect 4.9.0 pyhd8ed1ab_0 conda-forge
pickleshare 0.7.5 py_1003 conda-forge
pip 24.2 pyh8b19718_1 conda-forge
prompt-toolkit 3.0.47 pyha770c72_0 conda-forge
prompt_toolkit 3.0.47 hd8ed1ab_0 conda-forge
ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge
pure_eval 0.2.3 pyhd8ed1ab_0 conda-forge
pygments 2.18.0 pyhd8ed1ab_0 conda-forge
python 3.8.20 h4a871b0_1_cpython conda-forge
readline 8.2 h8228510_1 conda-forge
rhash 1.4.4 hd590300_0 conda-forge
setuptools 74.1.2 pyhd8ed1ab_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
stack_data 0.6.2 pyhd8ed1ab_0 conda-forge
tk 8.6.13 noxft_h4845f30_101 conda-forge
traitlets 5.14.3 pyhd8ed1ab_0 conda-forge
typing_extensions 4.12.2 pyha770c72_0 conda-forge
wcwidth 0.2.13 pyhd8ed1ab_0 conda-forge
wheel 0.44.0 pyhd8ed1ab_0 conda-forge
xz 5.2.6 h166bdaf_0 conda-forge
zstd 1.5.6 ha6fb4c9_0 conda-forge

@semajbaker
Copy link

semajbaker commented Sep 23, 2024 via email

@giampierobartolomei
Copy link

hi, thank you for the fast response, i will surely try, but i've tried also to install pytorch from conda and encountered the same problem:
$ conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 -c pytorch
Channels:

  • pytorch
  • conda-forge
  • nvidia
  • defaults
    Platform: linux-64
    Collecting package metadata (repodata.json): done
    Solving environment: failed

InvalidSpec: The package "nvidia/linux-64::cuda-compiler==12.6.0=0" is not available for the specified platform

do you think that i can install all from pip? i'm worried of installing from pip because i've a lot of dependencies.

Thank you again

@semajbaker
Copy link

semajbaker commented Sep 23, 2024 via email

@giampierobartolomei
Copy link

Ok thanks, now I have another question. I successfully installed all my python libraries. now when i try to run a cnn_face_detector (based on dlib) i find this error: dets = self.loader.cnn_face_detector(self.frame, 1)
RuntimeError: Error while calling cudaOccupancyMaxPotentialBlockSize(&num_blocks,&num_threads,K) in file /home/chiara/Desktop/gpu_4070/dlib/dlib/cuda/cuda_utils.h:164. code: 222, reason: the provided PTX was compiled with an unsupported toolchain.
Aborted (core dumped). I found that this error may be due to the cuda compatibilities with my rtx geforce 4070. I checked and it needs cuda >11.8. So I installed dlib with cuda like before and checked and DLIB_USE_CUDA=True.

This on my conda list:
cuda 11.8.0 0 nvidia
cuda-cccl_linux-64 12.6.37 0 nvidia
cuda-command-line-tools 12.6.1 0 nvidia
cuda-compiler 12.6.0 0 nvidia
cuda-cudart 12.6.68 0 nvidia
cuda-cudart-dev 12.6.68 0 nvidia
cuda-cudart-dev_linux-64 12.6.68 0 nvidia
cuda-cudart-static 12.6.68 0 nvidia
cuda-cudart-static_linux-64 12.6.68 0 nvidia
cuda-cudart_linux-64 12.6.68 0 nvidia
cuda-cuobjdump 12.6.68 0 nvidia
cuda-cupti 12.6.68 0 nvidia
cuda-cupti-dev 12.6.68 0 nvidia
cuda-cuxxfilt 12.6.68 0 nvidia
cuda-demo-suite 12.4.127 0 nvidia
cuda-documentation 12.4.127 0 nvidia
cuda-driver-dev 12.6.68 0 nvidia
cuda-driver-dev_linux-64 12.6.68 0 nvidia
cuda-gdb 12.6.68 0 nvidia
cuda-libraries 12.6.1 0 nvidia
cuda-libraries-dev 12.6.1 0 nvidia
cuda-libraries-static 12.6.1 0 nvidia
cuda-nsight 12.6.68 0 nvidia
cuda-nvcc 12.4.131 0 nvidia
cuda-nvdisasm 12.6.68 0 nvidia
cuda-nvml-dev 12.6.68 2 nvidia
cuda-nvprof 12.6.68 0 nvidia
cuda-nvprune 12.6.68 0 nvidia
cuda-nvrtc 12.6.68 0 nvidia
cuda-nvrtc-dev 12.6.68 0 nvidia
cuda-nvrtc-static 12.6.68 0 nvidia
cuda-nvtx 12.6.68 0 nvidia
cuda-nvvp 12.6.68 0 nvidia
cuda-opencl 12.6.68 0 nvidia
cuda-opencl-dev 12.6.68 0 nvidia
cuda-profiler-api 12.6.68 0 nvidia
cuda-runtime 12.6.1 0 nvidia
cuda-sanitizer-api 12.6.68 0 nvidia
cuda-toolkit 12.4.1 0 nvidia
cuda-tools 12.6.1 0 nvidia
cuda-version 12.6 3 nvidia
cuda-visual-tools 12.6.1 0 nvidia
cudnn 8.9.7.29 h092f7fd_3 conda-forge

This my nvidia-smi:
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.183.01 Driver Version: 535.183.01 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce RTX 4070 ... Off | 00000000:01:00.0 On | N/A |
| N/A 38C P8 4W / 55W | 17MiB / 8188MiB | 0% Default |

So even if i installed dlib with the right CUDA VERSION, i cannot use the model with the gpu.
Do you have any suggestion?

@semajbaker
Copy link

semajbaker commented Sep 23, 2024 via email

@giampierobartolomei
Copy link

@semajbaker
Copy link

semajbaker commented Sep 24, 2024 via email

@giampierobartolomei
Copy link

Thank you for your help, now it works! I just solved by installing latest NVIDIA driver after instaling cuda and cudnn on my local machine.

@semajbaker
Copy link

semajbaker commented Sep 24, 2024 via email

@YBachmann
Copy link

Nice guide! In my case I had to set export CUDAHOSTCXX=/usr/bin/g++ because otherwise I got the following error:

-- Building a CUDA test project to see if your compiler is compatible with CUDA...
-- *****************************************************************************************************************
-- *** CUDA was found but your compiler failed to compile a simple CUDA program so dlib isn't going to use CUDA. 
-- *** The output of the failed CUDA test compile is shown below: 
-- *** 
-- ***   Change Dir: /home/yannic/dlib/build/temp.linux-x86_64-3.10/dlib_build/cuda_test_build
   ***   
   ***   Run Build Command(s):/usr/bin/gmake -f Makefile && [ 50%] Building NVCC (Device) object CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o
   ***   nvcc warning : Support for offline compilation for architectures prior to '<compute/sm/lto>_75' will be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
   ***   cc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
   ***   compilation terminated.
   ***   nvcc fatal   : Failed to preprocess host compiler properties.
   ***   CMake Error at cuda_test_generated_cuda_test.cu.o.cmake:216 (message):
   ***     Error generating
   ***     /home/yannic/dlib/build/temp.linux-x86_64-3.10/dlib_build/cuda_test_build/CMakeFiles/cuda_test.dir//./cuda_test_generated_cuda_test.cu.o
   ***   
   ***   
   ***   gmake[2]: *** [CMakeFiles/cuda_test.dir/build.make:77: CMakeFiles/cuda_test.dir/cuda_test_generated_cuda_test.cu.o] Error 1
   ***   gmake[1]: *** [CMakeFiles/Makefile2:82: CMakeFiles/cuda_test.dir/all] Error 2
   ***   gmake: *** [Makefile:91: all] Error 2
   ***   
   ***   
-- *****************************************************************************************************************
-- Disabling CUDA support for dlib.  DLIB WILL NOT USE CUDA

@MichaelTarasov
Copy link

The BEST manual!
It's works!
Thank You very much!
Win 11.

@sickybee
Copy link

i've added some tweaks in my build
-install cuda 12.8
-install vs_BuildTools ->install Clang
-install intel onemkl
-install OpenBLAS

  • cmake .. -DDLIB_USE_MKL_WITH_TBB=1 -DDLIB_USE_BLAS=1 -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 -DUSE_SS2_INSTRUCTIONS=1 -DUSE_SS4_INSTRUCTIONS=1 -DCUDAToolkit_ROOT=E:\Source_Codes\WhoIsShe.conda\Library\bin\

  • activate conda environment

  • pip uninstall dlib #uninstall previous dlib

  • python setup.py install --set DLIB_USE_CUDA=1

DLIB CUDA is available
DLIB BLAS is available
DLIB LAPACK is available
DLIB AVX is available

... and now face_recognition webcam face blur works flawlessly in my GTX 970

@Rapcole12
Copy link

Rapcole12 commented Jul 9, 2025

for windows user who met the import dlib Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\oceanx\AppData\Local\Programs\Python\Python310\lib\site-packages\dlib-19.24.99-py3.10-win-amd64.egg\dlib\__init__.py", line 19, in <module> from _dlib_pybind11 import * ImportError: DLL load failed while importing _dlib_pybind11: The specified module could not be found. check your __init__.py , make sure its "on"=="on".

Thank you so much! I was wondering what was going on. Also make sure for anyone getting an error for not being able to find specific header files to ensure that your file paths are easily readable by C++ compilers. For example: If i have a apostrophe in my file path ex. C:\Go'Up, dlib will say it cannot find some header files when compiling for CUDA. But if i have ex. C:Go_Up, the problem is solves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment