title: OpenCV 2.4.3rc and CUDA 4.2: "OpenCV Error: No GPU support"
body: <p>I have uploaded several screenshots in this album: <a href="http://imgur.com/a/w4jHc" rel="nofollow">http://imgur.com/a/w4jHc</a></p>
  
  <p>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".</p>
  
  <ul>
  <li>Windows 7, 32-bit</li>
  <li>Visual Studio 2008</li>
  <li>nVidia Quadro 1000M with driver version 301.27</li>
  <li>OpenCV 2.4.3rc (using the precompiled libs that came with it)</li>
  <li>CUDA Toolkit 4.2, CUDA SDK.</li>
  </ul>
  
  <p>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.</p>
  
  <p>I really hope you can help because I feel I must be missing something obvious here. Any thoughts or suggestions are highly appreciated.</p>
  
  <p><strong>EDIT November 9th 2012:</strong></p>
  
  <p>I ended up following sgar91's instructions and it seems like things are working now! </p>
  
  <p><strong>One sidenote:</strong> When you enter <code>Environment Variables</code> check out the paths for CUDA. One of mine had one backslash (<code>\</code>) too many before <code>bin</code> like this <code>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\\bin;</code>. 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.</p>
  
  <p><strong>One more sidenote:</strong> 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.</p>
  
  <p><strong>Yet one more sidenote:</strong> 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.</p>
  
  <p>I ran the code below (it's from <a href="http://opencv.willowgarage.com/wiki/OpenCV_GPU#Short_Sample" rel="nofollow">here</a>, 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? </p>
  
  <pre><code>#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 &lt;iostream&gt;
      #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&amp; ex)
          {
              std::cout &lt;&lt; "Error: " &lt;&lt; ex.what() &lt;&lt; std::endl;
          }
          return 0;
  
      }
  </code></pre>
  
  <p>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 :)</p>