ageitgey / face_recognition_models

Trained models for the face_recognition python library
Creative Commons Zero v1.0 Universal
359 stars 180 forks source link

When running on a CPU-only Google Colab kernel, no CUDA-capable device is detected #9

Open xjdeng opened 4 years ago

xjdeng commented 4 years ago

Description

My face encoder doesn't work when running on a CPU-only instance of Google Colab because dlib seems to expect a GPU.

What I Did

import face_recognition_models
import dlib

predictor_5_point_model = face_recognition_models.pose_predictor_five_point_model_location()
pose_predictor_5_point = dlib.shape_predictor(predictor_5_point_model)

predictor_68_point_model = face_recognition_models.pose_predictor_model_location()
pose_predictor_68_point = dlib.shape_predictor(predictor_68_point_model)

face_recognition_model = face_recognition_models.face_recognition_model_location()

face_encoder = dlib.face_recognition_model_v1(face_recognition_model)

And got the following error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-2d57e5cbaae3> in <module>()
----> 1 face_encoder = dlib.face_recognition_model_v1(face_recognition_model)

RuntimeError: Error while calling cudaGetDevice(&the_device_id) in file /tmp/pip-wheel-b9ck8go0/dlib/dlib/cuda/gpu_data.cpp:201. code: 100, reason: no CUDA-capable device is detected
---------------------------------------------------------------------------

Note that this works fine on a GPU instance on Google Colab but not on a cpu-only one. And sometimes, I can't get a GPU instance on Colab which makes it impossible to run some code the uses the face_encoder (which should still work at a reasonable speed on the CPU.)

Here's a link to my Google Colab notebook to reproduce this: https://colab.research.google.com/drive/1wdCrks6Mdx-O9A77umQKUb8wCk8i43Uu

erisitohang commented 4 years ago

you can enable GPU in colab and it's free. Runtime => Change runtime type and select GPU as Hardware accelerator.

xjdeng commented 4 years ago

That doesn't solve the problem. Sometimes, Colab denies me a GPU and this library stops working as a result.

jbichene95 commented 4 years ago

the problem here is that the version of dlib that comes preinstalled with colab is configured to work with GPU. the work around here is either to pip uninstall the default dlib and pip install a new one ,or use virtual environments to isolate that dependency

Finki007 commented 3 years ago

@jbichene95 i tried to uninstall and reinstall dlib and still getting the error. @xjdeng could you solve this issue?