opencv make 在 Ubuntu 上因 CUDA 支持而失败

Posted

技术标签:

【中文标题】opencv make 在 Ubuntu 上因 CUDA 支持而失败【英文标题】:opencv make fails with CUDA support on Ubuntu 【发布时间】:2016-06-17 19:21:42 【问题描述】:

我正在尝试在 ubuntu 15.10 上构建具有 CUDA 支持的 OpenCV。 CMake 显示有可用的 CUDA 7.5。 CMAKE 是成功的。当我运行 make 命令时,我得到以下输出:

   -- Configuring done
-- Generating done
-- Build files have been written to: /home/jishnu/Downloads/opencv-2.4.13/Release
[  5%] Built target IlmImf
[  6%] Built target opencv_core_pch_dephelp
[  6%] Built target pch_Generate_opencv_core
[  8%] Built target opencv_core
[  9%] Built target opencv_ts_pch_dephelp
[  9%] Built target pch_Generate_opencv_ts
[  9%] Built target opencv_imgproc_pch_dephelp
[  9%] Built target pch_Generate_opencv_imgproc
[ 12%] Built target opencv_imgproc
[ 12%] Built target opencv_flann_pch_dephelp
[ 12%] Built target pch_Generate_opencv_flann
[ 12%] Built target opencv_flann
[ 12%] Built target opencv_highgui_pch_dephelp
[ 13%] Built target pch_Generate_opencv_highgui
[ 15%] Built target opencv_highgui
[ 15%] Built target opencv_features2d_pch_dephelp
[ 15%] Built target pch_Generate_opencv_features2d
[ 16%] Built target opencv_features2d
[ 16%] Built target opencv_calib3d_pch_dephelp
[ 16%] Built target pch_Generate_opencv_calib3d
[ 18%] Built target opencv_calib3d
[ 19%] Built target opencv_video_pch_dephelp
[ 19%] Built target pch_Generate_opencv_video
[ 19%] Built target opencv_video
[ 19%] Built target opencv_ts
[ 19%] Built target opencv_perf_core_pch_dephelp
[ 19%] Built target pch_Generate_opencv_perf_core
[ 21%] Built target opencv_perf_core
[ 21%] Built target opencv_test_core_pch_dephelp
[ 21%] Built target pch_Generate_opencv_test_core
[ 22%] Built target opencv_test_core
[ 22%] Built target opencv_test_flann_pch_dephelp
[ 22%] Built target pch_Generate_opencv_test_flann
[ 23%] Built target opencv_test_flann
[ 24%] Built target opencv_perf_imgproc_pch_dephelp
[ 24%] Built target pch_Generate_opencv_perf_imgproc
[ 25%] Built target opencv_perf_imgproc
[ 25%] Built target opencv_test_imgproc_pch_dephelp
[ 25%] Built target pch_Generate_opencv_test_imgproc
[ 27%] Built target opencv_test_imgproc
[ 27%] Built target opencv_perf_highgui_pch_dephelp
[ 27%] Built target pch_Generate_opencv_perf_highgui
[ 28%] Built target opencv_perf_highgui
[ 28%] Built target opencv_test_highgui_pch_dephelp
[ 28%] Built target pch_Generate_opencv_test_highgui
[ 29%] Built target opencv_test_highgui
[ 29%] Built target opencv_perf_features2d_pch_dephelp
[ 29%] Built target pch_Generate_opencv_perf_features2d
[ 29%] Built target opencv_perf_features2d
[ 29%] Built target opencv_test_features2d_pch_dephelp
[ 30%] Built target pch_Generate_opencv_test_features2d
[ 31%] Built target opencv_test_features2d
[ 31%] Built target opencv_perf_calib3d_pch_dephelp
[ 31%] Built target pch_Generate_opencv_perf_calib3d
[ 31%] Built target opencv_perf_calib3d
[ 31%] Built target opencv_test_calib3d_pch_dephelp
[ 31%] Built target pch_Generate_opencv_test_calib3d
[ 33%] Built target opencv_test_calib3d
[ 33%] Built target opencv_ml_pch_dephelp
[ 33%] Built target pch_Generate_opencv_ml
[ 34%] Built target opencv_ml
[ 34%] Built target opencv_test_ml_pch_dephelp
[ 35%] Built target pch_Generate_opencv_test_ml
[ 36%] Built target opencv_test_ml
[ 36%] Built target opencv_perf_video_pch_dephelp
[ 37%] Built target pch_Generate_opencv_perf_video
[ 38%] Built target opencv_perf_video
[ 38%] Built target opencv_test_video_pch_dephelp
[ 39%] Built target pch_Generate_opencv_test_video
[ 40%] Built target opencv_test_video
[ 40%] Built target opencv_legacy_pch_dephelp
[ 40%] Built target pch_Generate_opencv_legacy
[ 47%] Built target opencv_legacy
[ 47%] Built target opencv_test_legacy_pch_dephelp
[ 47%] Built target pch_Generate_opencv_test_legacy
[ 47%] Built target opencv_test_legacy
[ 47%] Built target opencv_objdetect_pch_dephelp
[ 47%] Built target pch_Generate_opencv_objdetect
[ 48%] Built target opencv_objdetect
[ 48%] Built target opencv_perf_objdetect_pch_dephelp
[ 48%] Built target pch_Generate_opencv_perf_objdetect
[ 48%] Built target opencv_perf_objdetect
[ 48%] Built target opencv_test_objdetect_pch_dephelp
[ 48%] Built target pch_Generate_opencv_test_objdetect
[ 48%] Built target opencv_test_objdetect
[ 48%] Built target opencv_photo_pch_dephelp
[ 48%] Built target pch_Generate_opencv_photo
[ 48%] Built target opencv_photo
[ 48%] Built target opencv_perf_photo_pch_dephelp
[ 48%] Built target pch_Generate_opencv_perf_photo
[ 49%] Built target opencv_perf_photo
[ 49%] Built target opencv_test_photo_pch_dephelp
[ 49%] Built target pch_Generate_opencv_test_photo
[ 50%] Built target opencv_test_photo
[ 50%] Built target opencv_gpu_pch_dephelp
[ 50%] Built target pch_Generate_opencv_gpu
Linking CXX shared library ../../lib/libopencv_gpu.so
[ 61%] Built target opencv_gpu
[ 61%] Built target opencv_perf_gpu_pch_dephelp
[ 61%] Built target pch_Generate_opencv_perf_gpu
Linking CXX executable ../../bin/opencv_perf_gpu
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `ncvHaarGetClassifierSize(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int&, unsigned int&, unsigned int&)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Ballard_Pos_findPosInHist_gpu(cv::gpu::PtrStepSz<int>, float4*, int3*, int, float, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::buildRTable_gpu(unsigned int const*, float const*, int, cv::gpu::PtrStepSz<short2>, int*, short2, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_calcPHist_gpu(int const*, int const*, cv::gpu::PtrStepSz<int>, float, float, float, float, int, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Ballard_PosRotation_calcHist_gpu(unsigned int const*, float const*, int, cv::gpu::PtrStepSz<short2>, int const*, cv::gpu::PtrStep<int>, int, int, float, float, int, float, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_buildImageFeatureList_gpu(unsigned int const*, float const*, int, int*, int, float, float, int, float2, float)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `int cv::gpu::device::hough::buildEdgePointList_gpu<float>(cv::gpu::PtrStepSz<unsigned char>, cv::gpu::PtrStepSz<unsigned char>, cv::gpu::PtrStepSz<unsigned char>, unsigned int*, float*)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `ncvDebugOutput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_calcSHist_gpu(int const*, int const*, int*, float, float, float, float, float, int, int, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Ballard_PosScale_findPosInHist_gpu(cv::gpu::PtrStep<int>, int, int, int, float4*, int3*, int, float, float, float, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `int cv::gpu::device::hough::buildEdgePointList_gpu<int>(cv::gpu::PtrStepSz<unsigned char>, cv::gpu::PtrStepSz<unsigned char>, cv::gpu::PtrStepSz<unsigned char>, unsigned int*, float*)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Ballard_PosRotation_findPosInHist_gpu(cv::gpu::PtrStep<int>, int, int, int, float4*, int3*, int, float, float, float, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_setImageFeatures(cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `int cv::gpu::device::hough::buildEdgePointList_gpu<short>(cv::gpu::PtrStepSz<unsigned char>, cv::gpu::PtrStepSz<unsigned char>, cv::gpu::PtrStepSz<unsigned char>, unsigned int*, float*)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_findPosInHist_gpu(cv::gpu::PtrStepSz<int>, float4*, int3*, int, int, float, int, float, int, float, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `ncvSetDebugOutputHandler(void (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&))'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Ballard_Pos_calcHist_gpu(unsigned int const*, float const*, int, cv::gpu::PtrStepSz<short2>, int const*, cv::gpu::PtrStepSz<int>, float, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_setTemplFeatures(cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>, cv::gpu::PtrStep<unsigned char>)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `loadFromXML(std::string const&, HaarClassifierCascadeDescriptor&, std::vector<HaarStage64, std::allocator<HaarStage64> >&, std::vector<HaarClassifierNode128, std::allocator<HaarClassifierNode128> >&, std::vector<HaarFeature64, std::allocator<HaarFeature64> >&)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_calcOHist_gpu(int const*, int const*, int*, float, float, float, int, int, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Guil_Full_buildTemplFeatureList_gpu(unsigned int const*, float const*, int, int*, int, float, float, int, float2, float)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `cv::gpu::device::hough::GHT_Ballard_PosScale_calcHist_gpu(unsigned int const*, float const*, int, cv::gpu::PtrStepSz<short2>, int const*, cv::gpu::PtrStep<int>, int, int, float, float, int, float, int)'
../../lib/libopencv_gpu.so.2.4.13: undefined reference to `ncvHaarLoadFromFile_host(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, HaarClassifierCascadeDescriptor&, NCVVector<HaarStage64>&, NCVVector<HaarClassifierNode128>&, NCVVector<HaarFeature64>&)'
collect2: error: ld returned 1 exit status
modules/gpu/CMakeFiles/opencv_perf_gpu.dir/build.make:364: recipe for target 'bin/opencv_perf_gpu' failed
make[2]: *** [bin/opencv_perf_gpu] Error 1
CMakeFiles/Makefile2:4453: recipe for target 'modules/gpu/CMakeFiles/opencv_perf_gpu.dir/all' failed
make[1]: *** [modules/gpu/CMakeFiles/opencv_perf_gpu.dir/all] Error 2
Makefile:146: recipe for target 'all' failed
make: *** [all] Error 2

我之前在没有 CUDA 支持的情况下构建了 OpenCV,它运行良好。

【问题讨论】:

您找到解决方案了吗?我现在正在为完全相同的错误而苦苦挣扎.. 您好,有什么解决办法吗?卡在确切的错误上。! 【参考方案1】:

这可能是由于您的 GPU 设备与库的兼容性问题。您能否指定您正在使用的 GPU 设备以及它是物理设备还是模拟设备?

【讨论】:

您好,我在配备 512MB NVIDIA® Quadro NVS 3100M 的 Thinkpad 410 上运行此程序。【参考方案2】:

解决它 检查你的 cmake gcc 和 g++ 版本 需要相同的版本

【讨论】:

以上是关于opencv make 在 Ubuntu 上因 CUDA 支持而失败的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu 下用于 C++ 编译的 OpenCV 2.4.13 失败

在ubuntu系统中测试opencv是否安装成功

Ubuntu 18.04配置OpenCV 4.2.0

Ubuntu安装opencv 为调用gpu模块

OpenCV Linux 安装 Make出错

在 Ubuntu 14.04 上安装 opencv-3.0.0-beta 时出错