我是靠谱客的博主 眯眯眼茉莉,最近开发中收集的这篇文章主要介绍编译OpenCV 2+ with CUDA 9+,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

编译很头疼,出现以下问题:

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行的

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)

修改opencv/cmake/FindCUDA.cmake 文件,将799行和801行的

find_cuda_helper_libs(nppi)
set(CUDA_npp_LIBRARY"${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}")

修改为

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)
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行中的

    if(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()

修改成

     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")
     endif()

将107行

      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")
       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()

修改成

      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")
       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 2+ with CUDA 9+所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(77)

评论列表共有 0 条评论

立即
投稿
返回
顶部