Face_recognition: GPU running out of memory

Created on 30 Jun 2018  路  2Comments  路  Source: ageitgey/face_recognition

  • face_recognition version:
  • Python version: 3.6.5
  • Operating System: Windows 10

Description

I've installed dlib with CUDA support on a GTX1060 3GB.

I've loaded 2 images, and have called

face_recognition.face_locations(img, number_of_times_to_upsample=0, model="cnn")

on each image separately. The first image is parsed correctly, and I receive the coordinates of the face in the first image. But trying to detect faces in the second image, I receive the error

RuntimeError: Error while calling cudaMalloc(&data, n) in file C:\Users\Gavan\dlib-master\dlib\cuda\cuda_data_ptr.cpp:28. code: 2, reason: out of memory

I've run nvidia-smi and confirmed that the program fills up ~2.7GB of VRAM upon running face_locations on the second image, then the crash happens. Is it possible to force VRAM to be flushed? Or is there an easier solution I'm not aware of?

Most helpful comment

Maybe try to resize the image. cv2.resize or scipy.misc.imresize. Try different values 1/2 or 1/4 etc

All 2 comments

Maybe try to resize the image. cv2.resize or scipy.misc.imresize. Try different values 1/2 or 1/4 etc

Thanks lolstatsguy, you've solved this particular issue for me. I'm going to push the face_recognition api further and see how far I get. Cheers!

Was this page helpful?
0 / 5 - 0 ratings