A Step-by-Step Guide to Verifying the Successful Installation of Dlib on a Raspberry Pi 3

This tutorial will walk you through the process of verifying the successful installation of the Dlib library on your Raspberry Pi 3. If you’re new to Dlib or are unsure whether it has been properly in …


Updated August 25, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


This tutorial will walk you through the process of verifying the successful installation of the Dlib library on your Raspberry Pi 3. If you’re new to Dlib or are unsure whether it has been properly installed, this guide is for you!

  1. Open the terminal by pressing Ctrl + Alt + T and enter the following command to check if Dlib is installed correctly:
pip3 list | grep dlib

This command will show you all the packages installed in Python 3 and filter out any package that has “dlib” in its name. If Dlib is installed, it should appear in the output.

  1. If Dlib is not listed, you may need to install it using pip. Enter the following command:
sudo pip3 install dlib

This will download and install the latest version of Dlib from the Python Package Index (PyPI) repository.

  1. Once the installation is complete, try running a simple test script to verify that Dlib is working correctly. Create a new file called test_dlib.py in your home directory using a text editor like nano:
nano ~/test_dlib.py

Add the following code to the file and save it:

import dlib
print("Dlib version: ", dlib.__version__)
  1. Run the test script using Python 3:
python3 ~/test_dlib.py

If Dlib is installed correctly, you should see the version number printed in the terminal. If not, there may be an issue with your installation or your system’s configuration. Check for any error messages and try installing Dlib again using the steps above.

  1. To confirm that CUDA (a parallel computing platform) is installed on your Raspberry Pi 3, enter the following command:
nvcc --version

If CUDA is installed, you should see version information displayed in the terminal. If not, you can install it using these instructions: https://github.com/NVIDIA/jetson-containers/blob/master/doc/cuda-on-rpi3.md

  1. To use Dlib with CUDA on your Raspberry Pi 3, you need to compile the GPU version of Dlib from source. First, clone the Dlib repository:
git clone https://github.com/davisking/dlib.git
cd dlib
  1. Now, create a new build folder and navigate to it:
mkdir build && cd build
  1. Run CMake with the following command:
cmake .. -DUSE_CUDA=1

This will generate Makefiles for building Dlib with CUDA support.

  1. Compile Dlib using make:
make -j4

The -j4 flag specifies the number of CPU cores to use during compilation (in this case, 4). Adjust this value based on your system’s capabilities.

  1. Install the compiled Dlib library:
sudo make install
  1. Run the test script from step 3 again using Python 3:
python3 ~/test_dlib.py

If everything is working correctly, you should see the version number printed in the terminal. If not, double-check your installation process and ensure that all dependencies are met.

Congratulations! You have successfully confirmed dlib installation on your Raspberry Pi 3. Now you can start using Dlib for a variety of computer vision applications.