ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.54k stars 13.5k forks source link

face detection, CNN mode, using CPU when I have a GPU? #859

Closed pliablepixels closed 5 years ago

pliablepixels commented 5 years ago

Description

I have an NVIDIA 1050 Ti GPU installed on my machine.

Drivers are correct:

nvidia-smi
Thu Jun 20 18:50:54 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.26       Driver Version: 430.26       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 105...  Off  | 00000000:02:00.0 Off |                  N/A |
| 36%   42C    P0    N/A /  75W |      0MiB /  4039MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

I have DLIB compiled with GPU:

>>> import dlib
>>> dlib.DLIB_USE_CUDA
True
>>> print (dlib.cuda.get_num_devices())
1

However, when I run face_recognition examples, this is what I see:

pp@homeserver:~$ nvidia-smi pmon
# gpu        pid  type    sm   mem   enc   dec   command
# Idx          #   C/G     %     %     %     %   name
  0       1755     C     0     0     0     0   python
  0       1755     C     1     0     0     0   python
   0       1755     C     6     2     0     0   python

A typical detection time on my machine (Xeon 3.1GHZ, 32GB RAM) takes 3 seconds. The output of nvidia-smi seems to show its using "C" (CPU?) and not GPU?

Please let me know if you need any more info.

pliablepixels commented 5 years ago

closing - I think this is more appropriate to be in the dlib repo

murilolopes commented 5 years ago

@pliablepixels did you find your answer?

pliablepixels commented 5 years ago

I did. a) It was a goofy mistake on my side https://github.com/davisking/dlib/issues/1805 b) (As a side note, I also realized that just compiling dlib to have GPU support doesn't mean it will be used. The GPU drivers need to be correct)

murilolopes commented 5 years ago

@pliablepixels thanks for the reply, I guess that I'm with the same problem(versions between stuff) I'm using GeForce 920m(4GB) with drive 418.67, cuda 10.1 and cudnn 7.6.1 on Ubuntu 18.04 can you say something about this stack?

murilolopes commented 5 years ago

My context is: I'm trying to improve fps for an RTSP video stream face recognition

pliablepixels commented 5 years ago

I can say a lot given I went through the complete process of getting everything working :-D I've created a gist to help you through - not sure what your issue is though, the fact that dlib is not using GPU or whether GPU is not configured correctly. Either way, if you need more help, feel free to continue comments on the gist. https://gist.github.com/pliablepixels/f0f86d8f8a8d2ddcbe9b9d4e25088af4

murilolopes commented 5 years ago

@pliablepixels thank you so much, I'll try and will return to say if worked fine

pliablepixels commented 5 years ago

No problem. FYI after all these changes, an 800x600 face takes around 240ms (average) in CNN mode. (first load time not included).

railton commented 5 years ago

@murilolopes For rtsp use this approach

https://github.com/gilbertfrancois/video-capture-async