face_recognition icon indicating copy to clipboard operation
face_recognition copied to clipboard

If 1080Ti GPU Fully Used

Open wxthss82 opened this issue 8 years ago • 12 comments

  • face_recognition version:latest
  • Python version:3.5.2
  • Operating System:Ubuntu 16.04.3
  • Webcam 8M WebCam, 3264*2448

Description

I build dlib with CUDA support, I try to use the facerec_from_webcam.py, but I find a low gpu usage, I pass model = "cnn", still low usage.

What I Did

screenshot from 2018-02-09 15-40-42

wxthss82 avatar Feb 09 '18 07:02 wxthss82

What's the problem exactly? Is the performance less than you need so you want it to use more GPU resources or something?

ageitgey avatar Feb 09 '18 22:02 ageitgey

facerec_from_webcam isn't really going to stress anything as it is still only processing one frame at a time - try running the find_faces_in_batches.py with a batch size of 128 against an input video.

facepainter avatar Feb 10 '18 08:02 facepainter

@ageitgey Yes, I think if the processing time is fast enough, It can do realtime face recognition, but now I see it's about one second delay

wxthss82 avatar Feb 10 '18 14:02 wxthss82

@facepainter Thank you for your advice, I think that if the processing time is fast enough, it can be realtime, but now I see about one second delay. That's to say, if it takes 0.099 second to recognize face in picture sequences, and take 0.001 second to grab image file from webcam, it can be about 10fps so the image sequences show in the windows can be continuous, but now I see it as discrete.

wxthss82 avatar Feb 10 '18 14:02 wxthss82

Similar issue here. After some digging, found that dlib's face detection does NOT support GPU nor multi-thread.

snuzxj avatar Feb 16 '18 20:02 snuzxj

That's not correct.

dlib's non-CNN based face detector doesn't support the GPU but you can easily run it in multiple processes in python (for example, see concurrent.futures) to take advantage of multiple cpu cores.

dlib's CNN-based face detector can use a GPU. Check out some of the demos, like the batch face detection demo.

ageitgey avatar Feb 16 '18 23:02 ageitgey

Can you show a pointer to dlib's source code which indicates it uses GPU for face detection?

snuzxj avatar Feb 16 '18 23:02 snuzxj

I am running dlib on Jetson TX2, which has a decent GPU but very weak CPU (which are ARM). It is really slow no mater using HOG or CNN based face detector. And, the face comparison speed is also slower than my MBP with has no GPU... BTW, I set GPU support when compiling and installing dlib.

snuzxj avatar Feb 16 '18 23:02 snuzxj

@snuzxj The python wrapper for the CNN face detector is here. The face detector model is defined here in code using the DNN functions provided by dlib.

The DNN code is full of CUDA references. See for example all the #ifdef DLIB_USE_CUDA sections in https://github.com/davisking/dlib/blob/master/dlib/dnn/tensor_tools.cpp which the face detector uses several functions from.

Note that the CNN face detector isn't necessarily faster than the non-CNN face detector. Instead, it achieves comparable speed on a GPU as the old algorithm but gives higher accuracy.

I don't have a Jetson TX2, so I don't have any real experience with it. But it might be worth checking to make sure you are compiling dlib with NEON extensions enabled if it uses an ARM cpu that supports it. That won't change the speed of any GPU based operations, but it might help a lot for everything else.

ageitgey avatar Feb 16 '18 23:02 ageitgey

@ageitgey Thank you for the detailed pointers. I will look into this, and see what are the problems. I just came across this thread, which also says dlib doesn't do GPU face detection. https://github.com/cmusatyalab/openface/issues/157

snuzxj avatar Feb 17 '18 01:02 snuzxj

That was true in the past when that thread was posted. The GPU model was only available via C++. That's why I contributed a python wrapper to expose that functionality in dlib a few months ago :)

ageitgey avatar Feb 17 '18 01:02 ageitgey

I have i5 8350u cpu 64 bit;8GB ram Windows 10 ; python 3.8 with conda 4.7

I used HOG model is sort of ok although slow with 5 min video . For each face i have only 1 photo to recognize and my known faces are only 2 I need to capture the video frames of incoming or outgoing employees of a company & capture their in time & out time So the camera will be continuously running and capturing Wit CNN model it is extremely slow.

  1. Should i go for Raspberry Pi . I understand from Adrian Rosebrock site that it is not suitable for face_recognition

  2. Should i go for CNN or Tensorflow/Keras or any other model should be tried pls advise

  3. I would like to find how to know if GPU is being used. i have followed the a site and done the cmake build of dlib I used https://github.com/ageitgey/face_recognition/commit/b17901840000e RUN cmake -H/dlib -B/dlib/build -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1 to build dlib before this i did conda install of dlib

  4. when i execute python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA -G "Visual Studio 15 2017 Win64" it says --yes is not recognized

  5. Also i have installed Microsoft Visual Studio 2017 and not 2015. I understand from https://github.com/ageitgey/face_recognition/issues/303 that CUDA do not support vs2017 & we need t install VS2015. Is there any workaround

  6. how to use face_recognition_svm.py for training.

deepa042008 avatar Dec 09 '19 08:12 deepa042008