ageitgey / face_recognition

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

cudamalloc error #1015

Open flydragon2018 opened 4 years ago

flydragon2018 commented 4 years ago

Description

I am running to train a 128-d model.

What I Did

D:\Downloads\dlibopencvface> python encode_faces.py --dataset dataset --encodings encodings.pickle
[INFO] quantifying faces...
[INFO] processing image 1/75
[INFO] processing image 2/75
[INFO] processing image 3/75
[INFO] processing image 4/75
[INFO] processing image 5/75
[INFO] processing image 6/75
[INFO] processing image 7/75
[INFO] processing image 8/75
[INFO] processing image 9/75
[INFO] processing image 10/75
[INFO] processing image 11/75
[INFO] processing image 12/75
Traceback (most recent call last):
  File "encode_faces.py", line 45, in <module>
    model=args["detection_method"])
  File "C:\ProgramData\Anaconda3\lib\site-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 "C:\ProgramData\Anaconda3\lib\site-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 cudaMalloc(&data, n) in file D:\dlib\dlib\cuda\cuda_data_ptr.cpp:58. code: 2, reason: out of memory
alessiosavi commented 4 years ago

The error is related to the high resolution of the photos. The GPU have not enough memory for deal with the photo. You can use a simple workaround: reduce the size of the image.

You can rewrite the load_image_file in order to manage high resolution image as following: https://github.com/alessiosavi/PyRecognizer/blob/master/utils/util.py#L288