OpenCV安装时CUDA_nppi_LIBRARY (ADVANCED) 报错处理方法

Ubuntu16.04在安装了CUDA10.1之后,安装OpenCV
执行cmake 时报错如下:

**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 /home/holi/opencv-3.2.0/modules/cudev
    linked by target "opencv_cudev" in directory /home/holi/opencv-3.2.0/modules/cudev
    linked by target "opencv_test_cudev" in directory /home/holi/opencv-3.2.0/modules/cudev/test
    linked by target "opencv_core" in directory /home/holi/opencv-3.2.0/modules/core
    linked by target "opencv_core" in directory /home/holi/opencv-3.2.0/modules/core
    linked by target "opencv_test_core" in directory /home/holi/opencv-3.2.0/modules/core
    linked by target "opencv_perf_core" in directory /home/holi/opencv-3.2.0/modules/core
    linked by target "opencv_perf_cudaarithm" in directory /home/holi/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_test_cudaarithm" in directory /home/holi/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/holi/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_cudaarithm" in directory /home/holi/opencv-3.2.0/modules/cudaarithm
    linked by target "opencv_test_flann" in directory /home/holi/opencv-3.2.0/modules/flann
    linked by target "opencv_flann" in directory /home/holi/opencv-3.2.0/modules/flann
    linked by target "opencv_flann" in directory /home/holi/opencv-3.2.0/modules/flann**

修改方法为:

Change in FindCUDA.cmake the nppi library to the several splitted ones. This has to be done in 3 places. Remember this change is just to make it work with CUDA 9.0, I am not doing checks for version or anything, which should be done if you plan to give it to different people with different CUDA versions.

1) look for the line with:

find_cuda_helper_libs(nppi)
and replace it with the lines:

  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) find the line:

set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}")
and change it to

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) find the unset variables and add the new variables as well So, find:

unset(CUDA_nppi_LIBRARY CACHE)
and change it to:

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)
And also in OpenCVDetectCUDA.cmake you have to remove the 2.0 architechture which is no longer supported.

It has:

  ...
  set(__cuda_arch_ptx "")
  if(CUDA_GENERATION STREQUAL "Fermi")
    set(__cuda_arch_bin "2.0")
  elseif(CUDA_GENERATION STREQUAL "Kepler")
    set(__cuda_arch_bin "3.0 3.5 3.7")
  ...
It should be:

  ...
  set(__cuda_arch_ptx "")
  if(CUDA_GENERATION STREQUAL "Kepler")
    set(__cuda_arch_bin "3.0 3.5 3.7")
  elseif(CUDA_GENERATION STREQUAL "Maxwell")
    set(__cuda_arch_bin "5.0 5.2")
  ...

修改之后可以完成cmake,
然后执行make -j, 又发生如下报错,修改方法为:

退回上一步 cmake
执行一下代码
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..

这样就可以了。

你可能感兴趣的:(OneNote)