serengil / deepface

A Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python
https://www.youtube.com/watch?v=WnUVYQP4h44&list=PLsS_1RYmYQQFdWqxQggXHynP1rqaYXv_E&index=1
MIT License
11.82k stars 2.02k forks source link

Performance On GPU Is Not So Faster Than CPU #386

Closed lujx1024 closed 2 years ago

lujx1024 commented 2 years ago

Here is the thing, I managed to install the tensorflow-gpu version before I installed deepface with --no-deps command, and also,I installed other dependencies seperately. After some struggles it finally pass the test by a simple script. Thanks to the reply of issue #251 and #336

But the problem is , when I tried VGG-Face model,the performance is not as faster as I anticipated,it took about 85% of GPU memorry and nearly 2% of GPU util, and it STILL need 3-5 seconds to process an image with just one face on it.

The environments and some test data are as follows:

ENV

CALL METHOD

 model = DeepFace.build_model(model_name='VGG-Face')   
 result = DeepFace.verify(image_pairs[:100],
                             model=model, distance_metric='euclidean_l2',
                             enforce_detection=False,
                             detector_backend='mtcnn')

GPU usage

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 426.00       Driver Version: 426.00       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name            TCC/WDDM | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro P1000       WDDM  | 00000000:01:00.0  On |                  N/A |
| 46%   59C    P0    N/A /  N/A |   3778MiB /  4096MiB |      1%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1712    C+G   ...hell.Experiences.TextInput.InputApp.exe N/A      |
|    0      3744    C+G   ...t_cw5n1h2txyewy\ShellExperienceHost.exe N/A      |
|    0      6476    C+G   ...dows.Cortana_cw5n1h2txyewy\SearchUI.exe N/A      |
|    0      6584    C+G   Insufficient Permissions                   N/A      |
|    0      8780    C+G   C:\Windows\explorer.exe                    N/A      |
|    0     10068    C+G   ...yCharm 2020.3.3\jbr\bin\jcef_helper.exe N/A      |
|    0     10756    C+G   ...es\Google\Chrome\Application\chrome.exe N/A      |
|    0     11212    C+G   ...mmersiveControlPanel\SystemSettings.exe N/A      |
|    0     11972      C   E:\conda\envs\deepface-gpu\python.exe      N/A      |
|    0     12000    C+G   ....100.3370.0_x64__8j3eq9eme6ctt\IGCC.exe N/A      |
+-----------------------------------------------------------------------------+

So. could you please tell me what went wrong ? Is there anything I can do to fix this problem ? Anything will be appreciated !

serengil commented 2 years ago

If you try to run it in a for loop, then you are going to understand the difference.