title: CUDA not running in OpenCV even after successful build
body: <p>I am trying to build OpenCV 2.4.10 on a Win 8.1 machine with CUDA 6.5. I have other third part libraries as well and they have installed successfully. I ram a simple GPU based program and I got this error <code>No GPU found or the library was compiled without GPU support</code>. I also ran the sample exe files like <code>performance_gpu.exe</code> that were built during the installation and I got the same error. I also had WITH_CUDA flag checked. Following are the flags (related to CUDA) that were set during the CMAKE build.</p>
  
  <ul>
  <li>WITH_CUDA : Checked</li>
  <li>WITH_CUBLAS : Checked</li>
  <li>WITH_CUFFT : Checked</li>
  <li>CUDA_ARCH_BIN : 1.1 1.2 1.3 2.0 2.1(2.0) 3.0 3.5</li>
  <li>CUDA_ARCH_PTX : 3.0</li>
  <li>CUDA_FAST_MATH : Checked</li>
  <li>CUDA_GENERATION : Auto</li>
  <li>CUDA_HOST_COMPILER : $(VCInstallDir)bin</li>
  <li>CUDA_SPERABLE_COMPILATION : Unchecked</li>
  <li>CUDA_TOOLKIT_ROOT_DIR : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v6.5</li>
  </ul>
  
  <p>Another thing is that in some posts I have read that along with CUDA the built takes a lot of time. My build takes ~ 3 Hrs where maximum time is taken up during the compilation of <code>.cu</code> files. I have not got any errors as far as I know during the compilation of those files. </p>
  
  <p>In some posts I have seen that people talk about a directory names <code>gpu</code> inside the <code>build</code> directory but I don't see any in mine!</p>
  
  <p>I am using Visual Studio 2013.</p>
  
  <p>What could be the issue? Please help!</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I again tried to build opencv and this time before starting the build I added the bin, lib and include directories of CUDA. After the build in <code>E:\opencv\build\bin\Release</code> I ran <code>gpu_perf4au.exe</code> and I got this output </p>
  
  <pre><code>[----------]
  [   INFO   ]    Implementation variant: cuda.
  [----------]
  [----------]
  [ GPU INFO ]    Run test suite on GeForce GTX 860M GPU.
  [----------]
  Time compensation is 0
  OpenCV version: 2.4.10
  OpenCV VCS version: unknown
  Build type: release
  Parallel framework: tbb
  CPU features: sse sse2 sse3 ssse3 sse4.1 sse4.2 avx avx2
  [----------]
  [ GPU INFO ]    Run on OS Windows x64.
  [----------]
  *** CUDA Device Query (Runtime API) version (CUDART static linking) ***
  
  Device count: 1
  
  Device 0: "GeForce GTX 860M"
    CUDA Driver Version / Runtime Version          6.50 / 6.50
    CUDA Capability Major/Minor version number:    5.0
    Total amount of global memory:                 2048 MBytes (2147483648 bytes)
    GPU Clock Speed:                               1.02 GHz
    Max Texture Dimension Size (x,y,z)             1D=(65536), 2D=(65536,65536), 3
  D=(4096,4096,4096)
    Max Layered Texture Size (dim) x layers        1D=(16384) x 2048, 2D=(16384,16
  384) x 2048
    Total amount of constant memory:               65536 bytes
    Total amount of shared memory per block:       49152 bytes
    Total number of registers available per block: 65536
    Warp size:                                     32
    Maximum number of threads per block:           1024
    Maximum sizes of each dimension of a block:    1024 x 1024 x 64
    Maximum sizes of each dimension of a grid:     2147483647 x 65535 x 65535
    Maximum memory pitch:                          2147483647 bytes
    Texture alignment:                             512 bytes
    Concurrent copy and execution:                 Yes with 1 copy engine(s)
    Run time limit on kernels:                     Yes
    Integrated GPU sharing Host Memory:            No
    Support host page-locked memory mapping:       Yes
    Concurrent kernel execution:                   Yes
    Alignment requirement for Surfaces:            Yes
    Device has ECC support enabled:                No
    Device is using TCC driver mode:               No
    Device supports Unified Addressing (UVA):      Yes
    Device PCI Bus ID / PCI location ID:           1 / 0
    Compute Mode:
        Default (multiple host threads can use ::cudaSetDevice() with device simul
  taneously)
  
  deviceQuery, CUDA Driver = CUDART, CUDA Driver Version  = 6.50, CUDA Runtime Ver
  sion = 6.50, NumDevs = 1
  </code></pre>
  
  <p>I thought that every thing was fine but after running this program where I had included all opencv and CUDA directories in its property files,</p>
  
  <pre><code>#include &lt;cv.h&gt;
  #include &lt;highgui.h&gt;
  #include &lt;iostream&gt;
  #include &lt;opencv2\opencv.hpp&gt;
  #include &lt;opencv2\gpu\gpu.hpp&gt;
  
  using namespace std;
  using namespace cv;
  
  char key;
  
  Mat thresholder (Mat input) {
      gpu::GpuMat dst, src;
      src.upload(input);
      gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);
      Mat result_host(dst);
      return result_host;
  }
  
  int main(int argc, char* argv[]) {
  
      cvNamedWindow("Camera_Output", 1);
      CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
  
      while (1){
          IplImage* frame = cvQueryFrame(capture);
          IplImage* gray_frame = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 1);
          cvCvtColor(frame, gray_frame, CV_RGB2GRAY);
  
          Mat temp(gray_frame);
          Mat thres_temp;
          thres_temp = thresholder(temp);
          //cvShowImage("Camera_Output", frame);   //Show image frames on created window
          imshow("Camera_Output", thres_temp);
  
          key = cvWaitKey(10);
          if (char(key) == 27){
              break;      //If you hit ESC key loop will break.
          }
      }
      cvReleaseCapture(&amp;capture);
      cvDestroyWindow("Camera_Output");
      return 0;
  }
  </code></pre>
  
  <p>I got the error:</p>
  
  <pre><code>OpenCV Error: No GPU support (The library is compiled without CUDA support) in E
  mptyFuncTable::mallocPitch, file C:\builds\2_4_PackSlave-win64-vc12-shared\openc
  v\modules\dynamicuda\include\opencv2/dynamicuda/dynamicuda.hpp, line 126
  </code></pre>