Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opencv 3.1. CUDA 8 compatibility issues #6632

Closed
timsamart opened this issue Jun 4, 2016 · 6 comments
Closed

Opencv 3.1. CUDA 8 compatibility issues #6632

timsamart opened this issue Jun 4, 2016 · 6 comments
Labels
category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib invalid

Comments

@timsamart
Copy link

First of all I know Cuda 8 came fresh out of the box, However I think there are some people who would love to see support for Visual Studio 2015 because Cuda 7.5 was not ready to be compiled out of the box for VS 2015.

However with the current master branch I encountered some errors which I guess must come from using CUDA 8 toolkit. Further I will discuss those Errors.

There are some Errors also in perf_tests but I just disabled them in cmake because I figured they are not as important for the time being.

System

  • OpenCV version: 3.1 (current master branch 20160603 18:00)
  • Win 8.1
  • VS 2015 Compiler
  • CUDA 8 toolkit

Current Issue present in following Project:

  • opencv_cudaimgproc

Additional description

Current Cmake excerpt of Cuda settings

NVIDIA CUDA
    Use CUFFT:                   YES
    Use CUBLAS:                  NO
    USE NVCUVID:                 NO
    NVIDIA GPU arch:             20 21 30 35
    NVIDIA PTX archs:            30
    Use fast math:               NO

Compiler

