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
14.34k stars 2.2k forks source link

GPU vs CPU, same inference time? #336

Closed apiszcz closed 3 years ago

apiszcz commented 3 years ago

I am seeing the same performance with CPU and GPU. When I disable the GPU I get the message, which indicates it is not in use. However the inference speed is the same. 2021-09-09 12:49:05.405376: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected

I'm using CUDA 11.1 and have no issues with pytorch, facenet, yolov5, detectron2, etc. Is there something I need to set in DeepFace besides the env variable? os.environ["CUDA_VISIBLE_DEVICES"]="0"

serengil commented 3 years ago

Nope. Setting this enough to act: os.environ["CUDA_VISIBLE_DEVICES"]="0"

serengil commented 3 years ago

BTW, you should install tensorflow-gpu before installing deepface if you want to use GPU.

Your gpu memory might not be enough for existing models in deepface. It requires > 10GB memory for a single model as I remember.

apiszcz commented 3 years ago
  1. GPU is RTX5000 with 16GB avail.
  2. I reinstalled deepface, BTW the DEEPFACE_HOME update is NOT in the pypi repo, when might that happen? This appears to have fixed the problem, getting 4x faster now.
  3. With the following actions actions=['age', 'gender', 'race', 'emotion'] i'm now getting 15 inferences/sec. Thank you for the quick response.