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
10.85k stars 1.91k forks source link

[BUG]: I want to use GPU when running deepface.analyze function , but I couldn't , please urgent help #1238

Closed omarnj-lab closed 1 month ago

omarnj-lab commented 1 month ago

Before You Report a Bug, Please Confirm You Have Done The Following...

DeepFace's version

0.0.91

Python version

3.10

Operating System

No response

Dependencies

tensorflow[and-cuda] tf-keras Keras facenet-pytorch gradio plotly pandas opencv-python deepface python-dotenv moviepy SpeechRecognition transformers openai

Reproducible example

def analyze_frame(frame, frame_count, backend):
    try:
        analysis = DeepFace.analyze(frame, actions=['emotion'], enforce_detection=False, detector_backend=backend)
        return {'frame_index': frame_count, 'data': analysis}
    except Exception as e:
        print(f"Error with {backend} on frame {frame_count}: {e}")
        return None

Relevant Log Output

===== Application Startup at 2024-05-23 10:07:33 =====

2024-05-23 12:10:34.682793: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0. 2024-05-23 12:10:34.743061: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-05-23 12:10:35.833124: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT 24-05-23 12:10:37 - Directory /home/user/.deepface created 24-05-23 12:10:37 - Directory /home/user/.deepface/weights created 2024-05-23 12:10:38.540298: I external/local_xla/xla/stream_executor/cuda/cuda_executor.cc:998] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355 2024-05-23 12:10:38.643304: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2251] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform. Skipping registering GPU devices... Num GPUs Available: 0 Running on local URL: http://0.0.0.0:7860

Expected Result

running on gpu

What happened instead?

very slow, not utilizing GPUs,

Additional Info

I am running it on Gradio App on Hugginface spaces with NVidia T4 small GPU

serengil commented 1 month ago

Duplicated - https://github.com/serengil/deepface/issues/1176