Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

How to install dlib HEAD (w/ python bindings) from github

These instructions assume you are on macOS, but basically the same on Linux.

Pre-reqs:

  • Have Python 3 installed. On macOS, this could be installed from homebrew or even via standard Python 3.6 downloaded installer from https://www.python.org/download. On Linux, just use your package manager.
  • On macOS:
    • Install XCode from the Mac App Store (or install the XCode command line utils).
    • Have homebrew installed
    • Install boost with this command: brew install boost-python --with-python3 --without-python
  • On Linux:
    • Install boost. On Ubuntu, that's sudo apt-get install libboost-all-dev
    • For a full list of apt packages required, check out the example Dockerfile and copy what's installed there.
    • These instructions assume you are using Ubuntu 16.04 or newer. If you are using 14.04, you can try these installation instructions instead to work around the old CMake version.
  • This assumes you don't have an nVidia GPU and don't have Cuda and cuDNN installed and don't want GPU acceleration (since none of the current Mac models support this).

Clone the code from github:

git clone https://github.com/davisking/dlib.git

Build the main dlib library:

cd dlib
mkdir build; cd build; cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1; cmake --build .

Build and install the Python extensions:

cd ..
python3 setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA

At this point, you should be able to run python3 and type import dlib successfully.

If you run into issues with a Boost dependency and if you're not careful, like me, you'll have Boost linking with Python 2. No worries, you can solve the issue with this:

brew reinstall boost-python --with-python3 --without-python

Good luck!

in mac os x:
build fail

[100%] Linking CXX shared library dlib.so
Undefined symbols for architecture x86_64:
"boost::python::detail::init_module(char const*, void (*)())", referenced from:
initdlib in dlib.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dlib.so] Error 1
make[1]: *** [CMakeFiles/dlib
.dir/all] Error 2
make: *** [all] Error 2
error: cmake build failed!

@mathslimin reinstall Boost with the command in my previous comment to solve that error.

centos:
after
yum install python34-devel
yum install boost-devel

python3
import dlib
ImportError: /usr/lib64/python3.4/site-packages/dlib-19.4.99-py3.4-linux-x86_64.egg/dlib/dlib.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE

RatchananPrasan commented Apr 4, 2017 edited

How to install dlib on Windows or it's only on MacOS or Linux ?
I can not use cmake.

Lily520 commented Apr 8, 2017

