使用源码编译opencv master分支(3.1.0)时,出现如下错误:
/usr/local/cuda/include/thrust/detail/reference.inl(127): error: no default constructor exists for class "thrust::detail::execute_with_allocator<cv::cuda::device::ThrustAllocator, thrust::system::cuda::detail::execute_on_stream_base>"
detected during:
instantiation of "void thrust::reference<Element, Pointer, Derived>::assign_from(OtherPointer) [with Element=float2, Pointer=thrust::pointer<float2, thrust::detail::execute_with_allocator<cv::cuda::device::ThrustAllocator, thrust::system::cuda::detail::execute_on_stream_base>, thrust::use_default, thrust::use_default>, Derived=thrust::use_default, OtherPointer=const float2 *]"
(65): here
......
4 errors detected in the compilation of "/tmp/tmpxft_00003fb9_00000000-17_gftt.compute_60.cpp1.ii".
CMake Error at cuda_compile_generated_gftt.cu.o.cmake:264 (message):
Error generating file
/home/chengxiang/workspace/opencv/build/modules/cudaimgproc/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gftt.cu.o
modules/cudaimgproc/CMakeFiles/opencv_cudaimgproc.dir/build.make:3603: recipe for target 'modules/cudaimgproc/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gftt.cu.o' failed
make[2]: *** [modules/cudaimgproc/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gftt.cu.o] Error 1
CMakeFiles/Makefile2:4419: recipe for target 'modules/cudaimgproc/CMakeFiles/opencv_cudaimgproc.dir/all' failed
make[1]: *** [modules/cudaimgproc/CMakeFiles/opencv_cudaimgproc.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
这是一个cuda8.0 rc版本bug, 使用github上的thrust 1.8.3tag替换cuda8.0rc安装时的thrust即可.
# find the thrust directory
find /usr/local/cuda -type d -name "thrust"
# clone the 1.8.3 thrust from github
git clone https://github.com/thrust/thrust.git -b 1.8.3
# diff them
diff -u thrust /usr/local/cuda/include/thrust
# backup the cuda/thrust
sudo mv /usr/local/cuda/include/thrust /usr/local/cuda/include/thrust_old
# move the thrust to cuda dir
sudo mv ./thrust /usr/local/cuda/include/thrust
实际测试通过,配置如下:
- opencv:3.1.0(master)
- cuda:8.0.26