I have uploaded several screenshots in this album: http://imgur.com/a/w4jHc
I am trying to get GPU up and running in OpenCV in Visual Studio 2008. I am running one of the OpenCV GPU example codes, bgfg_segm.cpp. However, when I compile (with no compile errors) it throws an "OpenCV Error: No GPU suport".
- Windows 7, 32-bit
- Visual Studio 2008
- nVidia Quadro 1000M with driver version 301.27
- OpenCV 2.4.3rc (using the precompiled libs that came with it)
- CUDA Toolkit 4.2, CUDA SDK.
I can run the .exe files in C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.2\C\bin\win32\Release without any errors, so it would seem that CUDA is working.
I really hope you can help because I feel I must be missing something obvious here. Any thoughts or suggestions are highly appreciated.
EDIT November 9th 2012:
I ended up following sgar91's instructions and it seems like things are working now!
One sidenote: When you enter Environment Variables
check out the paths for CUDA. One of mine had one backslash (\
) too many before bin
like this C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\\bin;
. There are three references to CUDA and its SDK, so check them out. Maybe it was just a one-time fluke. I am not sure this matters at all.
One more sidenote: I installed Visual Studio 2010 Express, and note that sgar91's instructions are meant 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 prebuilt lib files with OpenCV 2.4.3 for vc9 and vc11 (only vc10). Also, be aware if you are on 64-bit Windows you should change all X86 paths (32-bit) to X64 (64-bit) instead when you follow his guide, and in Visual Studio you need to change the Solution Platform from Win32 (dropdown menu in the top, middle next to Debug or Release) to x64.
Yet one more sidenote: OpenCV 2.4.3 supports CUDA 4.2 (or rather the libs have been compiled with CUDA 4.2). If you install CUDA 5.0 it will not work. It throws an error message. Can't recall which. If you absolutely need CUDA 5.0 you have to either wait for OpenCV to include it in future versions or compile your own libs via CMake.
I ran the code below (it's from here, but I had to correct one line in it to make it compile) and it compiled and showed the image, so I would expect that this means things are working?
#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 can't get any of the code in C:\opencv\samples\gpu to work. It compiles, but then throws an error. But screw it, I'll figure that out somehow :)