【问题标题】:how to run dlib face recognition with gpu如何使用 gpu 运行 dlib 人脸识别
【发布时间】:2020-06-12 11:27:44
【问题描述】:

我已经安装了 Visual Studio 2019,以及 Cuda 10.1 和 TensorFlow 2.1.0,但我仍然无法使用 GPU 运行人脸识别,有人可以给我一份关于使用 GPU 代替 CPU 步骤的完整指南。

注意:我使用的是 Windows 10,我的 GPU 是 gtx1050,我使用的是 anaconda spider。

【问题讨论】:

    标签: tensorflow gpu face-recognition dlib


    【解决方案1】:

    首先,你应该安装 tensorflow-gpu 包而不是 tensorflow。

    如果您的 tf 安装正确,您可以在 deepface 中的 gpu 中运行人脸识别。您可以使用分配内存功能对其进行测试。

    #!pip install deepface
    from deepface import DeepFace
    DeepFace.allocateMemory()
    

    如果一切正常,则返回“DeepFace 将在 GPU 上运行”消息。

    除 Dlib 之外的所有人脸识别模型都将在 tensorflow-gpu 上运行。您可以运行带有验证功能的人脸识别。

    from deepface import DeepFace
    models = ["VGG-Face", "Facenet", "OpenFace", "DeepFace", "DeepID", "Dlib"]
    obj = DeepFace.verify("img1.jpg", "img2.jpg", model_name = models[0])
    print(obj)
    

    【讨论】:

      【解决方案2】:

      我使用 anaconda 环境通过这些步骤解决了这个问题:

      已安装 cuda 10.2

      python (3.7.7)

      conda 安装 pip

      conda 安装 tensorflow(最新 2.1.0)

      conda 安装 tensorflow-gpu

      pip 安装 imutils

      pip install opencv-python

      pip install opencv-contrib-python

      pip 安装 dlib

      pip install face_recognition

      【讨论】:

        【解决方案3】:

        正如 Adrian Rosebrock 在 https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/ 中提到的,最好从源代码构建 Dlib,这样库就可以知道系统中存在确切的 GPU。我的猜测是 - 在构建过程中,它会通过 CUDA 驱动程序探测 GPU 的功能并相应地构建和安装。

        git克隆https://github.com/davisking/dlib.git
        cd dlib
        mkdir 构建
        光盘构建
        cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
        cmake --build .
        光盘..
        python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA

        【讨论】:

          猜你喜欢
          • 2020-02-20
          • 2018-12-07
          • 2018-03-27
          • 2021-11-08
          • 2021-09-20
          • 2018-11-09
          • 2011-12-11
          • 2021-01-26
          • 2021-01-02
          相关资源
          最近更新 更多