Skip to content

Instantly share code, notes, and snippets.

@MikeTrizna
Last active January 7, 2023 18:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeTrizna/4964278bb6378de72ba4b195553a3954 to your computer and use it in GitHub Desktop.
Save MikeTrizna/4964278bb6378de72ba4b195553a3954 to your computer and use it in GitHub Desktop.

Installing dlib and face_recognition

(assuming that conda and/or miniconda are already installed)

  1. Create a conda environment with a few packages initialized.

    conda create -n faces python=3.6 cudatoolkit cudnn cmake numpy ipython

  2. Activate the environment.

    conda activate faces

  3. Download and build dlib from source, following https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/. Notice that the last python setup.py step is changed...

    $ git clone https://github.com/davisking/dlib.git
    $ cd dlib
    $ mkdir build
    $ cd build
    $ cmake .. -DDLIB_USE_CUDA=1 -DUSE_AVX_INSTRUCTIONS=1
    $ cmake --build .
    $ cd ..
    $ python setup.py install --set DLIB_USE_CUDA=1
  4. Install face_recognition python library

    pip install face_recognition

  5. Test it out using ipython

    (faces) [triznam@NMNH-30914 dlib]$ ipython
    Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34)
    Type 'copyright', 'credits' or 'license' for more information
    IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: import dlib
    
    In [2]: dlib.DLIB_USE_CUDA
    Out[2]: True
    
    In [3]: print(dlib.cuda.get_num_devices())
    1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment