ubuntu18.04+ opencv3.1+caffe-ssd安装
Posted ranjiewen
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu18.04+ opencv3.1+caffe-ssd安装相关的知识,希望对你有一定的参考价值。
问题1:使用Cmake编译opencv源码
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CUDA_nppi_LIBRARY (ADVANCED) linked by target "opencv_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev linked by target "opencv_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev linked by target "opencv_test_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev/test linked by target "opencv_core" in directory D:/Cproject/opencv/opencv/sources/modules/core linked by target "opencv_core" in directory D:/Cproject/opencv/opencv/sources/modules/core linked by target "opencv_test_core" in directory D:/Cproject/opencv/opencv/sources/modules/core linked by target "opencv_perf_core" in directory D:/Cproject/opencv/opencv/sources/modules/core linked by target "opencv_test_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm linked by target "opencv_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm linked by target "opencv_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm linked by target "opencv_perf_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm linked by target "opencv_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann linked by target "opencv_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann linked by target "opencv_test_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann linked by target "opencv_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc linked by target "opencv_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc linked by target "opencv_test_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc linked by target "opencv_perf_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc linked by target "opencv_test_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml linked by target "opencv_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml linked by target "opencv_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml linked by target "opencv_test_video" in directory D:/Cproject/opencv/opencv/sources/modules/video linked by target "opencv_video" in directory D:/Cproject/opencv/opencv/sources/modules/video linked by target "opencv_video" in directory D:/Cproject/opencv/opencv/sources/modules/video linked by target "opencv_perf_video" in directory D:/Cproject/opencv/opencv/sources/modules/video linked by target "opencv_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm linked by target "opencv_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm linked by target "opencv_test_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm linked by target "opencv_perf_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm linked by target "opencv_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters linked by target "opencv_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters linked by target "opencv_test_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters linked by target "opencv_perf_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters linked by target "opencv_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc linked by target "opencv_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc linked by target "opencv_test_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc linked by target "opencv_perf_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc linked by target "opencv_perf_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping linked by target "opencv_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping linked by target "opencv_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping linked by target "opencv_test_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping linked by target "opencv_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs linked by target "opencv_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs linked by target "opencv_test_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs linked by target "opencv_perf_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs linked by target "opencv_perf_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo linked by target "opencv_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo linked by target "opencv_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo linked by target "opencv_test_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo linked by target "opencv_test_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape linked by target "opencv_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape linked by target "opencv_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape linked by target "opencv_test_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio linked by target "opencv_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio linked by target "opencv_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio linked by target "opencv_perf_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio linked by target "opencv_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec linked by target "opencv_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec linked by target "opencv_perf_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec linked by target "opencv_test_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec linked by target "opencv_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui linked by target "opencv_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui linked by target "opencv_test_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui linked by target "opencv_perf_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect linked by target "opencv_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect linked by target "opencv_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect linked by target "opencv_test_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect linked by target "opencv_ts" in directory D:/Cproject/opencv/opencv/sources/modules/ts linked by target "opencv_ts" in directory D:/Cproject/opencv/opencv/sources/modules/ts linked by target "opencv_test_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d linked by target "opencv_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d linked by target "opencv_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d linked by target "opencv_perf_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d linked by target "opencv_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d linked by target "opencv_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d linked by target "opencv_test_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d linked by target "opencv_perf_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d linked by target "opencv_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d linked by target "opencv_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d linked by target "opencv_test_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d linked by target "opencv_perf_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d linked by target "opencv_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy linked by target "opencv_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy linked by target "opencv_test_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy linked by target "opencv_perf_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy linked by target "opencv_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect linked by target "opencv_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect linked by target "opencv_perf_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect linked by target "opencv_test_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect linked by target "opencv_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow linked by target "opencv_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow linked by target "opencv_test_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow linked by target "opencv_perf_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow linked by target "opencv_perf_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo linked by target "opencv_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo linked by target "opencv_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo linked by target "opencv_test_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo linked by target "opencv_test_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching linked by target "opencv_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching linked by target "opencv_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching linked by target "opencv_perf_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching linked by target "opencv_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres linked by target "opencv_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres linked by target "opencv_test_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres linked by target "opencv_perf_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres linked by target "opencv_videostab" in directory D:/Cproject/opencv/opencv/sources/modules/videostab linked by target "opencv_videostab" in directory D:/Cproject/opencv/opencv/sources/modules/videostab linked by target "opencv_traincascade" in directory D:/Cproject/opencv/opencv/sources/apps/traincascade linked by target "opencv_createsamples" in directory D:/Cproject/opencv/opencv/sources/apps/createsamples linked by target "opencv_annotation" in directory D:/Cproject/opencv/opencv/sources/apps/annotation linked by target "opencv_visualisation" in directory D:/Cproject/opencv/opencv/sources/apps/visualisation linked by target "opencv_version" in directory D:/Cproject/opencv/opencv/sources/apps/version
原因解析:cuda9不再支持2.0架构
参考: OpenCV3.3+CUDA9.0+Cmake3.9 环境搭建
在opecv-3.1.0/cmake下:
1).找到FindCUDA.cmake文件;找到行 find_cuda_helper_libs(nppi)改为 find_cuda_helper_libs(nppial) find_cuda_helper_libs(nppicc) find_cuda_helper_libs(nppicom) find_cuda_helper_libs(nppidei) find_cuda_helper_libs(nppif) find_cuda_helper_libs(nppig) find_cuda_helper_libs(nppim) find_cuda_helper_libs(nppist) find_cuda_helper_libs(nppisu) find_cuda_helper_libs(nppitc)2) 找到行 set(CUDA_npp_LIBRARY"${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}") 改为 set(CUDA_npp_LIBRARY"${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}") 3).找到行 unset(CUDA_nppi_LIBRARY CACHE) 改为 unset(CUDA_nppial_LIBRARY CACHE) unset(CUDA_nppicc_LIBRARY CACHE) unset(CUDA_nppicom_LIBRARY CACHE) unset(CUDA_nppidei_LIBRARY CACHE) unset(CUDA_nppif_LIBRARY CACHE) unset(CUDA_nppig_LIBRARY CACHE) unset(CUDA_nppim_LIBRARY CACHE) unset(CUDA_nppist_LIBRARY CACHE) unset(CUDA_nppisu_LIBRARY CACHE) unset(CUDA_nppitc_LIBRARY CACHE)
cmake过
问题2:make 错误
[ 35%] Built target pch_Generate_opencv_test_cudacodec nvcc fatal : Unsupported gpu architecture ‘compute_20‘ CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:208 (message): Error generating /home/dsp/ranjiewen/opencv-3.1.0/build/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o modules/core/CMakeFiles/opencv_core.dir/build.make:63: recipe for target ‘modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o‘ failed make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o] Error 1 CMakeFiles/Makefile2:1485: recipe for target ‘modules/core/CMakeFiles/opencv_core.dir/all‘ failed make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
- 网上找的,Makefile.config文件找不到啊
错误:opencv nvcc fatal : Unsupported gpu architecture ‘compute_20‘
原因:cuda9不支持‘compute-20’,需要更改OpenCVDetectCUDA.cmake文件,将
if(CUDA_GENERATION STREQUAL "Fermi") set(__cuda_arch_bin "3.0 3.5") elseif(CUDA_GENERATION STREQUAL "Kepler") if(${CUDA_VERSION} VERSION_LESS "5.0") set(__cuda_arch_bin "2.0 2.1") else() set(__cuda_arch_bin "3.0 3.5") 替换为
if(CUDA_GENERATION STREQUAL "Fermi") set(__cuda_arch_bin "3.0 3.5") elseif(CUDA_GENERATION STREQUAL "Kepler") if(${CUDA_VERSION} VERSION_LESS "5.0") set(__cuda_arch_bin "3.0") else() set(__cuda_arch_bin "3.0 3.5") 将:
if(${CUDA_VERSION} VERSION_LESS "5.0") set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0") elseif(${CUDA_VERSION} VERSION_GREATER "6.5") set(__cuda_arch_bin "2.0 2.1(2.0) 3.0 3.5") 替换为:
if(${CUDA_VERSION} VERSION_LESS "5.0") set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0") elseif(${CUDA_VERSION} VERSION_GREATER "6.5") set(__cuda_arch_bin "3.0 3.5")
Makefile.config 中 CUDA_ARCH 设置:将紫色两行注释掉# CUDA architecture setting: going with all of them. # For CUDA < 6.0, comment the *_50 through *_61 lines for compatibility. # For CUDA < 8.0, comment the *_60 and *_61 lines for compatibility. # For CUDA >= 9.0, comment the *_20 and *_21 lines for compatibility. CUDA_ARCH := #-gencode arch=compute_20,code=sm_20 # -gencode arch=compute_20,code=sm_21 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_61,code=compute_61 重新cmake
- 输入:“cmake -D CMAKE_BUILD_TYPE=bulid -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..”,即可解决!
- 不知道后面用opencv会不会出错!
以上是关于ubuntu18.04+ opencv3.1+caffe-ssd安装的主要内容,如果未能解决你的问题,请参考以下文章
Ubuntu18.04 Azure Kinect ROS Driver配置
Ubuntu18.04 Azure Kinect ROS Driver配置