face_recognition: Can't run process dlib in GPU

  • face_recognition version: 1.2.3
  • Python version:2.7
  • Operating System:ubuntu16.04

Description

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

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

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

  • 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

i installed dlib on gpu, but can not see the dlib gpu process in nvidia-smi, do you know why? @ageitgey @akshay-shah @windforce7 @ManivannanMurugavel @blinkbink

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

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 .

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

  • 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

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.

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 ?

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.