ageitgey / ageitgey/face_recognition

RuntimeError when running multiprocessing example

Open
#841 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
56.8k
Forks
13.7k
PR merge metrics
No merged PRs in 30d

Description

  • face_recognition version: 1.2.3
  • Python version: 3.7
  • Operating System: Pop!_OS 19.04
  • CUDA + CuDNN version: 10.0

I'm trying to use the facerec_from_webcam_multiprocessing.py example with cuda support, but everytime I run it I get this error:

Width: 640, Height: 480, FPS: 30
Process Process-5:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "facerec_from_webcam_multiprocessing.py", line 78, in process
    face_locations = face_recognition.face_locations(rgb_frame, model="cnn")
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 116, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 100, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaGetDevice(&the_device_id) in file /home/han/dlib-19.17/dlib/cuda/gpu_data.cpp:201. code: 3, reason: initialization error
Process Process-6:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "facerec_from_webcam_multiprocessing.py", line 78, in process
    face_locations = face_recognition.face_locations(rgb_frame, model="cnn")
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 116, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 100, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaGetDevice(&the_device_id) in file /home/han/dlib-19.17/dlib/cuda/gpu_data.cpp:201. code: 3, reason: initialization error
Process Process-7:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "facerec_from_webcam_multiprocessing.py", line 78, in process
    face_locations = face_recognition.face_locations(rgb_frame, model="cnn")
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 116, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 100, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaGetDevice(&the_device_id) in file /home/han/dlib-19.17/dlib/cuda/gpu_data.cpp:201. code: 3, reason: initialization error
Process Process-8:
Traceback (most recent call last):
  File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/usr/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "facerec_from_webcam_multiprocessing.py", line 78, in process
    face_locations = face_recognition.face_locations(rgb_frame, model="cnn")
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 116, in face_locations
    return [_trim_css_to_bounds(_rect_to_css(face.rect), img.shape) for face in _raw_face_locations(img, number_of_times_to_upsample, "cnn")]
  File "/usr/local/lib/python3.7/dist-packages/face_recognition/api.py", line 100, in _raw_face_locations
    return cnn_face_detector(img, number_of_times_to_upsample)
RuntimeError: Error while calling cudaGetDevice(&the_device_id) in file /home/han/dlib-19.17/dlib/cuda/gpu_data.cpp:201. code: 3, reason: initialization error

I looked at the multiprocessing documentation and made a few changes in the script without success. Could you give me a hint on how could I make it work? Thanks in advance.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with facerec_from_webcam_multiprocessing.py at line 78, where face_recognition.face_locations is called with model="cnn". Reproduce the example with the reported Python, CUDA, and dlib setup, then investigate multiprocessing CUDA initialization around the cudaGetDevice error. Done means the multiprocessing webcam example runs without the RuntimeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.