Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dlib hangs when building on Google Coral dev board

I am struggling with installing latest version of dlib (http://dlib.net/, v19.17) for Python on the Google Coral Dev Board. It works well with Raspberry Pi 3 B+ (that seems to have exactly the same CPU and amount of RAM), but gets stuck on the Coral Dev Board at 80% (while compiling vector.cpp). This happens when you run running:

python3 setup.py install

I have tried following on Mendel Linux (that Dev Board runs) without any success:

  • upgrading the cmake to the latest version,
  • changing number of cores that setup.py uses to build dlib
  • adding SWAP file

The main difference I have seen between RPI and Coral/Mendel is older versions of cmake and gcc on Mendel.

I have upgraded cmake to the latest version without any success, but have not touched the gcc yet.

like image 944
mehmandarov Avatar asked Jul 07 '19 17:07

mehmandarov


2 Answers

How much swap space did you add to it? I added 1GB in /swapfile and it's finished building.

creating build/bdist.linux-aarch64
creating build/bdist.linux-aarch64/egg
copying build/lib.linux-aarch64-3.5/dlib.cpython-35m-aarch64-linux-gnu.so -> build/bdist.linux-aarch64/egg
creating stub loader for dlib.cpython-35m-aarch64-linux-gnu.so
byte-compiling build/bdist.linux-aarch64/egg/dlib.py to dlib.cpython-35.pyc
creating build/bdist.linux-aarch64/egg/EGG-INFO
copying dlib.egg-info/PKG-INFO -> build/bdist.linux-aarch64/egg/EGG-INFO
copying dlib.egg-info/SOURCES.txt -> build/bdist.linux-aarch64/egg/EGG-INFO
copying dlib.egg-info/dependency_links.txt -> build/bdist.linux-aarch64/egg/EGG-INFO
copying dlib.egg-info/not-zip-safe -> build/bdist.linux-aarch64/egg/EGG-INFO
copying dlib.egg-info/top_level.txt -> build/bdist.linux-aarch64/egg/EGG-INFO
writing build/bdist.linux-aarch64/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/dlib-19.18.0-py3.5-linux-aarch64.egg' and adding 'build/bdist.linux-aarch64/egg' to it
removing 'build/bdist.linux-aarch64/egg' (and everything under it)
Processing dlib-19.18.0-py3.5-linux-aarch64.egg
creating /usr/local/lib/python3.5/dist-packages/dlib-19.18.0-py3.5-linux-aarch64.egg
Extracting dlib-19.18.0-py3.5-linux-aarch64.egg to /usr/local/lib/python3.5/dist-packages
Adding dlib 19.18.0 to easy-install.pth file

Installed /usr/local/lib/python3.5/dist-packages/dlib-19.18.0-py3.5-linux-aarch64.egg
Processing dependencies for dlib==19.18.0
Finished processing dependencies for dlib==19.18.0
mendel@arid-valet:~ % python3 -c 'print(__import__("dlib").__version__)'
19.18.0

Although I'm not sure if you will get full benefit of the dev board by dlib on it. Since the dev board's main advantage for fast inference is the TPU, you're better off using the tflite_runtime APIs or the provided engine to run your inferences.

like image 99
Nam Vu Avatar answered Nov 05 '22 14:11

Nam Vu


@NamVu's solution worked for me: increase size of swapfile. I was also failing to compile dlib (version: 19.19.0, CMake: 3.7.2) at vector.cpp. I increased my swap to 2GB and was able to finish the build. I mounted an external SD card and large swap file according to this excellent guide. After mounting the SD card these were the steps from the guid to create the swap file:

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
like image 1
j2abro Avatar answered Nov 05 '22 13:11

j2abro