编译很头疼,出现以下问题:
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:
opencv_dep_CUDA_nppi_LIBRARY
linked by target "opencv_core" in directory /home/kamal/packages/opencv-2.4.13.3/modules/core
linked by target "opencv_core" in directory /home/kamal/packages/opencv-2.4.13.3/modules/core
linked by target "opencv_flann" in directory /home/kamal/packages/opencv-2.4.13.3/modules/flann
linked by target "opencv_imgproc" in directory /home/kamal/packages/opencv-2.4.13.3/modules/imgproc
linked by target "opencv_highgui" in directory /home/kamal/packages/opencv-2.4.13.3/modules/highgui
linked by target "opencv_features2d" in directory /home/kamal/packages/opencv-2.4.13.3/modules/features2d
linked by target "opencv_calib3d" in directory /home/kamal/packages/opencv-2.4.13.3/modules/calib3d
linked by target "opencv_ml" in directory /home/kamal/packages/opencv-2.4.13.3/modules/ml
……
1.
修改opencv/cmake/FindCUDA.cmake 文件,将524行的
1unset(CUDA_nppi_LIBRARY CACHE)
修改为
1
2
3
4
5
6
7
8
9
10unset(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)
修改opencv/cmake/FindCUDA.cmake 文件,将799行和801行的
1
2find_cuda_helper_libs(nppi) set(CUDA_npp_LIBRARY"${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}")
修改为
1
2
3
4
5
6
7
8
9
10
11find_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) 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}")
2.
更改 OpenCVDetectCUDA.cmake 文件,将74行中的
1
2
3
4
5
6
7
8if(CUDA_GENERATION STREQUAL "Fermi") set(__cuda_arch_bin "2.0 2.1(2.0)") 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") endif()
修改成
1
2
3
4
5
6
7
8if(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") endif()
将107行
1
2
3
4
5
6
7
8
9if(${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") else() set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0 3.5") endif() set(__cuda_arch_ptx "3.0") endif()
修改成
1
2
3
4
5
6
7
8
9if(${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") else() set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0 3.5") endif() set(__cuda_arch_ptx "3.0") endif()
如果大家懒,就直接下载我修改好的吧,替换自己的两个文件就好了
最后
以上就是眯眯眼茉莉最近收集整理的关于编译OpenCV 2+ with CUDA 9+的全部内容,更多相关编译OpenCV内容请搜索靠谱客的其他文章。
发表评论 取消回复