Cogito ergo sum

How to build Dlib on Linux Ubuntu 18.04 using cmake with AVX support and install its Python API

Dlib is a modern C++ toolkit containing machine learning algorithms and tools for creating complex software in C++ to solve real world problems. It is used in both industry and academia in a wide range of domains including robotics, embedded devices, mobile phones, and large high performance computing environments. Dlib’s open source licensing allows you to use it in any application, free of charge.
source (

First of all download the latest version from using this link or go to the website and download it.
Extract the content of the file tar -xvf dlib-19.10.tar.bz2
Go to dlib dir  cd dlib-19.10 and create a new dir inside mkdir build && cd build
Then run the build command, but here you have to make a choic.
If you want to build it to use the nVidia graphic card with Cuda then you have to do it as follows:

cmake ..
cmake --build . --config Release
sudo ldconfig
sudo make install

If you want to use Dlib with no Cuda support and only use it with the cpu:

cmake --build . --config Release
sudo make install
sudo ldconfig

Note we used -DUSE_AVX_INSTRUCTIONS=ON  explicitly. If you bought your laptop after 2012 and it has an Intel cpu then it supports AVX Instructions, otherwise you have to use

Finally exit the build dir cd ..  and run
sudo python3.6 install –no DLIB_USE_CUDA –yes USE_AVX_INSTRUCTIONS
This will build a Python package with no cuda support and with AVX_Instrcutions support! As you see I use python3.6 you can also use Python2.7 and Python3.5.


About the author

Peshmerge Morad

A IT-student and a programmer based in the Netherlands whose interests span multiple fields.

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Cogito ergo sum