Issue installing dlib on Jetson AGX Xavier

Hi,
I’m trying to install dlib libray (wget http://dlib.net/files/dlib-19.17.tar.bz2) on the Jetson AGX Xavier.

I downloaded and uncompressed the source code for dlib. Before compiling it, I commented the “forward_algo = forward_best_algo;” line in the dlib/cuda/cudnn_dlibapi.cpp file.

After that, I run this command to compile and install dlib:

sudo python3 setup.py install

but it won’t work.

The output I get by running the previous command is:

$ sudo python3 setup.py install
running install
running bdist_egg
running egg_info
creating dlib.egg-info
writing dlib.egg-info/PKG-INFO
writing dependency_links to dlib.egg-info/dependency_links.txt
writing top-level names to dlib.egg-info/top_level.txt
writing manifest file ‘dlib.egg-info/SOURCES.txt’
package init file ‘dlib/init.py’ not found (or not a regular file)
reading manifest file ‘dlib.egg-info/SOURCES.txt’
reading manifest template ‘MANIFEST.in’
writing manifest file ‘dlib.egg-info/SOURCES.txt’
installing library code to build/bdist.linux-aarch64/egg
running install_lib
running build_py
running build_ext
Building extension for Python 3.6.9 (default, Nov 7 2019, 10:44:02)
Invoking CMake setup: ‘cmake /home/xavier/dlib-19.17/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/xavier/dlib-19.17/build/lib.linux-aarch64-3.6 -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Release’
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a “project(Project)” command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.

– The C compiler identification is GNU 7.4.0
– The CXX compiler identification is GNU 7.4.0
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found PythonInterp: /usr/bin/python3 (found version “3.6.9”)
– Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.6m.so
– Performing Test HAS_CPP14_FLAG
– Performing Test HAS_CPP14_FLAG - Success
– pybind11 v2.2.2
– Using CMake version: 3.15.2
– Compiling dlib version: 19.17.0
– Looking for pthread.h
– Looking for pthread.h - found
– Performing Test CMAKE_HAVE_LIBC_PTHREAD
– Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
– Looking for pthread_create in pthreads
– Looking for pthread_create in pthreads - not found
– Looking for pthread_create in pthread
– Looking for pthread_create in pthread - found
– Found Threads: TRUE
– Found X11: /usr/include
– Looking for XOpenDisplay in /usr/lib/aarch64-linux-gnu/libX11.so;/usr/lib/aarch64-linux-gnu/libXext.so
– Looking for XOpenDisplay in /usr/lib/aarch64-linux-gnu/libX11.so;/usr/lib/aarch64-linux-gnu/libXext.so - found
– Looking for gethostbyname
– Looking for gethostbyname - found
– Looking for connect
– Looking for connect - found
– Looking for remove
– Looking for remove - found
– Looking for shmat
– Looking for shmat - found
– Looking for IceConnectionNumber in ICE
– Looking for IceConnectionNumber in ICE - found
– Looking for png_create_read_struct
– Looking for png_create_read_struct - found
– Looking for jpeg_read_header
– Looking for jpeg_read_header - found
– Searching for BLAS and LAPACK
– Searching for BLAS and LAPACK
– Found PkgConfig: /usr/bin/pkg-config (found version “0.29.1”)
– Checking for module ‘cblas’
– No package ‘cblas’ found
– Checking for module ‘lapack’
– Found lapack, version 0.2.20+ds
– Looking for sys/types.h
– Looking for sys/types.h - found
– Looking for stdint.h
– Looking for stdint.h - found
– Looking for stddef.h
– Looking for stddef.h - found
– Check size of void*
– Check size of void* - done
– Found OpenBLAS library
– Looking for sgetrf_single
– Looking for sgetrf_single - found
– Using OpenBLAS’s built in LAPACK
– Looking for cblas_ddot
– Looking for cblas_ddot - found
– Looking for sgesv
– Looking for sgesv - not found
– Looking for sgesv_
– Looking for sgesv_ - not found
– Found CUDA: /usr/local/cuda (found suitable version “10.0”, minimum required is “7.5”)
– Looking for cuDNN install…
– Found cuDNN: /usr/local/cuda/lib64/libcudnn.so
– Building a CUDA test project to see if your compiler is compatible with CUDA…
– Checking if you have the right version of cuDNN installed.
– Enabling CUDA support for dlib. DLIB WILL USE CUDA
– C++11 activated.
– Configuring done
– Generating done
– Build files have been written to: /home/xavier/dlib-19.17/build/temp.linux-aarch64-3.6
Invoking CMake build: ‘cmake --build . --config Release – -j8’
[ 2%] Building NVCC (Device) object dlib_build/CMakeFiles/dlib.dir/cuda/dlib_generated_cusolver_dlibapi.cu.o
[ 2%] Building NVCC (Device) object dlib_build/CMakeFiles/dlib.dir/cuda/dlib_generated_cuda_dlib.cu.o
Scanning dependencies of target dlib
[ 3%] Building CXX object dlib_build/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o
[ 4%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o
[ 5%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o
[ 6%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o
[ 7%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_1.cpp.o
[ 8%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_2.cpp.o
[ 9%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_1.cpp.o
[ 10%] Building CXX object dlib_build/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_2.cpp.o
[ 11%] Building CXX object dlib_build/CMakeFiles/dlib.dir/md5/md5_kernel_1.cpp.o
[ 12%] Building CXX object dlib_build/CMakeFiles/dlib.dir/tokenizer/tokenizer_kernel_1.cpp.o
[ 13%] Building CXX object dlib_build/CMakeFiles/dlib.dir/unicode/unicode.cpp.o
[ 15%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o
[ 16%] Building CXX object dlib_build/CMakeFiles/dlib.dir/data_io/mnist.cpp.o
[ 17%] Building CXX object dlib_build/CMakeFiles/dlib.dir/global_optimization/global_function_search.cpp.o
[ 18%] Building CXX object dlib_build/CMakeFiles/dlib.dir/filtering/kalman_filter.cpp.o
[ 19%] Building CXX object dlib_build/CMakeFiles/dlib.dir/test_for_odr_violations.cpp.o
[ 20%] Building CXX object dlib_build/CMakeFiles/dlib.dir/svm/auto.cpp.o
[ 21%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_1.cpp.o
[ 22%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bsp/bsp.cpp.o
[ 23%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_1.cpp.o
[ 24%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_kernel_2.cpp.o
[ 25%] Building CXX object dlib_build/CMakeFiles/dlib.dir/dir_nav/dir_nav_extensions.cpp.o
[ 26%] Building CXX object dlib_build/CMakeFiles/dlib.dir/linker/linker_kernel_1.cpp.o
[ 27%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/extra_logger_headers.cpp.o
[ 29%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_kernel_1.cpp.o
[ 30%] Building CXX object dlib_build/CMakeFiles/dlib.dir/logger/logger_config_file.cpp.o
[ 31%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_1.cpp.o
[ 32%] Building CXX object dlib_build/CMakeFiles/dlib.dir/misc_api/misc_api_kernel_2.cpp.o
[ 33%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_extensions.cpp.o
[ 34%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockets/sockets_kernel_2.cpp.o
[ 35%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf.cpp.o
[ 36%] Building CXX object dlib_build/CMakeFiles/dlib.dir/sockstreambuf/sockstreambuf_unbuffered.cpp.o
[ 37%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_kernel.cpp.o
[ 38%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_iostream.cpp.o
[ 39%] Building CXX object dlib_build/CMakeFiles/dlib.dir/server/server_http.cpp.o
[ 40%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/multithreaded_object_extension.cpp.o
[ 41%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threaded_object_extension.cpp.o
[ 43%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_1.cpp.o
[ 44%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_2.cpp.o
[ 45%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/threads_kernel_shared.cpp.o
[ 46%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/thread_pool_extension.cpp.o
[ 47%] Building CXX object dlib_build/CMakeFiles/dlib.dir/threads/async.cpp.o
[ 48%] Building CXX object dlib_build/CMakeFiles/dlib.dir/timer/timer.cpp.o
[ 49%] Building CXX object dlib_build/CMakeFiles/dlib.dir/stack_trace.cpp.o
[ 50%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cpu_dlib.cpp.o
[ 51%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/tensor_tools.cpp.o
[ 52%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/fonts.cpp.o
[ 53%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/widgets.cpp.o
[ 54%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/drawable.cpp.o
[ 55%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/canvas_drawing.cpp.o
[ 56%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/style.cpp.o
[ 58%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_widgets/base_widgets.cpp.o
[ 59%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_1.cpp.o
[ 60%] Building CXX object dlib_build/CMakeFiles/dlib.dir/gui_core/gui_core_kernel_2.cpp.o
[ 61%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/png_loader.cpp.o
[ 62%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_png.cpp.o
[ 63%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_loader/jpeg_loader.cpp.o
[ 64%] Building CXX object dlib_build/CMakeFiles/dlib.dir/image_saver/save_jpeg.cpp.o
[ 65%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cudnn_dlibapi.cpp.o
[ 66%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cublas_dlibapi.cpp.o
[ 67%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/curand_dlibapi.cpp.o
[ 68%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/cuda_data_ptr.cpp.o
[ 69%] Building CXX object dlib_build/CMakeFiles/dlib.dir/cuda/gpu_data.cpp.o
[ 70%] Linking CXX static library libdlib.a
[ 70%] Built target dlib
Scanning dependencies of target dlib_python
[ 72%] Building CXX object CMakeFiles/dlib_python.dir/src/dlib.cpp.o
[ 73%] Building CXX object CMakeFiles/dlib_python.dir/src/matrix.cpp.o
[ 74%] Building CXX object CMakeFiles/dlib_python.dir/src/vector.cpp.o
[ 75%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_c_trainer.cpp.o
[ 76%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_rank_trainer.cpp.o
[ 77%] Building CXX object CMakeFiles/dlib_python.dir/src/decision_functions.cpp.o
[ 78%] Building CXX object CMakeFiles/dlib_python.dir/src/other.cpp.o
[ 79%] Building CXX object CMakeFiles/dlib_python.dir/src/basic.cpp.o
[ 80%] Building CXX object CMakeFiles/dlib_python.dir/src/cca.cpp.o
[ 81%] Building CXX object CMakeFiles/dlib_python.dir/src/sequence_segmenter.cpp.o
[ 82%] Building CXX object CMakeFiles/dlib_python.dir/src/svm_struct.cpp.o
[ 83%] Building CXX object CMakeFiles/dlib_python.dir/src/image.cpp.o
[ 84%] Building CXX object CMakeFiles/dlib_python.dir/src/image2.cpp.o
[ 86%] Building CXX object CMakeFiles/dlib_python.dir/src/image3.cpp.o
[ 87%] Building CXX object CMakeFiles/dlib_python.dir/src/image4.cpp.o
[ 88%] Building CXX object CMakeFiles/dlib_python.dir/src/rectangles.cpp.o
[ 89%] Building CXX object CMakeFiles/dlib_python.dir/src/object_detection.cpp.o
[ 90%] Building CXX object CMakeFiles/dlib_python.dir/src/shape_predictor.cpp.o
[ 91%] Building CXX object CMakeFiles/dlib_python.dir/src/correlation_tracker.cpp.o
[ 92%] Building CXX object CMakeFiles/dlib_python.dir/src/face_recognition.cpp.o
[ 93%] Building CXX object CMakeFiles/dlib_python.dir/src/cnn_face_detector.cpp.o
[ 94%] Building CXX object CMakeFiles/dlib_python.dir/src/global_optimization.cpp.o
[ 95%] Building CXX object CMakeFiles/dlib_python.dir/src/image_dataset_metadata.cpp.o
[ 96%] Building CXX object CMakeFiles/dlib_python.dir/src/numpy_returns.cpp.o
[ 97%] Building CXX object CMakeFiles/dlib_python.dir/src/line.cpp.o
[ 98%] Building CXX object CMakeFiles/dlib_python.dir/src/gui.cpp.o
[100%] Linking CXX shared module /home/xavier/dlib-19.17/build/lib.linux-aarch64-3.6/dlib.cpython-36m-aarch64-linux-gnu.so
/usr/local/cuda/lib64/libcudnn.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
CMakeFiles/dlib_python.dir/build.make:475: recipe for target ‘/home/xavier/dlib-19.17/build/lib.linux-aarch64-3.6/dlib.cpython-36m-aarch64-linux-gnu.so’ failed
make[2]: *** [/home/xavier/dlib-19.17/build/lib.linux-aarch64-3.6/dlib.cpython-36m-aarch64-linux-gnu.so] Error 1
CMakeFiles/Makefile2:80: recipe for target ‘CMakeFiles/dlib_python.dir/all’ failed
make[1]: *** [CMakeFiles/dlib_python.dir/all] Error 2
Makefile:83: recipe for target ‘all’ failed
make: *** [all] Error 2
Traceback (most recent call last):
File “setup.py”, line 261, in
‘Topic :: Software Development’,
File “/usr/local/lib/python3.6/dist-packages/setuptools/init.py”, line 145, in setup
return distutils.core.setup(**attrs)
File “/usr/lib/python3.6/distutils/core.py”, line 148, in setup
dist.run_commands()
File “/usr/lib/python3.6/distutils/dist.py”, line 955, in run_commands
self.run_command(cmd)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/local/lib/python3.6/dist-packages/setuptools/command/install.py”, line 67, in run
self.do_egg_install()
File “/usr/local/lib/python3.6/dist-packages/setuptools/command/install.py”, line 109, in do_egg_install
self.run_command(‘bdist_egg’)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/local/lib/python3.6/dist-packages/setuptools/command/bdist_egg.py”, line 172, in run
cmd = self.call_command(‘install_lib’, warn_dir=0)
File “/usr/local/lib/python3.6/dist-packages/setuptools/command/bdist_egg.py”, line 158, in call_command
self.run_command(cmdname)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “/usr/local/lib/python3.6/dist-packages/setuptools/command/install_lib.py”, line 11, in run
self.build()
File “/usr/lib/python3.6/distutils/command/install_lib.py”, line 109, in build
self.run_command(‘build_ext’)
File “/usr/lib/python3.6/distutils/cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “/usr/lib/python3.6/distutils/dist.py”, line 974, in run_command
cmd_obj.run()
File “setup.py”, line 135, in run
self.build_extension(ext)
File “setup.py”, line 175, in build_extension
subprocess.check_call(cmake_build, cwd=build_folder)
File “/usr/lib/python3.6/subprocess.py”, line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘cmake’, ‘–build’, ‘.’, ‘–config’, ‘Release’, ‘–’, ‘-j8’]’ returned non-zero exit status 2.

Did anyone have the same problem with this library and know how to solve it?

Thanks in advance

Hi,

It looks like you are facing the similar issue of this issue:
https://github.com/facebookarchive/caffe2/issues/1887

Could you check if the NO_SYSTEM_ENVIRONMENT_PATH setting also works for you?
Thanks.

Hi,

It doesn’t seem to exist the cmake/public/cuda.cmake file. I cannot find the public folder.
Do you know how to help me?

Hi,

We are trying to reproduce this issue currently.

Do you follow the similar building steps like this:
https://devtalk.nvidia.com/default/topic/1049660/jetson-nano/issues-with-dlib-library/post/5336330/#5336330

Thanks.

Yes, I followed the building steps in that link but it doesn’t work.

May it be a problem with the cuda and cuDNN installation?

Hi,

We can setup dlib with python3 successfully.

...
Installed /usr/local/lib/python3.6/dist-packages/dlib-19.17.0-py3.6-linux-aarch64.egg
Processing dependencies for dlib==19.17.0
Finished processing dependencies for dlib==19.17.0

Here is our steps for your reference:

1. Setup device with JetPack4.3.

2. Build dlib from source.

$ wget http://dlib.net/files/dlib-19.17.tar.bz2
$ tar jxvf dlib-19.17.tar.bz2
cd dlib-19.17/
mkdir build
cd build/
cmake ..
cmake --build .
$ cd ../
$ sudo python3 setup.py install

Thanks.

Hi,
thanks for sharing your steps.
I run the jetsonInfo.py (git clone https://github.com/jetsonhacks/jetsonUtilities)to find out how the device was setup:

L4T 32.2.1 [JetPack 4.2.2]
Ubuntu 18.0.4 LTS
kernel version 4.9.140-tegra
cuda 10.0.326

Is it necessary to setup the device again with JetPack4.3?

Thank you for the help!
I successfully installed dlib reflashing the device with JetPack4.3.