OpenCV 2.4.3rc and CUDA 4.2: "OpenCV Error: GPU support not supported"

I uploaded a few screenshots in this album: http://imgur.com/a/w4jHc

I am trying to run the GPU in OpenCV in Visual Studio 2008. I am running one of the OpenCV code examples, bgfg_segm.cpp. However, when I compile (without compilation errors), it generates an “OpenCV error: no GPU support”.

  • Windows 7 32-bit
  • Visual studio 2008
  • nVidia Quadro 1000M with driver version 301.27
  • OpenCV 2.4.3rc (using the precompiled libraries that came with it)
  • CUDA Toolkit 4.2, CUDA SDK.

I can run .exe files in C: \ ProgramData \ NVIDIA Corporation \ NVIDIA GPU Computing SDK 4.2 \ C \ bin \ win32 \ Release without any errors, so it seems that CUDA is working.

I really hope that you can help, because I feel that I have to miss something obvious here. Any thoughts or suggestions are highly appreciated.

EDIT November 9, 2012:

I ended up following the sgar91 instructions and it seems like everything is working now!

One alert:. When you enter Environment Variables , check the paths for CUDA. One of mine had one backslash ( \ ) too much before bin like this C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\\bin; . There are three links to CUDA and its SDK, so check them out. Perhaps it was just a one-time accident. I am not sure if this is important at all.

Another side solution: I installed Visual Studio 2010 Express and note that the sgar91 instructions are for Visual Studio 2010 (aka "vc10"). It will not work in Visual Studio 2008 (aka "vc9") or Visual Studio 2012 (aka "vc11"), because there are no ready-made lib files with OpenCV 2.4.3 for vc9 and vc11 (vc10 only). Also, keep in mind that if you are on 64-bit Windows, you should change all X86 (32-bit) paths to X64 (64-bit) instead, when you follow his guide, but in Visual Studio you need to change the solution platform from Win32 (drop-down menu at the top, in the middle next to Debug or Release) to x64.

Another side solution: OpenCV 2.4.3 supports CUDA 4.2 (or rather, the libraries were compiled with CUDA 4.2). If you install CUDA 5.0, this will not work. It gives an error message. I can’t remember which one. If you absolutely need CUDA 5.0, you will either have to wait for OpenCV to include it in future versions or compile your own libraries through CMake.

I ran the code below (it's from here , but I had to fix one line in it so that it compiles) and it compiled and showed the image, so I expect this to mean that everything works?

 #ifdef _DEBUG #pragma comment(lib,"opencv_gpu243d") #pragma comment(lib,"opencv_core243d") #pragma comment(lib,"opencv_highgui243d") #else #pragma comment(lib,"opencv_core243") #pragma comment(lib,"opencv_highgui243") #pragma comment(lib,"opencv_gpu243") #endif #include <iostream> #include "opencv2/opencv.hpp" #include "opencv2/gpu/gpu.hpp" int main (int argc, char* argv[]) { try { cv::Mat src_host = cv::imread("file.png", CV_LOAD_IMAGE_GRAYSCALE); cv::gpu::GpuMat dst, src; src.upload(src_host); cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY); cv::Mat result_host(dst); //cv::Mat result_host = dst; //old line commented out cv::imshow("Result", result_host); //new line added by me cv::waitKey(); } catch(const cv::Exception& ex) { std::cout << "Error: " << ex.what() << std::endl; } return 0; } 

I cannot get any code in C: \ opencv \ samples \ gpu to work. It compiles, but then throws an error. But screw it on, I'll figure it out somehow :)

+7
source share
1 answer

You are using these OpenCV binaries that are compiled without GPU support.

C:\opencv\build\x86\... do not support GPU.

You must use the binaries and lib files that are present in the build\gpu folder.

C:\opencv\build\gpu\x86\... supported with GPU support.

UPDATE:

Procedure:

In Visual Studio 2010, navigate to the project properties. In the VC ++ directories, you will see the following page:

Add the path to the OpenCV include folder in the Include directories text box. Make sure that multiple paths are separated by a semicolon and that there is no space in any of the paths.

Similarly, add the path to the OpenCV lib folders for GPU and non-GPU versions in the Library Directories text box. (Do not forget the semicolon)

Important: When writing paths in this field, first write the path to the GPU, and then the path without the GPU.

enter image description here

The next step adds the path to the OpenCV bin folder. But not in the visual studio, but in the Path Environment variable, as shown below:

enter image description here

  • Right Click My Computer
  • Go to properties
  • Go to Environment Variables
  • Change the system variable Path
  • Attach C:\OpenCV\build\gpu\x86\vc10\bin and C:\OpenCV\build\x86\vc10\bin to the Path. Remember to separate the different values ​​with a semicolon. Also ---> GPU comes first .
  • Save and exit.

Restart Visual Studio. Now the linker and the #include directive will recognize OpenCV libraries. Since we added the path to the GPU libraries, so that full GPU support will be available in OpenCV.

To use the OpenCV GPU features, you just need to do the following:

  • #include opencv2/gpu/gpu.hpp
  • Specify opencv_gpu243d.lib for debug configuration or opencv_gpu243.lib for release configuration in the Additional Dependencies field in the Linker->Input properties section of the project properties.

Additional Information:

Visual Studio has an easy way to link libraries, rather than specifying them in project properties.

Just write these lines at the very beginning of your code:

 #ifdef _DEBUG #pragma comment(lib,"opencv_core243d") #pragma comment(lib,"opencv_highgui243d") #else #pragma comment(lib,"opencv_core243") #pragma comment(lib,"opencv_highgui243") #endif 
+10
source

All Articles