我曾尝试在CUDA支持下使用OpenCV。
我安装了Visual Studio 12 2013 Win64,OpenCV 3.1.0和CUDA 7.5。
使用WITH_CUDA = ON进行Cmake生成后,配置的结果如下所示。
我已将Markustp的问题页link 1视为我的情况,
和link 2关于修复opencv_world
如第一个链接所述, 我已经在CMAKELists.txt(C:\ opencv \ sources \ CMakeLists.txt中的文件)中用“$ {CMAKE_LIBRARY_PATH_FLAG}”替换了“-L”, 就像Dubrzr的建议一样。
# --------------------------------------------------------------------------
# Add CUDA libraries (needed for apps/tools, samples)
# --------------------------------------------------------------------------
if(HAVE_CUDA)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
if(HAVE_CUBLAS)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUFFT)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
endif()
foreach(p ${CUDA_LIBS_PATH})
---original source: set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} -L${p}
---revised part : set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}${p})
endforeach()
endif()
接下来,我生成了OpenCV.sln,
已完成调试,发布选项(X64)中的构建和停止,没有任何错误。
当我构建像这样的opencv-cuda代码时,
#include <opencv2\cvconfig.h>
#include <opencv2\core\cvdef.h>
#include <opencv2\core\base.hpp>
#include <opencv2\core\core.hpp>
#include <opencv2\core\cuda.hpp>
#include <cuda.h>
#include <opencv2\highgui.hpp>
#include <iostream>
#include <stdio.h>
#include <Windows.h>
#include <opencv2\core\cuda.inl.hpp>
#include <opencv2\world.hpp>
#include <cuda_runtime.h>
using namespace std;
int main(){
int nDevices;
//cv::cuda::setDevice(0);
try{
cout << cv::cuda::getDevice();
}
catch (const cv::Exception& ex){
std::cout << "Error: " << ex.what() << endl;
}
int a = cv::cuda::getCudaEnabledDeviceCount();
//if (cv::cuda::DeviceInfo::isCompatible())
//{
//printf("Device is Compatible with OpenCV GPU-built binaries \n");
//}
printf("Enabled device count: %d\n", a);
cudaGetDeviceCount(&nDevices);
for (int i = 0; i < nDevices; i++){
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, i);
printf("Device Number : %d\n", i);
printf("Device name: %s\n", prop.name);
printf("Memory Clock Rate (KHz): %d\n", prop.memoryClockRate);
}
return 0;
}
结果是,
OpenCV Error: No CUDA support <The library is compiled without CUDA support> in throw_no_cuda,
file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\include\opencv2\core\private.cuda.hpp, line 97
Error: C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\include\opencv2\core\private.cuda.hpp, line 97:
error: <-216> The library is compiled without CUDA support in funtion throw_no_cuda
Enabled device count: 0
Device Number : 0
Device name: GeForce GTX TITAN Z
Memory Clock Rate <kHz>: 3505000
Device Number : 1
Device name: GeForce GTX TITAN Z
Memory Clock Rate <kHz>: 3505000
我认为CUDA安装得很好(CUDA函数cudaGetDeviceCount运行良好,但函数throw_no_cuda(OpenCV函数??)可能有问题....
有人请帮助我T.T。
我花了过去一整天的时间来解决这个问题。
如何修复此错误 C:\ builds \ master_PackSlave-win64-vc12 shared \ opencv \ modules \ core \ include \ opencv2 / core / private.cuda.hpp
我找不到上面的目录,C:\ builds \ master_PackSlave-win64 ......