首页 > 编译OpenCV 2+ with CUDA 9+

编译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()

如果大家懒,就直接下载我修改好的吧,替换自己的两个文件就好了

更多相关:

  • CUDA编目录: 1.什么是CUDA 2.为什么要用到CUDA 3.CUDA环境搭建 4.第一个CUDA程序 5. CUDA编程 5.1. 基本概念 5.2. 线程层次结构 5.3. 存储器层次结构 5.4. 运行时API 5.4.1. 初始化 5.4.2. 设备管理 5.4.3. 存储器管理 5.4.3.1...

  • CUDA简介 CUDA是并行计算的平台和类C编程模型,我们能很容易的实现并行算法,就像写C代码一样。只要配备的NVIDIA GPU,就可以在许多设备上运行你的并行程序,无论是台式机、笔记本抑或平板电脑。熟悉C语言可以帮助你尽快掌握CUDA。 CUDA编程 CUDA编程允许你的程序执行在异构系统上,即CUP和GPU,二者有各自的存...

  • Boom Library 93套影视游戏无损配乐音效素材合集包 素材压缩包大小共:851G 每个合集为独立压缩包 可选择性下载 云桥网络 平台获取合集包 01.BOOM Library Assault Weapons Bundle【枪战机枪音效】 02.BOOM Library Birds of Prey【猛禽类音效】 0...