Hello, i'm tryng to running python code where the code run face_recognition library where is GPU required to run faster for dlib face_recognition run model CNN
i'm using NVIDIA GPU Cloud Image for Deep Learning and HPC to run the python script, then the python script main.py :
from PIL import Image
import face_recognition
from datetime import datetime
start=datetime.now()
# Load the jpg file into a numpy array
image = face_recognition.load_image_file("com.jpg")
face_locations = face_recognition.face_locations(image, number_of_times_to_upsample=0, model="cnn")
face_encode = face_recognition.face_encodings(image, face_locations)
print("I found {} face(s) in this photograph.".format(len(face_locations)))
print(face_encode)
print(datetime.now()-start)
here the driver of NVIDIA from nvidia-smi driver version 396.44 :
https://i.stack.imgur.com/OY2eq.png
i have installed CUDA-Toolkit 9.2 and CUDNN, here the log when installed the dlib with GPU support: there have support CUDA will used for dlib
https://i.stack.imgur.com/XrP7a.png
then i try to run the code main.py, but the process not running on NVIDIA GPU took 01:06.114585 any idea for this problem ?
https://i.stack.imgur.com/bD9xR.png
Is it possible you did something like install dlib for python3 but ran your code with python2 (or the reverse)? Or maybe you recompiled dlib with cuda support but didn't actually install that new version over an old version? Just a random guess.
Step 1 : i try to disable the python3 (purge the installed python3) and installed dlib from latest github source from here: https://github.com/davisking/dlib
Step 2 : i try install dlib in both python and run for each python and python3
and all not working
or maybe i must to do reinstall face_recognition ? cause when i install face_recognition with pip install face_recognition it's build and install dlib ?
GPU it's support for python 2 and python 3 right ?
If pip is rebuilding dlib when you install face_recognition, that means pip is not finding dlib correctly installed and pip thinks it still needs to be installed. Maybe you are not running python setup.py install correctly for the version of dlib you are compiling yourself or or something like that?
GPU should work fine for both python2 and python3 as long as dlib is compiled and installed correctly for that version of python.
i installed dlib first with pip then with sudo python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
are that possible python use dlib from pip version not from python setup.py ?
i'm try installed like this step:
$ git clone https://github.com/davisking/dlib.git
$ cd dlib
$ mkdir build
$ cd build
$ cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
$ cmake --build .
$ cd ..
$ python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
run the following script:
import dlib.cuda as cuda
print(cuda.get_num_devices())
if it went wrong, or said 0 gpu found, dlib for current python environment you run it is not linked to CUDA correctly .
that's work, thank you
i installed dlib first with pip then with
sudo python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDAare that possible python use dlib from pip version not from python
setup.py?
i'm try installed like this step:
$ git clone https://github.com/davisking/dlib.git
$ cd dlib
$ mkdir build
$ cd build
$ cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
$ cmake --build .
$ cd ..
$ python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
- note
i got successfull running on GPU, the problem is when making cmake --build . it's on python3 but i think dlib installed on python2. my bad. Thank You
You can run the code
python3 setup.py install
instead of
python setup.py install
i installed dlib first with pip then with
sudo python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDAare that possible python use dlib from pip version not from python
setup.py?
i'm try installed like this step:
$ git clone https://github.com/davisking/dlib.git
$ cd dlib
$ mkdir build
$ cd build
$ cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
$ cmake --build .
$ cd ..
$ python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
- note
i got successfull running on GPU, the problem is when making cmake --build . it's on python3 but i think dlib installed on python2. my bad. Thank You
--yes is deprecated is there any other way to build ??
i installed dlib first with pip then with
sudo python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
are that possible python use dlib from pip version not from pythonsetup.py?
i'm try installed like this step:
$ git clone https://github.com/davisking/dlib.git
$ cd dlib
$ mkdir build
$ cd build
$ cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
$ cmake --build .
$ cd ..
$ python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
- note
i got successfull running on GPU, the problem is when making cmake --build . it's on python3 but i think dlib installed on python2. my bad. Thank You--yes is deprecated is there any other way to build ??
python setup.py install --set DLIB_USE_CUDA=1 --set USE_AVX_INSTRUCTIONS=1
having similar problem, while installation it says: DLIB WILL USE CUDA, but then it doesn't.
I'm following these instructions for Windows and checking with python commands:
import dlib
dlib.DLIB_USE_CUDA
it says False for me.
I'm not performing step 5 Include cudnn.lib in your Visual Studio project.
simply because "Property Pages" menu in VS is not active for me, I guess because project is not opened even if I open python script in Visual Studio it's not a project for VS...
Can it be an issue? Is it necessary to use VS to run python code to make it work at all?
Any help or point to the topic would be appreciated.
My setup:
GPU: GTX 1050 on the first laptop and MX150 on the second one, both with newest drivers.
Thanks in advance
I think CUDA 10.2 and Dlib 19.19 are not compatible at all.
You should use CUDA 10.1.
It solves your issue.
I'm having the same issue as well. It runs with CPU instead of GPU.
My setup:
Windows 10
Python 3.7
CUDA 10.1
Dlib 19.19
VStudio 2019
I have been trying all sorts of method but still no luck.
Thank you for answer, but still not going to work, output during dlib installation:
-- pybind11 v2.2.2
-- Using CMake version: 3.16.3
-- Compiling dlib version: 19.19.99
-- SSE4 instructions can be executed by the host processor.
-- AVX instructions can be executed by the host processor.
-- Enabling AVX instructions
-- Looking for cuDNN install...
-- Found cuDNN: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1/lib/x64/cudnn.lib
-- Enabling CUDA support for dlib. DLIB WILL USE CUDA
-- C++11 activated.
-- Configuring done
-- Generating done
and checking with dlib.DLIB_USE_CUDA gives False
If dlib.DLIB_USE_CUDA gives False, then you should check
that you have installed Cuda Toolkit and also cudnn.
then check, cudnn path. It must be included in system path properly.
Note. cudnn version must meet Cuda Toolkit version.
I'm having the same issue as well. It runs with CPU instead of GPU.
My setup:
Windows 10
Python 3.7
CUDA 10.1
Dlib 19.19
VStudio 2019I have been trying all sorts of method but still no luck.
Install cudnn also.
Good luck!
how to install dlib with cuda support please provide the steps and which version of cuda supports the library
plsss help.............. it will be a graet help to the developers community
Most helpful comment
python setup.py install --set DLIB_USE_CUDA=1 --set USE_AVX_INSTRUCTIONS=1