Ask Your Question
0

[Solved] Cannot configure OpenCV with Python3 support in an Arm64 chroot.

asked 2018-08-21 08:35:19 -0500

g40 gravatar image

updated 2018-08-21 10:17:19 -0500

A bit complex this one. Configuring from a 3.4.1 tarball for aarch64 works if the cmake configuration stage is run on a native ARM64 machine. However, in a chroot with correctly installed Python 3 and numpy it fails. Any thoughts welcomed.

I think the core problem is CMake cannot complete the numpy probe. From the log below:

 Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)

Running python3 in the chroot gives this.

Python 3.5.3 (default, Jan 19 2017, 14:11:04)  
[GCC 6.3.0 20170118] on linux Type "help", "copyright",
"credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__ '1.15.0'

file /usr/bin/python3.5 /usr/bin/python3.5: ELF 64-bit LSB
shared object, ARM aarch64, version 1 (SYSV), dynamically linked,
interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0,
BuildID[sha1]=125327436b53ba5dbbc02d359984226437a132ce, stripped

The configuration options are (please bear in mind this is for an embedded platform so dependencies are minimized as far as possible)

cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_PYTHON3=ON -D BUILD_OPENCV_PYTHON2=OFF -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-3.4.1/modules _D WITH_NEON=ON -D BUILD_JAVA=OFF -D WITH_LAPACK=OFF -D BUILD_TESTS=OFF  -D BUILD_PERF_TESTS=OFF   -D BUILD_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D WITH_CAROTENE=OFF -D WITH_TBB=OFF -D WITH_OPENCL=OFF -D WITH_NVCUVID=OFF -D WITH_OPENCL_SVM=OFF -D WITH_OPENCLAMDFFT=OFF -D WITH_OPENCLAMDBLAS=OFF -D WITH_OPENEXR=OFF -D WITH_MATLAB=OFF -D WITH_GTK=OFF -D WITH_GSTREAMER=OFF -D WITH_GPHOTO2=OFF -D WITH_FFMPEG=OFF -D WITH_CUBLAS=OFF -D WITH_CUDA=OFF -D WITH_CUFFT=OFF -D WITH_EIGEN=OFF -D WITH_VTK=OFF -D WITH_JASPER=OFF -D WITH_WEBP=OFF -D WITH_1394=OFF -D BUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=install -D PYTHON3_LIBRARIES=usr/lib/aarch64-linux-gnu/libpython3.5m.so -D PYTHON3_LIBRARY=usr/lib/aarch64-linux-gnu/libpython3.5m.so -D PYTHON_INCLUDE_DIRS=/usr/include/python3.5m -D PYTHON3_INCLUDE_PATH=/usr/include/python3.5m -D PYTHON3_INCLUDE_DIR=/usr/include/python3.5m -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include -DPYTHON_DEFAULT_EXECUTABLE=$(which python3) -D CMAKE_TOOLCHAIN_FILE=../opencv-3.4.1/platforms/linux/aarch64-gnu.toolchain.cmake ../opencv-3.4.1 2>&1 | tee config.log

The config.log file (why no text attachments BTW?) contains this:

-- The CXX compiler identification is GNU 6.3.0
-- The C compiler identification is GNU 6.3.0
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc
-- Check for working C compiler: /usr/bin/aarch64-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test HAVE_CXX11 (check file: cmake/checks/cxx11.cpp)
-- Performing Test HAVE_CXX11 - Success
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.13", minimum required is "2.7") 
-- Could NOT find PythonLibs (missing:  PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) (Required is at least version "2.7")
-- Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)
-- If ...
(more)
edit retag flag offensive close merge delete

Comments

i'm afraid, your analysis is correct.

correctly installed Python 3 and numpy

that's for your host system, not for arm ;(

berak gravatar imageberak ( 2018-08-21 08:52:56 -0500 )edit

Thanks, can you clarify a bit?

Are you suggesting that a) CMake is failing to find the Arm64 binaries for numpy or b) it is unable to distinguish between Intel x64 and Arm aarch64 binaries in this context?

Would you regrd this as a bug?

TAIA.

g40 gravatar imageg40 ( 2018-08-21 09:29:28 -0500 )edit

i have never tried this, but the python wrappers have to link against libpython, so you would need the arm version of it

and cmake sees, that you're cross-compiling, and skips all numpy related tests (iirc, there are checks for multiarray)

berak gravatar imageberak ( 2018-08-21 09:34:59 -0500 )edit

Thanks again. The only python/numpy binaries in the chroot are aarch64, everything is being run via qemu-system-aarch64. Do you know which one of the myriad CMake support scripts carries out this check? The relevant directory contains this:

root@dev:/build/opencv# ls /usr/local/lib/python3.5/dist-packages/numpy/core
__init__.py
__pycache__
_dummy.cpython-35m-aarch64-linux-gnu.so
_internal.py
_methods.py
_multiarray_tests.cpython-35m-aarch64-linux-gnu.so
_operand_flag_tests.cpython-35m-aarch64-linux-gnu.so
_rational_tests.cpython-35m-aarch64-linux-gnu.so
_struct_ufunc_tests.cpython-35m-aarch64-linux-gnu.so
_umath_tests.cpython-35m-aarch64-linux-gnu.so
...
tests
umath.cpython-35m-aarch64-linux-gnu.so
umath_tests.py
g40 gravatar imageg40 ( 2018-08-21 09:56:30 -0500 )edit

Do you know which one of the myriad CMake support scripts carries out this check?

lol, nope. sorry ;)

berak gravatar imageberak ( 2018-08-21 09:57:30 -0500 )edit

Thanks Berak, input much appreciated. I wonder if there is another -D setting that points to numpy binaries, as opposed to the include directory?

g40 gravatar imageg40 ( 2018-08-21 10:02:08 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2018-08-21 10:08:47 -0500

g40 gravatar image

updated 2018-08-21 10:11:58 -0500

Setting the NUMPY version directly _does_ work -D PYTHON3_NUMPY_VERSION="1.15.0". Thanks again.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-08-21 08:35:19 -0500

Seen: 783 times

Last updated: Aug 21 '18