Ask Your Question
0

Failure building OpenCV 3.2 with CUDA support for VS15

asked 2017-02-01 13:01:07 -0600

ThorbjornSomod gravatar image

Hi!

I am trying to build OpenCV 3.2 with CUDA support for Microsoft Visual Studio 15 on Windows 10, but I have run into some trouble. I'll try to go through step by step what I have done so far to make it easier for you guys to understand if and where I have done anything wrong. So:

  • I startet out downloading the pre-built binaries of OpenCV 3.2 for Windows 10 from www.opencv.org/downloads.html. I placed OpenCV at C:\opencv for an easy path.
  • I then opened a command promt and navigated to the C:\opencv directory and cloned the git repository for the opencv_contrib modules into that directory. The contents of C:\opencv is so far the folders build, opencv_contrib and sources.
  • I then downloaded the latest version of the CUDA Toolbox, although I have read that this comes with OpenCV 3.2 already.
  • Next, I downloaded the latest version of Cmake and opened the GUI. I set the source code folder to C:/opencv/sources and the build folder to C:/opencv/build.
  • I then clicked configure, waited for it to be done and changed the OPENCV_EXTRA_MODULES_PATH to C:/opencv/opencv_contrib/modules. I then clicked reconfigure and acquired the list of all modules that the source material would allow me to generate a solution for.
  • Next, I ticked on the opencv_contrib modules that I need (ximgproc, xfeatures2d, plot, text and xobjdetect) and all the cuda modules. I also ticked on BUILD_CUDA_STUBS. I made sure that WITH_CUBLAS and WITH_CUDA was ticked on, set my CUDA_ARCH_BIN to 5.2 and CUDA_GENERATION to Maxwell (I'm using a GTX 960). I then generated the solution. This all went fine with no errors. Note: The generation was done with the Microsoft Visual Studio 14 2015 C++ compiler, as this is the only one I have gotten the opencv_contrib modules to work with before.
  • I then opened the OpenCV.sln project and built the ALL_BUILD and INSTALL projects in both debug and release, in that order. This produced the warnings mentioned here but completed with no errors.
  • I thought everything was fine at this point and decided to make an example project to test out OpenCV's capabilities with CUDA support. I made a new VS15 project and set up the include directories, linkers and library directories. Now, when I try to compile my example project I get the error:

    OpenCV Error: No CUDA support (The library is compiled without CUDA support) in throw_no_cuda, file C:\build\master_winpack-build-win64-vc14\opencv\modules\core\include\opencv2/core/private.cuda.hpp, line 97
    

Anyone else experienced anything similar? And does anyone know how to fix this? Any help would be appreciated.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-02-01 13:10:11 -0600

LBerger gravatar image

updated 2017-02-01 14:03:42 -0600

VS 2015 opencv 3.2-dev opencv_contrib if you want to use CUDA you have to clone opencv repo too and build opencv using cmake There is no CUDA in pre-built binaries of OpenCV 3.2

in folder g:/lib

  1. git clone https://github.com/opencv/opencv.git
  2. git clone https://github.com/opencv/opencv_cont...
  3. run cmakegui
  4. Where is source code = g:/lib/opencv
  5. Where to build binaries =g:/lib/opencv/build
  6. select generator Visual Studio 14 2015 win64 press configure
  7. in CMake gui set OPENCv_EXTRA_MODULE_PATH to g:/lib/opencv_contrib/modules
  8. you can set OPENCV_ENABLE_NONFREE if you want SURF, SIFT... good idea is too set BUILD_EXAMPLES to true
  9. You can disable BUILD_TESTS and BUILD_PERF_TESTS
  10. WITH CUDA should be on if you have install CUDA and and CUDA card.
  11. Set CUDA ARCH_BIN. If you have 2.0 3.0 3.5 3.7... It take 4 hours to build opencv or more...Use only one arch.
  12. press generate and no error (I hope so)

open.sln project should be in g:/lib/opencv/build open and generate. If you have doxygen it is quite long ...You can install opencv if you like

Now for your own project if you run cmake without installing opencv you have to set manually OPENCV_DIR to g:/lib/opencv/build

edit flag offensive delete link more

Comments

Ok so say that I cloned the repositories from https://github.com/opencv/opencv and https://github.com/opencv/opencv_contrib, how would I generate the solution with Cmake based on this? What would I choose as Source folder and Build destination? Would you be able to provide an example of a folder hierarchy for doing this? Thank you for the quick response by the way, much appreciated! :)

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-01 13:37:41 -0600 )edit
1

Thank you! I see some differences as to what I have tried before, and I believe this will fix my issues! Marked as aswered.

ThorbjornSomod gravatar imageThorbjornSomod ( 2017-02-01 14:51:19 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-02-01 13:01:07 -0600

Seen: 2,012 times

Last updated: Feb 01 '17