When I run in ubuntu : cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1
there are some clues:
-- C++11 activated (compiler doesn't have full C++11 support).
-- Searching for BLAS and LAPACK
-- checking for module 'cblas'
-- package 'cblas' not found
-- checking for module 'lapack'
-- package 'lapack' not found
-- Found Intel MKL BLAS/LAPACK library
-- Configuring done
-- Generating done
-- Build files have been written to: /home/zhoulili/install/dlib/build

so,was cmake successful?

Lily520 commented Apr 8, 2017

when I run :cmake --build .
there was error:
In file included from /home/zhoulili/install/dlib/dlib/dnn/cpu_dlib.cpp:9:0:
/home/zhoulili/install/dlib/dlib/dnn/tensor_tools.h:1365:36: error: ‘<::’ cannot begin a template-argument list [-fpermissive]
/home/zhoulili/install/dlib/dlib/dnn/tensor_tools.h:1365:36: note: ‘<:’ is an alternate spelling for ‘[’. Insert whitespace between ‘<’ and ‘::’
/home/zhoulili/install/dlib/dlib/dnn/tensor_tools.h:1365:36: note: (if you use ‘-fpermissive’ G++ will accept your code)
make[2]: *** [dlib/CMakeFiles/dlib.dir/dnn/cpu_dlib.cpp.o] Error 1
make[1]: *** [dlib/CMakeFiles/dlib.dir/all] Error 2
make: *** [all] Error 2

could you tell me how I shold do next?

RatchananPrasan commented Apr 15, 2017 edited

I run
python3 setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA
in Raspberry Pi 3 and ram are not enough to run at 96% "object_detection.cpp.o" .

zr0z commented Apr 20, 2017

@RatchananPrasan I had the same issue.

I solved it by running in console without X and closing most of services (SSH, VNC,...) in raspi-config.
I also grew the size of the Swapfile temporarily to 1024 Mb (The link I used).

I hit the error on the step of 'python3 setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA' in my MacOS.
[ 99%] Building CXX object CMakeFiles/dlib_.dir/src/gui.cpp.o
make[2]: *** No rule to make target /Users/winnerineast/anaconda/lib/libpython3.6.dylib', needed bydlib.so'. Stop.
make[1]: *** [CMakeFiles/dlib_.dir/all] Error 2
make: *** [all] Error 2
error: cmake build failed!

elf55 commented Apr 26, 2017

In response to winnerineast: this failed because the anaconda distro name for the referenced lib is libpython3.6m.dylab. There are probably several correct way you can fix this, but I just edited the setup.py file to insert the "m". It's on line 526 and the block you are looking for is:

# by default, cmake will choose the system python lib in /usr/lib
# this checks the sysconfig and will correctly pick up a brewed python lib
# e.g. in /usr/local/Cellar
py_ver = get_python_version()
py_lib = os.path.join(get_config_var('LIBDIR'), 'libpython'+py_ver+'m'+'.dylib')
cmake_extra_arch += ['-DPYTHON_LIBRARY={lib}'.format(lib=py_lib)]

The edit is to insert +'m' into the py_lib string. After that, it should complete the make without the error.

Will this work for python2?

CristaLCorp commented May 12, 2017 edited

Hi, i'm using Kali, followed all the steps :
Install libboost, compile dlib... but

if I install libboost-all-dev, dlib can't import libboost_python.so.1.64.0 (as I believe it installs the 1.62 version)
if i compile libboost 1.64 from source, it complains that "undefined symbol: PyClass_Type" (which was supposed to be an old bug fixed in version 1.47).
Is there a workaround like compile option for dlib to use 1.62 ? or am i doing something wrong ?

thanks

sunyongke commented May 15, 2017 edited

I meet a error in the Mac OSX sierra(10.12.4)
anybody help me?

In file included from /usr/local/include/boost/function/function0.hpp:11:
In file included from /usr/local/include/boost/function/detail/maybe_include.hpp:13:
In file included from /usr/local/include/boost/function/function_template.hpp:13:
In file included from /usr/local/include/boost/function/detail/prologue.hpp:13:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:865:22: error: invalid operands to binary expression ('dlib::full_object_detection' and 'const dlib::full_object_detection')
if (*__first == _value)
~~~~~~~~ ^ ~~~~~~~~
/usr/local/include/boost/python/suite/indexing/vector_indexing_suite.hpp:146:25: note: in instantiation of function template specialization 'std::__1::find<std::__1::__wrap_iter<dlib::full_object_detection *>, dlib::full_object_detection>' requested here
return std::find(container.begin(), container.end(), key)
^
/usr/local/include/boost/python/suite/indexing/indexing_suite.hpp:279:41: note: in instantiation of member function 'boost::python::vector_indexing_suite<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, false, boost::python::detail::final_vector_derived_policies<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, false> >::contains' requested here
return DerivedPolicies::contains(container, x());
^
/usr/local/include/boost/python/suite/indexing/indexing_suite.hpp:185:39: note: in instantiation of member function 'boost::python::indexing_suite<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::final_vector_derived_policies<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, false>, false, false, dlib::full_object_detection, unsigned long, dlib::full_object_detection>::base_contains' requested here
.def("contains", &base_contains)
^
/usr/local/include/boost/python/def_visitor.hpp:31:29: note: in instantiation of function template specialization 'boost::python::indexing_suite<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::final_vector_derived_policies<std::__1::vector<dlib::full_object_detection, std::_1::allocatordlib::full_object_detection >, false>, false, false, dlib::full_object_detection, unsigned long, dlib::full_object_detection>::visit<boost::python::class<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified> >' requested here
v.derived_visitor().visit(c);
^
/usr/local/include/boost/python/def_visitor.hpp:67:29: note: in instantiation of function template specialization 'boost::python::def_visitor_access::visit<boost::python::def_visitor<boost::python::indexing_suite<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::final_vector_derived_policies<std::__1::vector<dlib::full_object_detection, std::_1::allocatordlib::full_object_detection >, false>, false, false, dlib::full_object_detection, unsigned long, dlib::full_object_detection> >, boost::python::class<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified> >' requested here
def_visitor_access::visit(*this, c);
^
/usr/local/include/boost/python/class.hpp:225:17: note: in instantiation of function template specialization 'boost::python::def_visitor<boost::python::indexing_suite<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::final_vector_derived_policies<std::__1::vector<dlib::full_object_detection, std::_1::allocatordlib::full_object_detection >, false>, false, false, dlib::full_object_detection, unsigned long, dlib::full_object_detection> >::visit<boost::python::class<std::__1::vector<dlib::full_object_detection, std::_1::allocatordlib::full_object_detection >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified> >' requested here
visitor.visit(*this);
^
/Users/syk/Downloads/dlib/tools/python/src/face_recognition.cpp:164:10: note: in instantiation of function template specialization 'boost::python::class
<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>::def<boost::python::indexing_suite<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, boost::python::detail::final_vector_derived_policies<std::__1::vector<dlib::full_object_detection, std::__1::allocatordlib::full_object_detection >, false>, false, false, dlib::full_object_detection, unsigned long, dlib::full_object_detection> >' requested here
.def(vector_indexing_suite())
^
/usr/local/include/dlib/svm/../graph_utils/sample_pair.h:118:17: note: candidate function not viable: no known conversion from 'dlib::full_object_detection' to 'const dlib::sample_pair' for 1st argument
inline bool operator == (
^
/usr/local/include/dlib/svm/../graph_utils/ordered_sample_pair.h:64:17: note: candidate function not viable: no known conversion from 'dlib::full_object_detection' to 'const dlib::ordered_sample_pair' for 1st argument
inline bool operator == (
^
/usr/local/include/dlib/array2d/../geometry/../image_processing/../image_transforms/../simd/simd4i.h:265:19: note: candidate function not viable: no known conversion from 'dlib::full_object_detection' to 'const dlib::simd4i' for 1st argument
inline simd4i operator== (const simd4i& lhs, const simd4i& rhs)
^
/usr/local/include/dlib/array2d/../geometry/../image_processing/../image_transforms/../simd/simd4f.h:253:24: note: candidate function not viable: no known conversion from 'dlib::full_object_detection' to 'const dlib::simd4f' for 1st argument
inline simd4f_bool operator== (const simd4f& lhs, const simd4f& rhs)
^
/usr/local/include/dlib/simd/simd8i.h:239:19: note: candidate function not viable: no known conversion from 'dlib::full_object_detection' to 'const dlib::simd8i' for 1st argument
inline simd8i operator== (const simd8i& lhs, const simd8i& rhs)
^
/usr/local/include/dlib/simd/simd8f.h:216:24: note: candidate function not viable: no known conversion from 'dlib::full_object_detection' to 'const dlib::simd8f' for 1st argument
inline simd8f_bool operator== (const simd8f& lhs, const simd8f& rhs)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/utility:414:1: note: candidate template ignored: could not match 'pair<type-parameter-0-0, type-parameter-0-1>' against 'dlib::full_object_detection'
operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:584:1: note: candidate template ignored: could not match 'reverse_iterator' against 'dlib::full_object_detection'
operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:885:6: note: candidate template ignored: could not match 'istreambuf_iterator<type-parameter-0-0, type-parameter-0-1>' against 'dlib::full_object_detection'
bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a,
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:988:1: note: candidate template ignored: could not match 'move_iterator' against 'dlib::full_object_detection'
operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iterator:1304:1: note: candidate template ignored: could not match '__wrap_iter' against 'dlib::full_object_detection'
operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/tuple:909:1: note: candidate template ignored: could not match 'tuple<type-parameter-0-0...>' against 'dlib::full_object_detection'
operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:1903:6: note: candidate template ignored: could not match 'allocator' against 'dlib::full_object_detection'
bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2985:1: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'dlib::full_object_detection'
operator==(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {return __x.get() == __y.get();}
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3021:1: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'dlib::full_object_detection'
operator==(const unique_ptr<_T1, _D1>& __x, nullptr_t) _NOEXCEPT
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:3029:1: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'const dlib::full_object_detection'
operator==(nullptr_t, const unique_ptr<_T1, _D1>& __x) _NOEXCEPT
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4873:1: note: candidate template ignored: could not match 'shared_ptr' against 'dlib::full_object_detection'
operator==(const shared_ptr<_Tp>& __x, const shared_ptr<_Up>& __y) _NOEXCEPT
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4922:1: note: candidate template ignored: could not match 'shared_ptr' against 'dlib::full_object_detection'
operator==(const shared_ptr<_Tp>& __x, nullptr_t) _NOEXCEPT
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:4930:1: note: candidate template ignored: could not match 'shared_ptr' against 'const dlib::full_object_detection'
operator==(nullptr_t, const shared_ptr<_Tp>& _x) NOEXCEPT
^
/usr/local/include/dlib/smart_pointers/shared_ptr.h:464:10: note: candidate template ignored: could not match 'shared_ptr' against 'dlib::full_object_detection'
bool operator== (
^
/usr/local/include/dlib/matrix/lapack/../matrix.h:935:10: note: candidate template ignored: could not match 'matrix_exp' against 'dlib::full_object_detection'
bool operator== (
^
/usr/local/include/dlib/svm/../std_allocator.h:173:10: note: candidate template ignored: could not match 'std_allocator<type-parameter-0-0, type-parameter-0-1>' against 'dlib::full_object_detection'
bool operator== (
^
/usr/local/include/dlib/matrix/matrix_utilities.h:1349:97: note: candidate template ignored: could not match 'matrix_exp' against 'dlib::full_object_detection'
const typename enable_if<is_built_in_scalar_type, matrix_op<op_equal_to<EXP,S> > >::type operator== (
^
/usr/local/include/dlib/matrix/matrix_utilities.h:1366:97: note: candidate template ignored: could not match 'matrix_exp' against 'const dlib::full_object_detection'
const typename enable_if<is_built_in_scalar_type, matrix_op<op_equal_to<EXP,S> > >::type operator== (
^
/usr/local/include/dlib/smart_pointers/shared_ptr_thread_safe.h:432:10: note: candidate template ignored: could not match 'shared_ptr_thread_safe' against 'dlib::full_object_detection'
bool operator== (
^
/usr/local/include/dlib/threads/thread_pool_extension.h:107:32: note: candidate template ignored: could not match 'future' against 'dlib::full_object_detection'
template bool operator== (const future& a, const future& b) { return a.get() == b.get(); }
^
/usr/local/include/dlib/threads/thread_pool_extension.h:114:32: note: candidate template ignored: could not match 'future' against 'dlib::full_object_detection'
template bool operator== (const future& a, const T& b) { return a.get() == b; }
^
/usr/local/include/dlib/threads/thread_pool_extension.h:115:32: note: candidate template ignored: could not match 'future' against 'const dlib::full_object_detection'
template bool operator== (const T& a, const future& b) { return a == b.get(); }
^
/usr/local/include/dlib/svm/../unordered_pair.h:96:10: note: candidate template ignored: could not match 'unordered_pair' against 'dlib::full_object_detection'
bool operator==(const unordered_pair& a, const unordered_pair & b)
^
4 warnings and 1 error generated.
make[2]: *** [CMakeFiles/dlib
.dir/src/face_recognition.cpp.o] Error 1
make[1]: *** [CMakeFiles/dlib
.dir/all] Error 2
make: *** [all] Error 2
error: cmake build failed!

ok, i think no one is reading that feed anymore :)
I 've been trying on debian (jessie), got other problems...
maybe using the VM iso is our best chance

chriship commented May 23, 2017 edited

I keep receiving the following error when trying to build the main library. I've tried removing and reinstalling libpng but no luck. Anyone have a suggestion for me?

[100%] Linking CXX shared library libdlib.dylib
Undefined symbols for architecture x86_64:
  "_png_set_longjmp_fn", referenced from:
      dlib::png_loader::read_image(char const*) in png_loader.cpp.o
      dlib::png_loader_user_error_fn_silent(png_struct_def*, char const*) in png_loader.cpp.o
      dlib::png_reader_user_error_fn_silent(png_struct_def*, char const*) in save_png.cpp.o
      dlib::impl::impl_save_png(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<unsigned char*, std::__1::allocator<unsigned char*> >&, long, dlib::impl::png_type, int) in save_png.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dlib/libdlib.19.4.99.dylib] Error 1
make[1]: *** [dlib/CMakeFiles/dlib_shared.dir/all] Error 2
make: *** [all] Error 2

EDIT: Turns out my issue was something to do with libpng inside php5. I simply removed php5 and it installed.

looks like no one knows how to install dlib in windows

adamleo commented Jun 9, 2017

@elf55 BIG THUMB UP! Thanks!

erivandoramos commented Jun 9, 2017 edited

Hi!

The my installation sudo python setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA failed here:

**[ 97%] Building CXX object CMakeFiles/dlib_.dir/src/face_recognition.cpp.o
c++: internal compiler error: Morto (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
CMakeFiles/dlib_.dir/build.make:446: recipe for target 'CMakeFiles/dlib_.dir/src/face_recognition.cpp.o' failed
make[2]: *** [CMakeFiles/dlib_.dir/src/face_recognition.cpp.o] Error 4
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/dlib_.dir/all' failed
make[1]: *** [CMakeFiles/dlib_.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
error: cmake build failed!**

There is a solution ??

I get this after 99%. Help, stuck here since forever!

[ 95%] Building CXX object CMakeFiles/dlib_.dir/src/object_detection.cpp.o
[ 96%] Building CXX object CMakeFiles/dlib_.dir/src/shape_predictor.cpp.o
[ 97%] Building CXX object CMakeFiles/dlib_.dir/src/correlation_tracker.cpp.o
[ 98%] Building CXX object CMakeFiles/dlib_.dir/src/face_recognition.cpp.o
[ 99%] Building CXX object CMakeFiles/dlib_.dir/src/gui.cpp.o
make[2]: *** No rule to make target `/Users/cereteam/anaconda3/lib/libpython3.6.dylib', needed by `dlib.so'.  Stop.
make[1]: *** [CMakeFiles/dlib_.dir/all] Error 2
make: *** [all] Error 2
error: cmake build failed!

After following the installation steps, i still get this message whenever trying to import dlib or even face_recognition:

$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import dlib
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/dlib-19.4.99-py2.7-linux-x86_64.egg/dlib/init.py", line 1, in
from .dlib import *
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory

Any idea what this could be? I have cuda 8.0 correctly installed in ubuntu 16.04

thanks for ageitgey that build such amazing project.
here I just want to show a issue that I solved in my machine, maybe can help someone.
I just follow the step to build dlib from source and then build face_recognition, when I run example, it shows me Illegal Instruction. When I first changed set(USE_SSE4_INSTRUCTIONS ON CACHE BOOL "Use SSE4 instructions")
to: set(USE_SSE2_INSTRUCTIONS ON CACHE BOOL "Use SSE2 instructions")
and recompile dlib again, but find it still the same problem.
Then I use cat /proc/cpuinfo, find my flag:
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm tsc_adjust dtherm arat

I found my cpu support sse2, also sse4, so the steps above did not help me. and also I found my cpu doesn't support avx, so when I compile again with following command and then I success. hope can help you

cmake .. -DDLIB_USE_CUDA=0; cmake --build .

python3 setup.py install --no USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA

SteinCoda commented Aug 17, 2017 edited

Hi @erivandoramos I meet the same error.

When I try :python setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA
error: c++: internal compiler error
reason: maybe memory not enough
solution:
1、change you virtual machine memory ( it works for me ! )
2、change spaw space ubuntu How to change spaw space or similar issue

How do you do this on Windows?

Re install the boost package in case of CMake Error with Boost not found
sudo apt-get install libboost-all-dev

limsan commented Sep 15, 2017

Strange, freeze after some point.
I use anaconda with python=3.5.3 on windows 10
successfully compiled the previous steps using CUDA.
python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA
compiler msvc 2017
...
rectangles.cpp
object_detection.cpp
shape_predictor.cpp
correlation_tracker.cpp
face_recognition.cpp

stopped here, no errors or warning,

I tried with pip install face_recognition
, but at
Running setup.py bdist_wheel for dlib ... -
it also stopped, no errors nor warning

These instructions aren't right. In particular, you don't need to do this to build the python binding:

cd dlib
mkdir build; cd build; cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1; cmake --build .

That's unnecessary and unrelated to building the python API.

@mathslimin did you solve that problem,and how?plz

jcbloch commented Oct 7, 2017 edited

this fails on Mac OS X 10.12.6 (and setup.py will then fail)

$ brew install boost-python --with-python3 --without-python ==> Installing dependencies for boost-python: boost ==> Installing boost-python dependency: boost ==> Downloading https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.bz2 ######################################################################## 100.0% ==> ./bootstrap.sh --prefix=/usr/local/Cellar/boost/1.65.1 --libdir=/usr/local/Cellar/boost/1.65.1/lib --without-icu --without-libraries=python,mpi ==> ./b2 headers ==> ./b2 --prefix=/usr/local/Cellar/boost/1.65.1 --libdir=/usr/local/Cellar/boost/1.65.1/lib -d2 -j8 --layout=tagged --user-config=user-config.jam -sNO_LZMA=1 install threadi /usr/local/Cellar/boost/1.65.1: 12,681 files, 432.1MB, built in 12 minutes 24 seconds ==> Installing boost-python --without-python --with-python3 ==> Downloading https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.bz2 ######################################################################## 100.0% Error: boost was built in C++11 mode so boost-python must be built with --c++11.

instead, install just boost first, then boost-python:

$ brew install boost
$ brew install boost-python --with-python3 --without-python

and follow rest of directions above...

does it matter where clone the directory

git clone https://github.com/davisking/dlib.git

Can I clone it into my home directory?

[ 86%] Built target dlib
Scanning dependencies of target dlib_
[ 87%] Building CXX object CMakeFiles/dlib_.dir/src/dlib.cpp.o
In file included from /usr/include/boost/python/detail/prefix.hpp:13:0,
                 from /usr/include/boost/python/args.hpp:8,
                 from /usr/include/boost/python.hpp:11,
                 from /root/dlib/tools/python/src/dlib.cpp:4:
/usr/include/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory
compilation terminated.
CMakeFiles/dlib_.dir/build.make:62: recipe for target 'CMakeFiles/dlib_.dir/src/dlib.cpp.o' failed
error: cmake build failed!
  • why?

you must use python 3.5 version

adriangay commented Oct 18, 2017 edited

as noted by @davisking, building dlib for Python is not required - just do
pip3 install face_recognition
if cmake is missing then just install it. On OSX:
brew install cmake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment