<h5 dir="auto">System information (version)</h5>
<ul dir="auto">
<li>OpenCV =&gt; latest pull from git ... 3.1.0-1483-g73a8fa8</li>
<li>Operating System / Platform =&gt; Ubuntu Linux 16.04, Kernel 4.7.5</li>
<li>Compiler =&gt; ?</li>
</ul>
<h5 dir="auto">In which part do you get the Issue</h5>
<p dir="auto">the cmake bit works (I think, no errors but ... I don't know enough about it)</p>
<p dir="auto">make</p>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">Similar error to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="152966521" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/6500" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/6500/hovercard" href="https://github.com/opencv/opencv/issues/6500">#6500</a> . I don't think it's a duplicate because it's using CUDA 8 and not 7.5<br>
Also I tried all the fixes mentioned in that one, but still have the same problem :(</p>
<p dir="auto">[  2%] Building NVCC (Device) object modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o<br>
In file included from /home/brian/opencv/opencv/modules/core/include/opencv2/core.hpp:3195:0,<br>
from /home/brian/opencv/opencv/modules/core/include/opencv2/core/cuda.hpp:51,<br>
from /home/brian/opencv/opencv/modules/core/src/cuda/gpu_mat.cu:51:<br>
/home/brian/anaconda2/include/opencv2/core/operations.hpp:72:0: warning: "CV_XADD" redefined<br>
#define CV_XADD <strong>sync_fetch_and_add<br>
...<br>
then a whole heap of<br>
/home/brian/anaconda2/include/opencv2/core/mat.hpp(__xxx</strong>): error: identifier <strong>xxx</strong> is undefined<br>
...<br>
Error limit reached.<br>
100 errors detected in the compilation of "/tmp/tmpxft_00003ea1_00000000-11_gpu_mat.compute_37.cpp1.ii".<br>
Compilation terminated.<br>
CMake Error at cuda_compile_generated_gpu_mat.cu.o.cmake:266 (message):<br>
Error generating file<br>
/home/brian/opencv/opencv/build/modules/core/CMakeFiles/cuda_compile.dir/src/cuda/./cuda_compile_generated_gpu_mat.cu.o</p>
<p dir="auto">modules/core/CMakeFiles/opencv_core.dir/build.make:402: recipe for target 'modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o' failed<br>
make[2]: *** [modules/core/CMakeFiles/cuda_compile.dir/src/cuda/cuda_compile_generated_gpu_mat.cu.o] Error 1<br>
CMakeFiles/Makefile2:2086: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed<br>
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2<br>
Makefile:160: recipe for target 'all' failed<br>
make: *** [all] Error 2</p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">as per: <a href="https://blog.kickview.com/building-a-digits-dev-machine-on-ubuntu-16-04/" rel="nofollow">https://blog.kickview.com/building-a-digits-dev-machine-on-ubuntu-16-04/</a><br>
but without the python env</p>
<p dir="auto">git clone <a href="https://github.com/opencv/opencv.git">https://github.com/opencv/opencv.git</a><br>
git clone <a href="https://github.com/opencv/opencv_contrib.git">https://github.com/opencv/opencv_contrib.git</a><br>
cd opencv &amp;&amp; mkdir build &amp;&amp; cd build<br>
--install dependencies</p>
<p dir="auto">cmake<br>
-D CMAKE_BUILD_TYPE=RELEASE<br>
-D CMAKE_INSTALL_PREFIX=/usr/local<br>
-D WITH_CUDA=ON<br>
-D CUDA_ARCH_BIN="5.2"<br>
-D CUDA_ARCH_PTX="5.2"<br>
-D CUDA_GENERATION=Kepler<br>
-D ENABLE_FAST_MATH=1<br>
-D CUDA_FAST_MATH=1<br>
-D WITH_CUBLAS=1<br>
-D INSTALL_PYTHON_EXAMPLES=ON<br>
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules<br>
-D BUILD_EXAMPLES=ON ..</p>
<p dir="auto">also added in the <code class="notranslate">-D_FORCE_INLINES</code> in <code class="notranslate">opencv/cmake/OpencvDetectCuda.cmake</code></p>
<h5 dir="auto">System information (version)</h5>

<ul dir="auto">
<li>OpenCV =&gt; recent 3.4 branch</li>
<li>Operating System / Platform =&gt; Win10 64bit</li>
<li>Compiler =&gt; Visual Studio 2015</li>
<li>CUDA =&gt; 10.0</li>
<li>GPU =&gt; GTX 1060</li>
</ul>
<p dir="auto">related <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="254396313" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/9529" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/9529/hovercard" href="https://github.com/opencv/opencv/issues/9529">#9529</a><br>
relaetd <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="124635309" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/5915" data-hovercard-type="issue" data-hovercard-url="/opencv/opencv/issues/5915/hovercard" href="https://github.com/opencv/opencv/issues/5915">#5915</a></p>
<h5 dir="auto">Detailed description</h5>
<p dir="auto">I confirmed some sporadic test failures in "PyrLKOpticalFlow.Mat"<br>
I looked in the kernel, and realized there is a race condition.  Synchronization was inside the <code class="notranslate">#if</code> so in some condition, race happens.<br>
</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/opencv/opencv/blob/0101fa789cde6c03bc58288a56e1d6ce7175cd48/modules/video/src/opencl/pyrlk.cl#L198-L210">opencv/modules/video/src/opencl/pyrlk.cl</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 198 to 210
      in
      <a data-pjax="true" class="commit-tease-sha" href="/opencv/opencv/commit/0101fa789cde6c03bc58288a56e1d6ce7175cd48">0101fa7</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L198" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="198"></td>
          <td id="LC198" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">if</span> (<span class="pl-s1">tid</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">32</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L199" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="199"></td>
          <td id="LC199" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L200" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="200"></td>
          <td id="LC200" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         <span class="pl-s1">smem1</span>[<span class="pl-s1">tid</span>] <span class="pl-c1">+=</span> <span class="pl-s1">smem1</span>[<span class="pl-s1">tid</span> <span class="pl-c1">+</span> <span class="pl-c1">32</span>]; </td>
        </tr>

        <tr class="border-0">
          <td id="L201" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="201"></td>
          <td id="LC201" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">#if</span> <span class="pl-c1">WAVE_SIZE</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">32</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L202" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="202"></td>
          <td id="LC202" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L203" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="203"></td>
          <td id="LC203" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-en">barrier</span>(<span class="pl-c1">CLK_LOCAL_MEM_FENCE</span>); </td>
        </tr>

        <tr class="border-0">
          <td id="L204" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="204"></td>
          <td id="LC204" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-k">if</span> (<span class="pl-s1">tid</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">16</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L205" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="205"></td>
          <td id="LC205" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     { </td>
        </tr>

        <tr class="border-0">
          <td id="L206" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="206"></td>
          <td id="LC206" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">#endif</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L207" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="207"></td>
          <td id="LC207" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">         smem1[tid] += smem1[tid + 16]; </td>
        </tr>

        <tr class="border-0">
          <td id="L208" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="208"></td>
          <td id="LC208" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">#if</span> <span class="pl-c1">WAVE_SIZE</span> <span class="pl-c1">&lt;</span><span class="pl-c1">16</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L209" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="209"></td>
          <td id="LC209" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     } </td>
        </tr>

        <tr class="border-0">
          <td id="L210" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="210"></td>
          <td id="LC210" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">     <span class="pl-en">barrier</span>(<span class="pl-c1">CLK_LOCAL_MEM_FENCE</span>); </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">Now, I faced similar situation in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="318348315" data-permission-text="Title is private" data-url="https://github.com/opencv/opencv/issues/11409" data-hovercard-type="pull_request" data-hovercard-url="/opencv/opencv/pull/11409/hovercard" href="https://github.com/opencv/opencv/pull/11409">#11409</a><br>
I'm not sure where this <code class="notranslate">WAVE_SIZE</code> came from, but I removed it and modified the reduction part in more simple way.</p>
<p dir="auto">And during the investigation, I think there is also something wrong during the upload.<br>
Let me send my patch later.</p>
<h5 dir="auto">Steps to reproduce</h5>
<p dir="auto">Run <code class="notranslate">opencv_test_video</code> on above configuration</p>