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 ..

这样就可以了。

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
安装opencv_python后依然ModuleNotFoundError: No module named 'cv2'通常是因为opencv_python未正确安装或未正确配置路径。这可能是由于以下几个原因导致的: 1. Opencv_python未成功安装:请确保您已按照正确的安装步骤安装opencv_python库。您可以通过在命令行中运行以下命令来检查是否成功安装:pip show opencv-python。如果显示有关opencv_python库的信息,则表示已成功安装。 2. 环境变量未正确配置:请确保您已正确配置了系统的环境变量。这包括将opencv_python库的路径添加到系统的Path变量中。您可以通过打开命令提示符并键入echo %PATH%来检查系统路径是否包含了opencv_python库的路径。如果没有,请将包含opencv_python的路径添加到系统的Path变量中。 3. 安装的版本不兼容:请确保您安装的是与您的操作系统和Python版本兼容的opencv_python版本。某些opencv_python版本可能不与特定的Python版本或操作系统版本兼容。 如果您按照上述步骤进行了检查和调整,但问题仍然存在,请尝试重新安装opencv_python库。您可以通过卸载现有库并重新安装最新版本来做到这一点。在重新安装之前,请确保您已经删除了旧版本的库,以避免任何冲突。 希望这些信息对您有帮助。如果问题仍然存在,请提供更多详细信息,以便我能够更好地帮助您解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [虚拟环境中安装cv包:ModuleNotFoundError: No module named ‘cv2](https://blog.csdn.net/m0_64054405/article/details/128367713)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [【】已安装opencv,仍然:“ModuleNotFoundError: No module named ‘cv2‘”](https://blog.csdn.net/wss794/article/details/121046923)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值