TadasBaltrusaitis / OpenFace

OpenFace – a state-of-the art tool intended for facial landmark detection, head pose estimation, facial action unit recognition, and eye-gaze estimation.
Other
6.71k stars 1.82k forks source link

Memory allocate error #1077

Closed ismeyueyue closed 3 months ago

ismeyueyue commented 3 months ago

I have successfully installed OpenFace on my server (Python application).

However, when run FeatureExtraction commond to generate detection results in a 3-minute duration video, but I got a memory error as follows:

...
Starting tracking
Reading the MTCNN face detector from: /workspace/OpenFace/build/bin/model/mtcnn_detector/MTCNN_detector.txt
Reading the PNet module from: /workspace/OpenFace/build/bin/model/mtcnn_detector/PNet.dat
Reading the RNet module from: /workspace/OpenFace/build/bin/model/mtcnn_detector/RNet.dat
Reading the ONet module from: /workspace/OpenFace/build/bin/model/mtcnn_detector/ONet.dat
OpenBLAS warning: precompiled NUM_THREADS exceeded, adding auxiliary array for thread metadata.
0% 10% 20% 30% 40% OpenBLAS : Program is Terminated. Because you tried to allocate too many memory regions.
This library was built to support a maximum of 128 threads - either rebuild OpenBLAS
with a larger NUM_THREADS value or set the environment variable OPENBLAS_NUM_THREADS to
a sufficiently small number. This error typically occurs when the software that relies on
OpenBLAS calls BLAS functions from many threads in parallel, or when your computer has more
cpu cores than what OpenBLAS was configured to handle.
OpenBLAS : Program is Terminated. Because you tried to allocate too many memory regions.
This library was built to support a maximum of 128 threads - either rebuild OpenBLAS
with a larger NUM_THREADS value or set the environment variable OPENBLAS_NUM_THREADS to
a sufficiently small number. This error typically occurs when the software that relies on
OpenBLAS calls BLAS functions from many threads in parallel, or when your computer has more
cpu cores than what OpenBLAS was configured to handle.
Segmentation fault

What does this mean and how can we solve it?

brmarkus commented 3 months ago

Have you tried to limit the number of threads to use for OpenBLAS, as mentioned in the console log? You might really use a powerful server with lots of CPU cores (maybe even a multi-CPU socket server).

Start small like setting the ENV variable via export OPENBLAS_NUM_THREADS=10 before starting the application.

ismeyueyue commented 3 months ago

Setting environment variables solved my problem.

brmarkus commented 3 months ago

Can you provide more information for future questions, please? How many (logical, physical) cores does your server have - and which ENV variable have you set to which value?

ismeyueyue commented 3 months ago

Well, export OPENBLAS_NUM_THREADS=1 and export OPENBLAS_NUM_THREADS=10 can both solve my problem

brmarkus commented 3 months ago

Thank you for the update!! Have you see an impact on performance, througput, latency with the different values (besides memory consumption)? May I ask how many CPU cores (logical, physical) your server environment has?