带有 python 中 CUDA 的 OpenCV 4.1 使用了错误的 OpenCV 版本



我正在尝试安装 opencv 4.1 以在 python 中使用,支持 Cuda。我尝试按照本指南进行操作并预装了 CUDA 10(因为我需要它与 keras 并且这已经有效了(,但是在使用以下代码在 python 中检查 opencv 时

import cv2 as cv
print(cv.__version__)
print(cv.getBuildInformation())

但它返回错误的打开 cv 版本和不可用的 cuda 库:

3.2.0
General configuration for OpenCV 3.2.0 =====================================
Version control:               unknown
Extra modules:
Location (extra):            /build/opencv-L2vuMj/opencv-3.2.0+dfsg/contrib/modules
Version control (extra):     unknown
Platform:
Timestamp:                   2018-09-20T09:28:13Z
Host:                        Linux 4.4.0-135-generic x86_64
CMake:                       3.10.2
CMake generator:             Unix Makefiles
CMake build tool:            /usr/bin/make
Configuration:               Release
C/C++:
Built as dynamic libs?:      YES
C++ Compiler:                /usr/bin/c++  (ver 7.3.0)
C++ flags (Release):         -g -O2 -fdebug-prefix-map=/build/opencv-L2vuMj/opencv-3.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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O2 -fdebug-prefix-map=/build/opencv-L2vuMj/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security  -DNDEBUG
C++ flags (Debug):           -g -O2 -fdebug-prefix-map=/build/opencv-L2vuMj/opencv-3.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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
C Compiler:                  /usr/bin/cc
C flags (Release):           -g -O2 -fdebug-prefix-map=/build/opencv-L2vuMj/opencv-3.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 -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g -O2 -fdebug-prefix-map=/build/opencv-L2vuMj/opencv-3.2.0+dfsg=. -fstack-protector-strong -Wformat -Werror=format-security  -DNDEBUG
C flags (Debug):             -g -O2 -fdebug-prefix-map=/build/opencv-L2vuMj/opencv-3.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 -Wno-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -mno-avx -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -ffunction-sections -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
Linker flags (Release):      -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
Linker flags (Debug):        -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now
ccache:                      NO
Precompiled headers:         NO
Extra dependencies:          /usr/lib/x86_64-linux-gnu/libwebp.so gdcmMSFF /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 /usr/lib/libgdal.so gtk-3 gdk-3 pangocairo-1.0 pango-1.0 atk-1.0 cairo-gobject cairo gdk_pixbuf-2.0 gio-2.0 gobject-2.0 glib-2.0 gthread-2.0 dc1394 avcodec avformat avutil swscale avresample gphoto2 gphoto2_port /usr/lib/x86_64-linux-gnu/hdf5/serial/libhdf5.so /usr/lib/x86_64-linux-gnu/libpthread.so /usr/lib/x86_64-linux-gnu/libsz.so /usr/lib/x86_64-linux-gnu/libdl.so /usr/lib/x86_64-linux-gnu/libm.so vtkRenderingOpenGL vtkImagingHybrid vtkIOImage vtkCommonDataModel vtkCommonMath vtkCommonCore vtksys vtkCommonMisc vtkCommonSystem vtkCommonTransforms vtkCommonExecutionModel vtkDICOMParser vtkIOCore /usr/lib/x86_64-linux-gnu/libz.so vtkmetaio /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/x86_64-linux-gnu/libpng.so /usr/lib/x86_64-linux-gnu/libtiff.so vtkImagingCore vtkRenderingCore vtkCommonColor vtkFiltersExtraction vtkFiltersCore vtkFiltersGeneral vtkCommonComputationalGeometry vtkFiltersStatistics vtkImagingFourier vtkalglib vtkFiltersGeometry vtkFiltersSources vtkInteractionStyle vtkRenderingLOD vtkFiltersModeling vtkIOPLY vtkIOGeometry vtkFiltersTexture vtkRenderingFreeType /usr/lib/x86_64-linux-gnu/libfreetype.so vtkftgl vtkIOExport vtkRenderingAnnotation vtkImagingColor vtkRenderingContext2D vtkRenderingGL2PS vtkRenderingContextOpenGL /usr/lib/x86_64-linux-gnu/libgl2ps.so vtkRenderingLabel tesseract lept dl m pthread rt tbb
3rdparty dependencies:
OpenCV modules:
To be built:                 core flann hdf imgproc ml photo reg surface_matching video viz freetype fuzzy imgcodecs shape videoio highgui objdetect plot superres ts xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo stitching videostab ximgproc aruco optflow phase_unwrapping structured_light java python2 python3
Disabled:                    world contrib_world
Disabled by dependency:      tracking
Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cnn_3dobj cvv dnn matlab sfm
GUI: 
QT:                          NO
GTK+ 3.x:                    YES (ver 3.22.30)
GThread :                    YES (ver 2.56.2)
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 )
WEBP:                        /usr/lib/x86_64-linux-gnu/libwebp.so (ver encoder: 0x020e)
PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.34)
TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 - 4.0.9)
JPEG 2000:                   NO
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.2.0)
GDAL:                        /usr/lib/libgdal.so
GDCM:                        YES (ver 2.8.4)
Video I/O:
DC1394 1.x:                  NO
DC1394 2.x:                  YES (ver 2.2.5)
FFMPEG:                      YES
avcodec:                   YES (ver 57.107.100)
avformat:                  YES (ver 57.83.100)
avutil:                    YES (ver 55.78.100)
swscale:                   YES (ver 4.8.100)
avresample:                YES (ver 3.7.0)
GStreamer:                   NO
OpenNI:                      NO
OpenNI PrimeSensor Modules:  NO
OpenNI2:                     NO
PvAPI:                       NO
GigEVisionSDK:               NO
Aravis SDK:                  NO
UniCap:                      NO
UniCap ucil:                 NO
V4L/V4L2:                    NO/YES
XIMEA:                       NO
Xine:                        NO
gPhoto2:                     YES
Parallel framework:            TBB (ver 2017.0 interface 9107)
Other third-party libraries:
Use IPP:                     NO
Use IPP Async:               NO
Use VA:                      NO
Use Intel VA-API/OpenCL:     NO
Use Lapack:                  NO
Use Eigen:                   YES (ver 3.3.4)
Use Cuda:                    NO
Use OpenCL:                  YES
Use OpenVX:                  NO
Use custom HAL:              NO
OpenCL:                        <Dynamic loading of OpenCL library>
Include path:                /usr/include/CL
Use AMDFFT:                  NO
Use AMDBLAS:                 NO
Python 2:
Interpreter:                 /usr/bin/python2.7 (ver 2.7.15)
Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.15rc1)
numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
packages path:               lib/python2.7/dist-packages
Python 3:
Interpreter:                 /usr/bin/python3 (ver 3.6.5)
Libraries:                   /usr/lib/x86_64-linux-gnu/libpython3.6m.so (ver 3.6.5)
numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.13.3)
packages path:               lib/python3.6/dist-packages
Python (for build):            /usr/bin/python2.7
Java:
ant:                         /usr/bin/ant (ver 1.10.3)
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
Matlab:                        Matlab not found or implicitly disabled
Documentation:
Doxygen:                     /usr/bin/doxygen (ver 1.8.13)
Tests and samples:
Tests:                       NO
Performance tests:           YES
C/C++ Examples:              YES
Install path:                  /usr
cvconfig.h is in:              /build/opencv-L2vuMj/opencv-3.2.0+dfsg/obj-x86_64-linux-gnu
-----------------------------------------------------------------

在生成 cmake 时,在 cmake-gui 中,cuda WAS 已启用,opencv 实际上是 4.1 版。

有什么想法吗?提前感谢!

附言。我没有使用 pip 来安装 opencv,但我是从源代码构建的

问题是在我用我想要的标志编译 opencv 之后,我忘记运行sudo make install来有效地安装所有绑定等。

默认情况下,python 会找到 cv2 模块,但并非所有模块都已配置。

相关内容

  • 没有找到相关文章