CMake:编译OpenCV时找不到CUDA库 [英] CMake: CUDA libraries not found when compiling OpenCV

查看:726
本文介绍了CMake:编译OpenCV时找不到CUDA库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CMAKE在Windows上编译具有CUDA支持的OpenCV 3.0.0.当我单击配置"时,将发生以下错误:

I am compiling OpenCV 3.0.0 with CUDA support on Windows, using CMAKE. When I click "configure", errors occur as following:

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_cufft_LIBRARY (ADVANCED)
    linked by target "opencv_hal" in directory E:/dev-lib/opencv3/sources/modules/hal
    ...
CUDA_nppc_LIBRARY (ADVANCED)
    ...
CUDA_nppi_LIBRARY (ADVANCED)
    ...
CUDA_npps_LIBRARY (ADVANCED)

我已经检查了条目中的"WITH_CUDA"和"WITH_CUFFT".如果我也选中"WITH_CUBLAS",则上面的输出将再增加一个CUDA_cublas_LIBRARY错误.

I have checked "WITH_CUDA" and "WITH_CUFFT" in entries. If I check "WITH_CUBLAS" as well, the outputs above will add one more CUDA_cublas_LIBRARY error.

但是在所有这些错误消息之前,它表明了

But before all these error messages it shows that

CUDA detected: 7.5
CUDA NVCC target flags: -gencode;arch=compute_20,code=sm_20;-gencode;arch=compute_20,code=sm_21;-gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_30,code=compute_30

表示CMAKE可以检测到CUDA.但是,找不到所需的那四个库.

which indicates CUDA can be detected by CMAKE. However, those 4 libraries needed cannot be found.

我之前已经安装了CUDA 7.5并使用Visual Studio 2012对其进行了编译. CUDA样本运行完美.因此,我的CUDA库应该正确安装.

I have installed CUDA 7.5 and compiled it with Visual Studio 2012 before. The CUDA samples run perfectly. So my CUDA libraries should be installed properly.

我想知道即使我必须手动设置这些值,也应该怎么做?

I wonder even if I have to set these values manually, how should I do it?

我的规格:Windows 7 x64,Visual Studio 2012,CMAKE 3.4.0,CUDA Toolkit 7.5

My specs: Windows 7 x64, Visual Studio 2012, CMAKE 3.4.0, CUDA Toolkit 7.5

推荐答案

多亏了Drop的提示,我解决了这个问题.为了结束这个问题,我在回答自己的问题.

Thanks to tips from Drop in the comments, I solved this problem. In order to close this question, I'm answering my own question.

这是一个"Win32或x64"体系结构问题.由于NVIDIA仅提供x64的cufftnvblasnppcnppinpps库,因此CMAKE自然不可能找到这些库来配置Win32 OpenCV库.

It's a "Win32 or x64" architecture problem. Since NVIDIA only provides cufft, nvblas, nppc, nppi, npps libs for x64, it's naturally impossible for CMAKE to find these libs for configuring a Win32 OpenCV library.

我的解决方案是在CMAKE中选择Visual Studio 11 Win64而不是Visual Studio 11作为生成器.这样,CMAKE将自动从<CUDA_DIR>\lib\x64而不是<CUDA_DIR>\lib\Win32加载库.此外,我还需要以64位版本加载OpenCV所需的所有其他库,例如OpenGL.我还需要在x64体系结构中编译OpenCV.我将来要编写的所有代码都只能在x64中构建和调试.

My solution was to choose Visual Studio 11 Win64 instead of Visual Studio 11 as generator in CMAKE. So that CMAKE will automatically load libs from <CUDA_DIR>\lib\x64 rather than <CUDA_DIR>\lib\Win32. Further more, I also need to load all the other libs required by OpenCV in 64 bit version, such as OpenGL. I will also need to compile OpenCV in x64 architecture. All the code I'm going to write in the future will have to build and debug in x64 only.

应该很容易阅读中文资料,我很乐意提供

Should one have no trouble reading Chinese materials, I'm happy to provide a link towards a post regarding the complete guide on building OpenCV 3.0 on VS2012 with CUDA supports.

这篇关于CMake:编译OpenCV时找不到CUDA库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