I have a segmentation fault after trying to import a freshly compiled version of the latest available OpenCV from github on Ubuntu 18.04.
Here is the error message I got while trying to import cv2
in Python 3:
$ python3
Python 3.6.8 (default, Aug 20 2019, 17:12:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
python3: Relink `/lib/x86_64-linux-gnu/libsystemd.so.0' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime'
python3: Relink `/lib/x86_64-linux-gnu/libudev.so.1' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime'
Segmentation fault (core dumped)
My Ubuntu; 5.0.0-29-generic x86_64 GNU/Linux
From where I cloned OpenCV; https://github.com/opencv/opencv
Related threads;
getting error while importing cv2 module in ubuntu amazon instance
Configure AWS Redshift on Ubuntu 18.04 and use it with pyodbc
https://unix.stackexchange.com/questions/444697/cannot-run-python-file-asks-to-relink-libraries
https://github.com/tensorflow/tensorflow/issues/19375
None of the solutions presented worked as I do not have any NVidia graphic chips on my laptop;
$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 5500 (rev 09)
Notice:
I need to compile OpenCV from sources because I want to use SIFT and SURF detectors and descriptors and they are no more available when OpenCV is installed with apt
:
>>> import cv2
>>> cv2.__version__
'4.2.0'
>>> cv2.xfeatures2d.SIFT_create()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv2.error: OpenCV(4.2.0)
/io/opencv_contrib/modules/xfeatures2d/src/sift.cpp:1210:
error: (-213:The function/feature is not implemented)
This algorithm is patented and is excluded in this configuration;
Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in
function 'create'
In my case
python3.6: Relink `/lib/x86_64-linux-gnu/libsystemd.so.0' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime'
python3.6: Relink `/lib/x86_64-linux-gnu/libudev.so.1' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime'
was generated by
$ python3.6
import tvm
and resolved by installation of a missing library. I found out this was missing by using a different version of python, as has been suggested elsewhere. In particular I found
$ python3.7
import tvm
reports (accurately) on a missing library. Once the missing library was installed for python3.6
$ python3.6 -m pip install <missing_library>
the problem went away.
So the problem is not specific to OpenCV or CuDNN. It seems to be a problem in the error reporting in python3.6.
In my case, the error was solved by installing the OpenCV headers sudo apt install libopencv-dev
. Typically I do this apt
install before trying to pip
install the OpenCV Python bindings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With