Hello.
I am currently try to test some cuda-accelerated functionalities applied to a open source visual-inertial odomertry vins_mono, in ubuntu 20.04.
I replaced cv::goodFeaturesToTrack(~~) with cv::cuda::CornersDetector::detect() fucntion as follows
#if USE_CUDA
cv::Ptr<cv::cuda::CornersDetector>detector_ = cv::cuda::createGoodFeaturesToTrackDetector(CV_8UC1, MAX_CNT, 0.01, MIN_DIST, 3);
detector_->detect(img, n_pts, mask=mask);
#endif
Here is the part of CMakeLists.txt for the project which find_package OpenCV
find_package(OpenCV 4.5 REQUIRED)
message(WARNING "OpenCV_VERSION: ${OpenCV_VERSION}")
message("Open CV libs : ${OpenCV_LIBS}")
From the image below, I think that the project is properly built with a desired version of Opencv built with Cuda.
However, when I launch the program, the program dies with the following error code.
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.2.0) ../modules/core/include/opencv2/core/private.cuda.hpp:109: error: (-216:No CUDA support) The library is compiled without CUDA support in function 'throw_no_cuda'
It seems like somehow the program runs with OpenCV 4.2.0(which is not built with CUDA support) which is installed with ROS package, although I checked that it was built with the CUDA 4.5.2 version with CUDA support.
What could be going wrong here?
The warning message when building the code(=content of the image) is as follows.
----------------------------------------------------------------
CMake Warning at /home/larr-uav-laptop/catkin_ws/src/vins_mono/feature_tracker/CMakeLists.txt:18 (message):
OpenCV_VERSION: 4.5.2
Open CV libs : opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio;opencv_alphamat;opencv_aruco;opencv_bgsegm;opencv_bioinspired;opencv_ccalib;opencv_cudaarithm;opencv_cudabgsegm;opencv_cudafeatures2d;opencv_cudafilters;opencv_cudaimgproc;opencv_cudalegacy;opencv_cudaobjdetect;opencv_cudaoptflow;opencv_cudastereo;opencv_cudawarping;opencv_cudev;opencv_datasets;opencv_dnn_objdetect;opencv_dnn_superres;opencv_dpm;opencv_face;opencv_freetype;opencv_fuzzy;opencv_hdf;opencv_hfs;opencv_img_hash;opencv_intensity_transform;opencv_line_descriptor;opencv_mcc;opencv_optflow;opencv_phase_unwrapping;opencv_plot;opencv_quality;opencv_rapid;opencv_reg;opencv_rgbd;opencv_saliency;opencv_sfm;opencv_shape;opencv_stereo;opencv_structured_light;opencv_superres;opencv_surface_matching;opencv_text;opencv_tracking;opencv_videostab;opencv_viz;opencv_wechat_qrcode;opencv_xfeatures2d;opencv_ximgproc;opencv_xobjdetect;opencv_xphoto
cd /home/larr-uav-laptop/catkin_ws/build/feature_tracker; catkin build --get-env feature_tracker | catkin env -si /usr/bin/cmake /home/larr-uav-laptop/catkin_ws/src/vins_mono/feature_tracker --no-warn-unused-cli -DCATKIN_DEVEL_PREFIX=/home/larr-uav-laptop/catkin_ws/devel/.private/feature_tracker -DCMAKE_INSTALL_PREFIX=/home/larr-uav-laptop/catkin_ws/install; cd -
...................................................................................................
___________________________________________________________________________________________________
Warnings << feature_tracker:make /home/larr-uav-laptop/catkin_ws/logs/feature_tracker/build.make.008.log
/usr/bin/ld: warning: libopencv_calib3d.so.4.5, needed by /home/larr-uav-laptop/catkin_ws/devel/.private/camera_model/lib/libcamera_model.so, may conflict with libopencv_calib3d.so.4.2
/usr/bin/ld: warning: libopencv_imgproc.so.4.5, needed by /home/larr-uav-laptop/catkin_ws/devel/.private/camera_model/lib/libcamera_model.so, may conflict with libopencv_imgproc.so.4.2
/usr/bin/ld: warning: libopencv_core.so.4.5, needed by /home/larr-uav-laptop/catkin_ws/devel/.private/camera_model/lib/libcamera_model.so, may conflict with libopencv_core.so.4.2
cd /home/larr-uav-laptop/catkin_ws/build/feature_tracker; catkin build --get-env feature_tracker | catkin env -si /usr/bin/make --jobserver-auth=3,4; cd -
Could you share the result of cv::getBuildInformation ?
This result will give you build information of OpenCV.
If you used libopencv-dev installed via apt, this package was build without CUDA.
Thank you for your reply. Here is the getBuildInformation() result
WARN] [1656655245.420383036]: Build Information :
General configuration for OpenCV 4.2.0 =====================================
Version control: unknown
Extra modules:
Location (extra): /build/opencv-YsXJoR/opencv-4.2.0+dfsg/contrib/modules
Version control (extra): unknown
Platform:
Timestamp: 2020-02-18T03:31:25Z
Host: Linux 4.4.0-173-generic x86_64
CMake: 3.16.3
CMake generator: Ninja
CMake build tool: /usr/bin/ninja
Configuration: Release
CPU/HW features:
Baseline: SSE SSE2
requested: SSE2
disabled: SSE3
Dispatched code generation: SSE4_1 SSE4_2 FP16 AVX AVX2 AVX512_SKX
requested: SSE4_1 SSE4_2 AVX FP16 AVX2 AVX512_SKX
SSE4_1 (13 files): + SSE3 SSSE3 SSE4_1
SSE4_2 (1 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (0 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (4 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (26 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (3 files): + SSE3 SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/bin/c++ (ver 9.2.1)
C++ flags (Release): -g -O2 -fdebug-prefix-map=/build/opencv-YsXJoR/opencv-4.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -g -O2 -fdebug-prefix-map=/build/opencv-YsXJoR/opencv-4.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C++ flags (Debug): -g -O2 -fdebug-prefix-map=/build/opencv-YsXJoR/opencv-4.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -fvisibility-inlines-hidden -g -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -g -O2 -fdebug-prefix-map=/build/opencv-YsXJoR/opencv-4.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -g -O2 -fdebug-prefix-map=/build/opencv-YsXJoR/opencv-4.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C flags (Debug): -g -O2 -fdebug-prefix-map=/build/opencv-YsXJoR/opencv-4.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -fvisibility=hidden -g -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
Linker flags (Debug): -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections
ccache: NO
Precompiled headers: NO
Extra dependencies: dl m pthread rt
3rdparty dependencies:
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 quality reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab viz ximgproc xobjdetect xphoto
Disabled: world
Disabled by dependency: sfm
Unavailable: cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv gapi js matlab ovis python2 ts
Applications: apps
Documentation: doxygen python javadoc
Non-free algorithms: NO
GUI:
GTK+: YES (ver 3.24.13)
GThread : YES (ver 2.63.3)
GtkGlExt: NO
OpenGL support: NO
VTK support: YES (ver 6.3.0)
Media I/O:
ZLib: /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.11)
JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (ver 80)
WEBP: /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.37)
TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.1.0)
OpenEXR: /usr/lib/x86_64-linux-gnu/libImath.so /usr/lib/x86_64-linux-gnu/libIlmImf.so /usr/lib/x86_64-linux-gnu/libIex.so /usr/lib/x86_64-linux-gnu/libHalf.so /usr/lib/x86_64-linux-gnu/libIlmThread.so (ver 2.3.0)
GDAL: YES (/usr/lib/libgdal.so)
GDCM: YES (3.0.4)
HDR: YES
SUNRASTER: YES
PXM: YES
PFM: YES
Video I/O:
DC1394: YES (2.2.5)
FFMPEG: YES
avcodec: YES (58.54.100)
avformat: YES (58.29.100)
avutil: YES (56.31.100)
swscale: YES (5.5.100)
avresample: YES (4.0.0)
GStreamer: YES (1.16.2)
PvAPI: NO
v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: TBB (ver 2020.1 interface 11101)
Trace: YES (built-in)
Other third-party libraries:
Lapack: NO
Eigen: YES (ver 3.3.7)
Custom HAL: NO
Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (3.6.1)
OpenCL: YES (no extra features)
Include path: /usr/include/CL
Link libraries: Dynamic load
Python 3:
Interpreter: /usr/bin/python3 (ver 3.8.2)
Libraries: /usr/lib/x86_64-linux-gnu/libpython3.8.so (ver 3.8.2rc1)
numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.17.4)
install path: lib/python3.8/dist-packages
Python (for build): /usr/bin/python3
Java:
ant: /usr/bin/ant (ver 1.10.7)
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include
Java wrappers: YES
Java tests: NO
Install to: /usr
-----------------------------------------------------------------
So apparently somehow it is built with opencv4.2.0 … which is default installed by ROS and without cuda support.
Hi there , I encounter the same issue here, google lead me to this topic, did u manage to solve it?
I removed opencv and cuda after few months since I faced the error, and reinstalled everything again. It is not happening again since then, but I wasn’t able to find more “non-destructive” way to fix the problem back then.
2023년 7월 21일 (금) 오전 10:43, Li Wang via OpenCV <notifications@opencv.discoursemail.com>님이 작성: