Prerequisite: conda and/or miniconda are already installed
- Create a conda environment.
$ conda create -n dlib python=3.8 cmake ipython- Activate the environment.
$ conda activate dlib- Install CUDA and cuDNN with
condausing nvidia channel
$ conda install cuda cudnn -c nvidiaThen 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/- 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- 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
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.
So even if i installed dlib with the right CUDA VERSION, i cannot use the model with the gpu.
Do you have any suggestion?