ageitgey / face_recognition

The world's simplest facial recognition api for Python and the command line
MIT License
53.28k stars 13.48k forks source link

Use face_recognition on raspberry, “segmentation fault” occurred #294

Open sxyzzzzzzz opened 6 years ago

sxyzzzzzzz commented 6 years ago

python facerec_on_raspberry_pi.py

segmentation fault

sxyzzzzzzz commented 6 years ago

Similar to https://github.com/ageitgey/face_recognition/issues/119

sxyzzzzzzz commented 6 years ago

cpu 100%,then segmentation fault. raspberry pi 3.

sxyzzzzzzz commented 6 years ago

seems to freeze the function "face_encodings"

jparedesj commented 6 years ago

Do you found a solution for this?

andrewda commented 6 years ago

Any solution found for this? Been debugging for many hours now to no avail.

xyG67 commented 6 years ago

Have you found the solution? I met the same problem

andrewda commented 6 years ago

Unfortunately I never found a solution to this, besides using some faster hardware. I'd love to hear if others have figured this out, though!

andrewplesniak commented 5 years ago

I was experiencing the same problem, segmentation fault when calling the face_encodings on the raspberry pi 3. In my case, I compiled dlib with OpenBLAS for linear algebra optimizations which allows dlib functionality to execute faster. However, OpenBLAS itself is multi-threaded and if you try and use it in a muilt-threaded application it will peg the CPU and cause the seg fault. For use in multi-threaded applications, OpenBlas recommends you set it to single thread mode.

In my case, I set some environmental variables in my virtual environment to tell OpenBLAS to only use a single thread by doing the following:

$ workon myvenv $ nano VIRTUAL_ENV/bin/postactivate

add the following lines and save: export OPENBLAS_NUM_THREADS=1 export OPENBLAS_MAIN_FREE=1

By doing this, I was able to achieve ~15 fps of facial recognition in my application that was previously crashing on my pi.

AlexBdx commented 5 years ago

I was experiencing the same problem, segmentation fault when calling the face_encodings on the raspberry pi 3. In my case, I compiled dlib with OpenBLAS for linear algebra optimizations which allows dlib functionality to execute faster. However, OpenBLAS itself is multi-threaded and if you try and use it in a muilt-threaded application it will peg the CPU and cause the seg fault. For use in multi-threaded applications, OpenBlas recommends you set it to single thread mode.

In my case, I set some environmental variables in my virtual environment to tell OpenBLAS to only use a single thread by doing the following:

$ workon myvenv $ nano VIRTUAL_ENV/bin/postactivate

add the following lines and save: export OPENBLAS_NUM_THREADS=1 export OPENBLAS_MAIN_FREE=1

By doing this, I was able to achieve ~15 fps of facial recognition in my application that was previously crashing on my pi.

This solved my issue too. The Pi is now using only one CPU core instead of 4 but does not crash when calling face_encodings! Any idea how all 4 cores could be used to increase the FPS?

SeanIsAllRobot commented 5 years ago

I have the same issue, but I'm not working within a virtual environment, so where would i write

export OPENBLAS_NUM_THREADS=1
export OPENBLAS_MAIN_FREE=1

to?