安裝opencv-cuda
有好事之徒(好心人)已經編譯了opencv3.4.2帶cuda的版本,直接用env的控制台安裝
conda install -c oddconcepts opencv-cuda
在spyder IDE裡 import cv2
會提示,找不到libjasper.so.1
這是因為ubuntu 在17.04之後取消了libjasper-dev了,(按其他教程要裝這個那都是ubuntu 16.04的,在18.04裡是裝不上的)
Note that
libjasper-dev
has been removed from Ubuntu 17.04 (https://launchpad.net/ubuntu/zesty/amd64/libjasper-dev/1.900.1-debian1-2.4+deb8u1), and they suggest to use OpenJPEG instead (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=812630).
Since OpenCV uses
trying to install it manually may be an option.
jasper
那麼還是在env裡用conda裝,但是注意不要搜libjasper,可能裝上的是.a的靜态庫版本,那麼還是會找不到.so
這麼裝:
conda install -c conda-forge jasper
然後應該 import cv2時不報錯。
這時,檢查一下opencv安裝的情況:
print(cv2.getBuildInformation())
我這裡的資訊是:
General configuration for OpenCV 3.4.2 =====================================
Version control: 3.4.2
Extra modules:
Location (extra): /home/tee/anaconda3/conda-bld/opencv-cuda_1534922162608/work/opencv_contrib-3.4.2/modules
Version control (extra): 3.4.2
Platform:
Timestamp: 2018-08-22T07:16:54Z
Host: Linux 4.4.0-130-generic x86_64
CMake: 3.9.4
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 (3 files): + SSSE3 SSE4_1
SSE4_2 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2
FP16 (1 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 AVX
AVX (4 files): + SSSE3 SSE4_1 POPCNT SSE4_2 AVX
AVX2 (8 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2
AVX512_SKX (0 files): + SSSE3 SSE4_1 POPCNT SSE4_2 FP16 FMA3 AVX AVX2 AVX_512F AVX512_SKX
C/C++:
Built as dynamic libs?: YES
C++ Compiler: /usr/bin/c++ (ver 5.4.0)
C++ flags (Release): -I/home/machinelearning/anaconda3/envs/cuda-opencv/include -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -I/home/machinelearning/anaconda3/envs/cuda-opencv/include -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -I/home/machinelearning/anaconda3/envs/cuda-opencv/include -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-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -I/home/machinelearning/anaconda3/envs/cuda-opencv/include -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-narrowing -Wno-comment -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -msse -msse2 -msse3 -fvisibility=hidden -fopenmp -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
ccache: NO
Precompiled headers: YES
Extra dependencies: dl m pthread rt cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda/lib64
3rdparty dependencies:
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dpm face features2d flann freetype fuzzy hdf hfs highgui img_hash imgcodecs imgproc java_bindings_generator line_descriptor ml objdetect optflow phase_unwrapping photo plot python3 python_bindings_generator reg rgbd saliency shape stereo stitching structured_light superres surface_matching tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
Disabled: js world
Disabled by dependency: dnn_objdetect text
Unavailable: cnn_3dobj cvv dnn java matlab ovis python2 sfm ts viz
Applications: apps
Documentation: NO
Non-free algorithms: NO
GUI:
Media I/O:
ZLib: /home/machinelearning/anaconda3/envs/cuda-opencv/lib/libz.so (ver 1.2.11)
JPEG: build-libjpeg-turbo (ver 1.5.3-62)
WEBP: build (ver encoder: 0x020e)
PNG: build (ver 1.6.34)
TIFF: build (ver 42 - 4.0.9)
JPEG 2000: /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
HDR: YES
SUNRASTER: YES
PXM: YES
Video I/O:
DC1394: YES (ver 2.2.4)
FFMPEG: YES
avcodec: YES (ver 58.18.100)
avformat: YES (ver 58.12.100)
avutil: YES (ver 56.14.100)
swscale: YES (ver 5.1.100)
avresample: YES (ver 4.0.0)
GStreamer: NO
libv4l/libv4l2: NO
v4l/v4l2: linux/videodev2.h
gPhoto2: NO
Parallel framework: OpenMP
Trace: YES (with Intel ITT)
Other third-party libraries:
Intel IPP: 2017.0.3 [2017.0.3]
at: /home/tee/anaconda3/conda-bld/opencv-cuda_1534922162608/work/build/3rdparty/ippicv/ippicv_lnx
Intel IPP IW: sources (2017.0.3)
at: /home/tee/anaconda3/conda-bld/opencv-cuda_1534922162608/work/build/3rdparty/ippicv/ippiw_lnx
Lapack: NO
Eigen: YES (ver 3.3.3)
Custom HAL: NO
NVIDIA CUDA: YES (ver 9.2, CUFFT CUBLAS)
NVIDIA GPU arch: 30 35 37 50 52 60 61 70
NVIDIA PTX archs:
Python 3:
Interpreter: /home/machinelearning/anaconda3/envs/cuda-opencv/bin/python (ver 3.6.6)
Libraries: /home/machinelearning/anaconda3/envs/cuda-opencv/lib/libpython3.6m.so (ver 3.6.6)
numpy: /home/machinelearning/anaconda3/envs/cuda-opencv/lib/python3.6/site-packages/numpy/core/include (ver 1.11.3)
packages path: /home/machinelearning/anaconda3/envs/cuda-opencv/lib/python3.6/site-packages
Python (for build): /home/machinelearning/anaconda3/envs/cuda-opencv/bin/python
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Install to: /home/machinelearning/anaconda3/envs/cuda-opencv
标紅的部分說明opencv成功找到了cuda。