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 (http://dlib.net/)

Update:

Based on the comment from Davis E King, the maker of Dlib, you don’t to follow these steps. See his comment below to know how to do it!


First of all download the latest version from using this link http://dlib.net/files/dlib-19.10.tar.bz2 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 .. -DUSE_AVX_INSTRUCTIONS=ON
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
-DUSE_SSE2_INSTRUCTIONS=ON

Finally exit the build dir cd ..  and run
sudo python3.6 setup.py 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.

3 comments

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

  • These instructions are wrong. To install dlib all you do is run:
    python setup.py install
    That’s it. Just that one command and nothing else.

    None of the other stuff is required. The setup.py file builds the dlib extension and auto-detects if you have AVX, SSE, CUDA, or any of that other stuff and enables it if you do.

    • “The setup.py file builds the dlib extension and auto-detects if you have AVX, SSE, CUDA, or any of that other stuff and enables it if you do.”
      How can we disable some stuff e.g do not use CUDA even if it finds one. Just don’t use it. and install only CPU version ?
      python setup.py install –no DLIB_USE_CUDA
      this thing does not work and Dlib is still using Cuda.
      Is there any other way

Cogito ergo sum