C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe  (ver 19.0.23506.0)`

Cmake NVCC target flags:

CUDA detected: 8.0
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;-D_FORCE_INLINES;-gencode;arch=compute_30,code=compute_30

Compiler output:

Severity    Code    Description Project File    Line    Suppression State
Error       no default constructor exists for class "thrust::detail::execute_with_allocator<cv::cuda::device::ThrustAllocator, thrust::system::cuda::detail::execute_on_stream_base>"   opencv_cudaimgproc  D:\Libs\CUDA8toolkit\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>"   opencv_cudaimgproc  D:\Libs\CUDA8toolkit\include\thrust\detail\reference.inl    98  
Error       no default constructor exists for class "thrust::detail::execute_with_allocator<cv::cuda::device::ThrustAllocator, thrust::system::cuda::detail::execute_on_stream_base>"   opencv_cudaimgproc  D:\Libs\CUDA8toolkit\include\thrust\detail\reference.inl    98  
Error       no default constructor exists for class "thrust::detail::execute_with_allocator<cv::cuda::device::ThrustAllocator, thrust::system::cuda::detail::execute_on_stream_base>"   opencv_cudaimgproc  D:\Libs\CUDA8toolkit\include\thrust\detail\reference.inl    98  

Code Section Error is referring to:

__thrust_exec_check_disable__
template<typename Element, typename Pointer, typename Derived>
  template<typename OtherPointer>
    void reference<Element,Pointer,Derived>
      ::assign_from(OtherPointer src)
{
  typedef typename thrust::iterator_system<pointer>::type      System1;
  typedef typename thrust::iterator_system<OtherPointer>::type System2;

  System1 system1; // THIS IS THE LINE THROWING THE ERROR
  System2 system2;

  using thrust::system::detail::generic::select_system;

  strip_const_assign_value(select_system(system1, system2), src);
} // end assign_from()

And:

__thrust_exec_check_disable__
template<typename Element, typename Pointer, typename Derived>
  reference<Element,Pointer,Derived>
    ::operator typename reference<Element,Pointer,Derived>::value_type () const
{
  typedef typename thrust::iterator_system<pointer>::type System;

  System system;  // THIS IS THE LINE THROWING THE ERROR
  using thrust::system::detail::generic::select_system;
  return strip_const_get_value(select_system(system));
} // end reference::operator value_type ()

So yeah maybe someone has an Idea? because I am not getting anywhere with this.

Also it's the first time posting on here so feel free to correct me if i missed something!

@itooon
Copy link

itooon commented Jun 5, 2016

This issue has a workaround on below url.

NVIDIA/thrust#800

@timsamart
Copy link
Author

Perfect! Thank you very much @itooon it compiled!

For everyone else having this problem, here is the solution from thrust issue#800 proposed by @bramton
clone:
https://github.com/thrust/thrust.git

and replace the thrust folder from CUDA 8 toolkit with the one from thrust 1.8.3 branch you cloned.

Nvidia told User @bramton They already fixed the issue and we will get the official fix with the next version of cuda 8 toolkit

I will comment again when I checked if everything works.

@ahaque
Copy link

ahaque commented Aug 14, 2016

The solution stated by @timsamart worked for me on CUDA 8, Ubuntu 16.04.1, GCC 4.9.3 and it did not break any of my other CUDA dependencies.

@vincenttsai2015
Copy link

I tried the approach provided by @timsamart but still failed with the following error messages:
(My machine environment: Linux Mint 18+CUDA 8.0)
[ 94%] Building CXX object modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/src/graphcuts.cpp.o
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
typedef NppStatus (init_func_t)(NppiSize oSize, NppiGraphcutState* ppState, Npp8u* pDeviceMem);
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:135:18: error: ‘NppiGraphcutState’ does not name a type
operator NppiGraphcutState*()
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:141:9: error: ‘NppiGraphcutState’ does not name a type
NppiGraphcutState* pState;
^
In file included from /home/vincenttsai/opencv-3.1.0/build/modules/cudalegacy/precomp.hpp:75:0:
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp: In constructor ‘{anonymous}::NppiGraphcutStateHandler::NppiGraphcutStateHandler(NppiSize, Npp8u*, {anonymous}::init_func_t)’:
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:127:39: error: ‘pState’ was not declared in this scope
nppSafeCall( func(sznpp, &pState, pDeviceMem) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp: In destructor ‘{anonymous}::NppiGraphcutStateHandler::~NppiGraphcutStateHandler()’:
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:132:43: error: ‘pState’ was not declared in this scope
nppSafeCall( nppiGraphcutFree(pState) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:132:49: error: ‘nppiGraphcutFree’ was not declared in this scope
nppSafeCall( nppiGraphcutFree(pState) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp: In function ‘void cv::cuda::graphcut(cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::Stream&)’:
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:174:51: error: ‘nppiGraphcutGetSize’ was not declared in this scope
nppSafeCall( nppiGraphcutGetSize(sznpp, &bufsz) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:182:61: error: ‘nppiGraphcutInitAlloc’ was not declared in this scope
NppiGraphcutStateHandler state(sznpp, buf.ptr(), nppiGraphcutInitAlloc);
^
In file included from /home/vincenttsai/opencv-3.1.0/build/modules/cudalegacy/precomp.hpp:75:0:
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:191:146: error: ‘nppiGraphcut_32s8u’ was not declared in this scope
static_cast(terminals.step), static_cast(leftTransp.step), sznpp, labels.ptr(), static_cast(labels.step), state) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:196:146: error: ‘nppiGraphcut_32f8u’ was not declared in this scope
static_cast(terminals.step), static_cast(leftTransp.step), sznpp, labels.ptr(), static_cast(labels.step), state) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp: In function ‘void cv::cuda::graphcut(cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::Stream&)’:
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:246:52: error: ‘nppiGraphcut8GetSize’ was not declared in this scope
nppSafeCall( nppiGraphcut8GetSize(sznpp, &bufsz) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:254:61: error: ‘nppiGraphcut8InitAlloc’ was not declared in this scope
NppiGraphcutStateHandler state(sznpp, buf.ptr(), nppiGraphcut8InitAlloc);
^
In file included from /home/vincenttsai/opencv-3.1.0/build/modules/cudalegacy/precomp.hpp:75:0:
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:267:146: error: ‘nppiGraphcut8_32s8u’ was not declared in this scope
static_cast(terminals.step), static_cast(leftTransp.step), sznpp, labels.ptr(), static_cast(labels.step), state) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
/home/vincenttsai/opencv-3.1.0/modules/cudalegacy/src/graphcuts.cpp:274:146: error: ‘nppiGraphcut8_32f8u’ was not declared in this scope
static_cast(terminals.step), static_cast(leftTransp.step), sznpp, labels.ptr(), static_cast(labels.step), state) );
^
/home/vincenttsai/opencv-3.1.0/modules/core/include/opencv2/core/private.cuda.hpp:165:52: note: in definition of macro ‘nppSafeCall’
#define nppSafeCall(expr) cv::cuda::checkNppError(expr, FILE, LINE, CV_Func)
^
modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/build.make:338: recipe for target 'modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/src/graphcuts.cpp.o' failed
make[2]: *** [modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/src/graphcuts.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:9120: recipe for target 'modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/all' failed
make[1]: *** [modules/cudalegacy/CMakeFiles/opencv_cudalegacy.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

Is there something I need to install or fix? Thanks.

@vict0rsch
Copy link

I have the same issue with Ubuntu 16 and cuda 8.0 -> Makefile:160: recipe for target 'all' failed make: *** [all] Error 2 (interestingly also at 94%).

Any known fix since this issue was raised?

@alalek
Copy link
Member

alalek commented Mar 2, 2017

Fix should be in OpenCV 3.2 (this issue blames OpenCV 3.1): #6510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib invalid
Projects
None yet
Development

No branches or pull requests

7 participants