使用 CMake、CUDA 9.0 RC 和 Visual Studio 2017 安装带有 contrib 模块的 OpenCV 3.3.0

Installing OpenCV 3.3.0 with contrib modules using CMake, CUDA 9.0 RC and Visual Studio 2017(使用 CMake、CUDA 9.0 RC 和 Visual Studio 2017 安装带有 contrib 模块的 OpenCV 3.3.0)

本文介绍了使用 CMake、CUDA 9.0 RC 和 Visual Studio 2017 安装带有 contrib 模块的 OpenCV 3.3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用最新的 CUDA 9.0 RC 安装带有 contrib 模块的 OpenCV 3.3.0,因此它与 Microsoft Visual Studio 2017 兼容.CUDA 安装很简单,并成功集成到 VS 2017 中.我正在按照各种在线说明使我能够在没有 CUDA 的情况下成功构建 contrib 模块.

I'm trying to install OpenCV 3.3.0 with contrib modules using the newest CUDA 9.0 RC so it is compatible with Microsoft Visual Studio 2017. The CUDA installation was straightforward and successfully integrated into VS 2017. I'm operating according to various instructions online which allowed me to successfully build the contrib modules without CUDA before.

但是,当我运行 CMake 时(确保将其设置为 VS 2017 x64,请参阅:CMake: 编译OpenCV时未找到CUDA库),我得到了经典:

When I run CMake, however (ensuring that I set it to VS 2017 x64, see: CMake: CUDA libraries not found when compiling OpenCV), I get the classic:

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

这不是上面发布的 x64 问题.CUDA 9.0RC 物理上不包含 nppi.lib,相反,Nvidia 似乎已将其分解为几个库:nppial.lib、nppicc.lib、nppicom.lib、nppidei.lib、nppif.lib、nppig.lib、nppist.lib nppisu.lib 和 nppitc.lib

This is not the x64 issue as posted above. the CUDA 9.0RC physically does not contain nppi.lib, instead, it appears Nvidia has broken it into several libraries: nppial.lib, nppicc.lib, nppicom.lib, nppidei.lib, nppif.lib, nppig.lib, nppist.lib nppisu.lib and nppitc.lib

为了解决这个问题,我将 CUDA 8.0 中的 nppi.lib 直接添加到 CUDA 9.0 的库目录中.这似乎使 CMake 的配置变得愉快,但最终当我在 Visual Studio 中构建解决方案时,几乎一切都失败了,并出现了一些变化:

In an attempt to resolve this, I added the nppi.lib from CUDA 8.0 straight into the library directory of the CUDA 9.0. This appears to make the configuring for CMake happy, but ultimately when I build the solution in Visual Studio, almost everything fails with some variation of:

5>LINK : fatal error LNK1104: cannot open file '....libReleaseopencv_core330.lib'
5>Done building project "opencv_ml.vcxproj" -- FAILED.

我还尝试进入 CMakeCache 文件并将 nppi 库的路径更改为以分号分隔的所有上述文件.结果是一样的.(请注意,我只更改了库文件路径,而不是在 CMakeCache 中每次都提到 nppi)

I also tried going into the CMakeCache file and changing the Path to nppi library to all of the aforementioned files as separated with a semicolon. Result is the same. (As a note, i only changed the library filepath, not every other mention of nppi in the CMakeCache)

我预计这可能是 CUDA 9.0 RC 的问题,可能需要 CMake 的补丁.有没有人有解决方法/我做错了什么?如果大家能提供任何帮助,我将不胜感激.

I expect that this is probably an issue with CUDA 9.0 RC and may require a patch from CMake. Does anyone have a workaround/am I doing something wrong? I'd appreciate any help you all can provide.

推荐答案

我已经解决了这个问题.我使用 lib.exe 将这几个库合并为一个库.

I have solved this problem. I use lib.exe to combine these several libraries into one library.

  1. 运行x64 Native Tools Command Prompt for VS 2017"
  2. cd 进入 cuda 文件夹
  3. lib.exe/out:nppi.lib nppial.lib nppicc.lib nppicom.lib nppidei.lib nppif.lib nppig.lib nppim.lib nppist.lib nppisu.lib nppitc.lib

这篇关于使用 CMake、CUDA 9.0 RC 和 Visual Studio 2017 安装带有 contrib 模块的 OpenCV 3.3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:使用 CMake、CUDA 9.0 RC 和 Visual Studio 2017 安装带有 contrib 模块的 OpenCV 3.3.0

基础教程推荐