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 :)