How to build and install dlib for python without GUI support?

Viewed 365

Background:

I'm running a ‍jupyter‍ notebook on an AWS sagemaker ec2 instance (Which uses Fedora Linux) and one of my requirements is dlib. However, dlib (by default) uses xorg's x11 libs for GUI support, and these are not installed on the sagemaker instance. I do not need the GUI support, and sagemaker does not support yum installs, so I'm trying to build it without them.

I've cloned dlib's github repo and have attempted to build with python setup.py, where it throws x11 errors. I've read through the website and it says that you can define the DLIB_NO_GUI_SUPPORT preprocessor directive to compile without GUI support. Sounds great! I read through the setup.py file and see that I can add that by running python setup.py x DLIB_NO_GUI_SUPPORT where x is one of [--no, --set, --compiler-flags, and -G]. I don't know which one, so I try them all:

  • python setup.py --no DLIB_NO_GUI_SUPPORT
  • python setup.py --set DLIB_NO_GUI_SUPPORT
  • python setup.py --compiler-flags DLIB_NO_GUI_SUPPORT
  • python setup.py -G DLIB_NO_GUI_SUPPORT

None of them worked.

Question:

What is the correct syntax for setting the DLIB_NO_GUI_SUPPORT preprocessor directive for dlib using setup.py?

1 Answers

You can try to build the source first, passing -D DLIB_NO_GUI_SUPPORT to cmake. Then you can install the python wrappers as you did.

Related