我在互联网上搜索过它,我只能找到人们在使用 Cuda 安装 Dlib 时遇到问题。我有完全相反的问题。我可以在 Ubuntu (Google Colab) 上成功安装具有 Cuda 和 GPU 支持的 Dlib。但我不想那样。我想强制 Dlib 使用 CPU,因为当我将运行时更改为 TPU 时,将没有 GPU。但是 Dlib 在安装时会找到 CUDA,并在安装时添加对 CUDA 的支持,即使运行时设置为“NOT GPU”。
pip install Dlib
默认情况下,这将使用 cuda 安装 Dlib,因为我不知道任何禁用 Cuda 的标志。但即使我尝试从源代码构建 Dlib,例如:
!git clone https://github.com/davisking/dlib.git
%cd dlib
!mkdir build
%cd build
!cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1
!cmake --build .
# !sudo make install
# !sudo ldconfig
%cd ..
# !python setup.py build --no DLIB_USE_CUDA
!python setup.py install --no DLIB_USE_CUDA
我可以成功
import Dlib
但是当我使用在后端调用 Dlib 的“face_recogntion”时
!pip install face_recognition
import dlib
import face_recognition
它抛出一个错误:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-52-c42385b122ec> in <module>()
2 get_ipython().system('pip install face_recognition')
3 import dlib
----> 4 import face_recognition
1 frames
/usr/local/lib/python3.6/dist-packages/face_recognition/api.py in <module>()
21
22 cnn_face_detection_model = face_recognition_models.cnn_face_detector_model_location()
---> 23 cnn_face_detector = dlib.cnn_face_detection_model_v1(cnn_face_detection_model)
24
25 face_recognition_model = face_recognition_models.face_recognition_model_location()
RuntimeError: Error while calling cudaGetDevice(&the_device_id) in file /tmp/pip-install-9p_kkgzg/dlib/dlib/cuda/gpu_data.cpp:178. code: 38, reason: no CUDA-capable device is detected
现在我无法理解我错过了什么。我应该设置什么标志才能强制 DLIB 使用 CPU,即使有 GPU 也不寻找 GPU。
慕哥6287543
月关宝盒
慕标5832272
牛魔王的故事
随时随地看视频慕课网APP
相关分类