Closed Alex-43760 closed 1 year ago
I suspect this maybe the same issue related to the way Ceras solver defines the CUDA targets, see https://github.com/opencv/opencv/issues/23422
Can you try building against these PR's to see if this solves your issue https://github.com/opencv/opencv/pull/23021, https://github.com/opencv/opencv_contrib/pull/3400
I followed the instructions within #23422
using -D BUILD_opencv_sfm=OFF
The result is as follows
(AIenv) ai@ai:~/nvidia/opencv-4.5.2/build$ make -j20
[ 0%] Built target gen-pkgconfig
[ 0%] Built target opencv_videoio_plugins
[ 0%] Built target ittnotify
[ 1%] Built target quirc
[ 3%] Built target ippiw
[ 4%] Built target libopenjp2
[ 4%] Built target gen_opencv_python_source
[ 4%] Built target ade
[ 4%] Built target opencv_cudev
[ 9%] Built target libwebp
[ 12%] Built target libprotobuf
[ 17%] Built target opencv_core
[ 17%] Built target opencv_hdf
[ 17%] Built target opencv_version
[ 17%] Built target opencv_flann
[ 17%] Built target opencv_surface_matching
[ 18%] Built target opencv_ml
[ 22%] Built target opencv_imgproc
[ 23%] Built target opencv_plot
[ 23%] Built target opencv_intensity_transform
[ 23%] Built target opencv_phase_unwrapping
[ 23%] Built target opencv_quality
[ 23%] Built target opencv_freetype
[ 24%] Built target opencv_cudaarithm
[ 24%] Built target opencv_reg
[ 24%] Built target opencv_fuzzy
[ 24%] Built target opencv_alphamat
[ 24%] Built target opencv_img_hash
[ 25%] Built target opencv_hfs
[ 25%] Built target opencv_cudawarping
[ 26%] Built target opencv_imgcodecs
[ 28%] Built target opencv_features2d
[ 29%] Built target opencv_videoio
[ 30%] Built target opencv_line_descriptor
[ 31%] Built target opencv_saliency
[ 31%] Built target opencv_highgui
[ 31%] Built target opencv_annotation
[ 31%] Built target opencv_visualisation
[ 32%] Built target opencv_cudafilters
[ 33%] Built target opencv_bioinspired
[ 34%] Built target opencv_ts
[ 36%] Built target opencv_calib3d
[ 36%] Built target opencv_test_flann
[ 36%] Built target opencv_test_hdf
[ 36%] Built target opencv_test_intensity_transform
[ 36%] Built target opencv_perf_cudaarithm
[ 36%] Built target opencv_test_phase_unwrapping
[ 36%] Built target opencv_test_reg
[ 36%] Built target opencv_perf_reg
[ 36%] Built target opencv_test_cudafilters
[ 36%] Built target opencv_test_cudaarithm
[ 37%] Built target opencv_perf_cudafilters
[ 37%] Built target opencv_test_quality
[ 38%] Built target opencv_test_ml
[ 38%] Built target opencv_cudafeatures2d
[ 38%] Built target opencv_perf_cudawarping
[ 39%] Built target opencv_test_cudawarping
[ 39%] Built target opencv_perf_imgcodecs
[ 39%] Built target opencv_perf_features2d
[ 39%] Built target opencv_test_fuzzy
[ 39%] Built target opencv_perf_line_descriptor
[ 39%] Built target opencv_test_line_descriptor
[ 39%] Built target opencv_test_img_hash
[ 39%] Built target opencv_test_saliency
[ 39%] Built target opencv_test_imgcodecs
[ 40%] Built target opencv_perf_core
[ 40%] Built target opencv_perf_videoio
[ 41%] Built target opencv_test_features2d
[ 41%] Built target opencv_test_cudafeatures2d
[ 41%] Built target opencv_perf_cudafeatures2d
[ 42%] Built target opencv_test_highgui
[ 42%] Built target opencv_rapid
[ 43%] Built target opencv_perf_calib3d
[ 45%] Built target opencv_perf_imgproc
[ 45%] Built target opencv_test_videoio
[ 45%] Built target opencv_structured_light
[ 45%] Built target opencv_objdetect
[ 45%] Built target opencv_aruco
[ 45%] Built target opencv_shape
[ 46%] Built target opencv_test_bioinspired
[ 46%] Built target opencv_test_rapid
[ 46%] Built target opencv_perf_bioinspired
[ 51%] Built target opencv_dnn
[ 51%] Built target opencv_ccalib
[ 52%] Built target opencv_cudastereo
[ 52%] Built target opencv_test_structured_light
[ 52%] Built target opencv_test_objdetect
[ 52%] Built target opencv_xobjdetect
[ 52%] Built target opencv_perf_objdetect
[ 54%] Built target opencv_dpm
[ 54%] Built target opencv_test_calib3d
[ 54%] Built target opencv_test_aruco
[ 54%] Built target opencv_interactive-calibration
[ 54%] Built target opencv_dnn_superres
[ 54%] Built target opencv_test_shape
[ 54%] Built target opencv_perf_dnn
[ 54%] Built target opencv_text
[ 56%] Built target opencv_cudaimgproc
[ 57%] Built target opencv_rgbd
[ 57%] Built target opencv_test_dnn
[ 57%] Built target opencv_dnn_objdetect
[ 57%] Built target opencv_model_diagnostics
[ 57%] Built target opencv_waldboost_detector
[ 59%] Built target opencv_test_core
[ 59%] Built target opencv_mcc
[ 61%] Built target opencv_test_cudev
[ 61%] Built target opencv_perf_cudastereo
[ 61%] Built target opencv_test_cudastereo
[ 61%] Built target opencv_test_dnn_superres
[ 61%] Built target opencv_perf_dnn_superres
[ 61%] Built target opencv_test_text
[ 64%] Built target opencv_test_imgproc
[ 64%] Built target opencv_test_mcc
[ 64%] Built target opencv_perf_rgbd
[ 64%] Built target opencv_test_cudaimgproc
[ 64%] Built target opencv_perf_cudaimgproc
[ 65%] Built target opencv_test_rgbd
[ 68%] Built target opencv_wechat_qrcode
[ 71%] Built target opencv_video
[ 71%] Built target opencv_datasets
[ 71%] Built target opencv_photo
[ 72%] Built target opencv_test_wechat_qrcode
[ 72%] Built target opencv_bgsegm
[ 73%] Built target opencv_xfeatures2d
[ 74%] Built target opencv_cudabgsegm
[ 75%] Built target opencv_perf_photo
[ 76%] Built target opencv_test_video
[ 77%] Built target opencv_test_photo
[ 77%] Built target opencv_xphoto
[ 77%] Built target opencv_perf_video
[ 77%] Built target opencv_test_bgsegm
[ 77%] Built target opencv_perf_cudabgsegm
[ 78%] Built target opencv_test_cudabgsegm
[ 78%] Built target opencv_test_xfeatures2d
[ 79%] Built target opencv_perf_xfeatures2d
[ 80%] Built target opencv_tracking
[ 80%] Built target opencv_face
[ 80%] Built target opencv_perf_xphoto
[ 81%] Built target opencv_test_xphoto
[ 81%] Built target opencv_perf_tracking
[ 82%] Built target opencv_stereo
[ 82%] Built target opencv_test_tracking
[ 83%] Built target opencv_test_face
[ 84%] Built target opencv_cudalegacy
[ 86%] Built target opencv_ximgproc
[ 86%] Built target opencv_test_stereo
[ 86%] Built target opencv_perf_stereo
[ 86%] Built target opencv_perf_cudalegacy
[ 86%] Built target opencv_cudaobjdetect
[ 89%] Built target opencv_gapi
[ 90%] Built target opencv_test_cudalegacy
[ 91%] Built target opencv_perf_ximgproc
[ 92%] Built target opencv_optflow
[ 92%] Built target opencv_test_cudaobjdetect
[ 92%] Built target opencv_perf_cudaobjdetect
[ 92%] Built target opencv_stitching
[ 93%] Built target opencv_test_ximgproc
[ 93%] Built target opencv_test_optflow
[ 93%] Built target opencv_perf_optflow
[ 94%] Built target opencv_perf_gapi
[ 94%] Built target opencv_perf_stitching
[ 94%] Built target opencv_cudaoptflow
[ 95%] Built target opencv_test_stitching
[ 95%] Built target opencv_test_cudaoptflow
[ 95%] Built target opencv_perf_cudaoptflow
[ 96%] Built target opencv_superres
[ 96%] Built target opencv_test_superres
[ 97%] Built target opencv_perf_superres
[ 97%] Built target opencv_videostab
[ 97%] Built target opencv_test_videostab
[100%] Built target opencv_test_gapi
[100%] Building CXX object modules/python2/CMakeFiles/opencv_python2.dir//src2/cv2.cpp.o
In file included from /home/ai/nvidia/opencv-4.5.2/modules/python/src2/cv2.cpp:41:
/home/ai/nvidia/opencv-4.5.2/build/modules/python_bindings_generator/pyopencv_generated_include.h:198:10: fatal error: opencv2/sfm/conditioning.hpp: No such file or directory
198 | #include "opencv2/sfm/conditioning.hpp"
| ^~~~~~~~~~
compilation terminated.
make[2]: *** [modules/python2/CMakeFiles/opencv_python2.dir/build.make:76: modules/python2/CMakeFiles/opencv_python2.dir//src2/cv2.cpp.o] Error 1
make[1]: [CMakeFiles/Makefile2:9847: modules/python2/CMakeFiles/opencv_python2.dir/all] Error 2
make: [Makefile:166: all] Error 2
Did you clean your build directory and re-generate the build files first?
Thank you, It succeeded I cleaned my files and re-build and it worked
When I tested installing cuda with OpenCV 4.5.2 The result was (AIenv) ai@ai:~/nvidia/opencv-4.5.2/build$ python3 Python 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.
import cv2 count = cv2.cuda.getCudaEnabledDeviceCount() Traceback (most recent call last): File "
", line 1, in cv2.error: OpenCV(4.5.2) /home/ai/nvidia/opencv-4.5.2/modules/core/src/cuda_info.cpp:62: error: (-217:Gpu API call) unknown error in function 'getCudaEnabledDeviceCount' What's the reason ??
Which GPU do you have and what is your output from print(cv.getBuildInformation())
?
my gpu is GeForce RTX 3070 Ti This line came out print(cv.getBuildInformation()) is
print(cv2.getBuildInformation())
General configuration for OpenCV 4.5.2 ===================================== Version control: unknown
Extra modules: Location (extra): /home/ai/nvidia/opencv_contrib-4.5.2/modules Version control (extra): unknown
Platform: Timestamp: 2023-05-23T11:36:56Z Host: Linux 5.15.0-72-generic x86_64 CMake: 3.26.0 CMake generator: Unix Makefiles CMake build tool: /usr/bin/make Configuration: RELEASE
CPU/HW features: Baseline: SSE SSE2 SSE3 requested: 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 (17 files): + SSSE3 SSE4_1 SSE4_2 (2 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX AVX (5 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX AVX2 (31 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX512_SKX (7 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_COMMON AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ standard: 11
C++ Compiler: /usr/bin/c++ (ver 9.4.0)
C++ flags (Release): -fsigned-char -ffast-math -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 -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 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -ffast-math -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 -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 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
Linker flags (Debug): -Wl,--exclude-libs,libippicv.a -Wl,--exclude-libs,libippiw.a -Wl,--gc-sections -Wl,--as-needed
ccache: NO
Precompiled headers: NO
Extra dependencies: m pthread cudart_static dl rt nppc nppial nppicc nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-11.2/lib64 -L/usr/lib/x86_64-linux-gnu
3rdparty dependencies:
OpenCV modules: To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python2 python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto Disabled: cudacodec sfm world Disabled by dependency: - Unavailable: cnn_3dobj cvv java julia matlab ovis viz Applications: tests perf_tests apps Documentation: NO Non-free algorithms: YES
GUI: GTK+: YES (ver 3.24.20) GThread : YES (ver 2.64.6) GtkGlExt: NO OpenGL support: NO VTK support: NO
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: build (ver encoder: 0x020f) 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) JPEG 2000: build (ver 2.4.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) 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.3) v4l/v4l2: YES (linux/videodev2.h)
Parallel framework: TBB (ver 2020.1 interface 11101)
Trace: YES (with Intel ITT)
Other third-party libraries: Intel IPP: 2020.0.0 Gold [2020.0.0] at: /home/ai/nvidia/opencv-4.5.2/build/3rdparty/ippicv/ippicv_lnx/icv Intel IPP IW: sources (2020.0.0) at: /home/ai/nvidia/opencv-4.5.2/build/3rdparty/ippicv/ippicv_lnx/iw VA: YES Lapack: YES (/usr/lib/x86_64-linux-gnu/liblapack.so /usr/lib/x86_64-linux-gnu/libcblas.so /usr/lib/x86_64-linux-gnu/libatlas.so) Eigen: YES (ver 3.3.7) Custom HAL: NO Protobuf: build (3.5.1)
NVIDIA CUDA: YES (ver 11.2, CUFFT CUBLAS FAST_MATH) NVIDIA GPU arch: 86 NVIDIA PTX archs:
cuDNN: YES (ver 8.1.0)
OpenCL: YES (INTELVA) Include path: /home/ai/nvidia/opencv-4.5.2/3rdparty/include/opencl/1.2 Link libraries: Dynamic load
Python 2: Interpreter: /usr/bin/python2.7 (ver 2.7.18) Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.18) numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.16.5) install path: lib/python2.7/dist-packages/cv2/python-2.7
Python 3: Interpreter: /home/ai/.virtualenvs/AIenv/bin/python3 (ver 3.8.10) Libraries: /usr/lib/x86_64-linux-gnu/libpython3.8.so (ver 3.8.10) numpy: /home/ai/.virtualenvs/AIenv/lib/python3.8/site-packages/numpy/core/include (ver 1.24.3) install path: /home/ai/.virtualenvs/AIenv/lib/python3.8/site-packages/cv2/python-3.8
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Not sure why cv2.cuda.getCudaEnabledDeviceCount()
is throwing that error.
I would confirm that the C++ CUDA tests work, e.g.
OPENCV_BUILD_DIR/bin/opencv_test_cudaarithm --gtest_filter=CUDA_Arithm/GEMM.Accuracy/0
If so you could confirm that both opencv_test_cudaarithm
and /home/ai/.virtualenvs/AIenv/lib/python3.8/site-packages/cv2/python-3.8/cv2.abi3.so
are linked to the same CUDA libs incase you have more than one CUDA install, e.g. compare the output of
ldd OPENCV_BUILD_DIR/bin/opencv_test_cudaarithm | grep cuda and
ldd /home/ai/.virtualenvs/AIenv/lib/python3.8/site-packages/cv2/python-3.8/cv2.abi3.so | grep cuda
If the above doesn't help it might be worth moving this to the OpenCV forum to see if anyone can offer any help.
I am grateful to you for your help It worked (AIenv) ai@ai:~$ python3 Python 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information.
import cv2 count = cv2.cuda.getCudaEnabledDeviceCount() print (count) 1
System Information
I Use ubuntu 20.04 I have cuda 11.2 I have cuDNN version 8.1.0
Detailed description
I'm trying to install opencv 4.5.2 with cuda 11.2 and cuDNN 8.1.0 but I'm having a problem with that and it's as follows
Thanks for the help in advance
Steps to reproduce
None
Issue submission checklist