title: Strange error while using cudaMemcpy: cudaErrorLaunchFailure
body: <p>I have a CUDA code which works like below:</p>
  
  <pre><code>cpyDataGPU --&gt; CPU     
  
  while(nsteps){
  
      cudaKernel1&lt;&lt;&lt;,&gt;&gt;&gt;
      function1();    
      cudaKernel2&lt;&lt;&lt;,&gt;&gt;&gt;
  
  }
  
  cpyDataGPU --&gt; CPU
  </code></pre>
  
  <hr>
  
  <p>And function1 is like that:</p>
  
  <pre><code>function1{
  
      cudaKernel3&lt;&lt;&lt;,&gt;&gt;&gt;
      cudaKernel4&lt;&lt;&lt;,&gt;&gt;&gt;
  
      cpyNewNeedDataCPU --&gt; GPU   // Error line
      cudaKernel5&lt;&lt;&lt;,&gt;&gt;&gt;
  }
  </code></pre>
  
  <p>According to <a href="http://www.clear.rice.edu/comp422/resources/cuda/html/group__CUDART__MEMORY_g48efa06b81cc031b2aa6fdc2e9930741.html" rel="noreferrer">cudaMemcpy documentation</a>, this function, can produce 4 differents error codes: "cudaSuccess", "cudaErrorInvalidValue", "cudaErrorInvalidDevicePointer" and "cudaErrorInvalidMemcpyDirection".</p>
  
  <p>However, I get the following error: "cudaErrorLaunchFailure": "An exception occurred on the device while executing a kernel. Common causes include dereferencing an invalid device pointer and accessing out of bounds shared memory. The device cannot be used untilcudaThreadExit() is called. All existing device memory allocations are invalid and must be reconstructed if the program is to continue using CUDA."</p>
  
  <p>Does anybody have any idea about why am I getting this error¿?
  What am I doing wrong¿?</p>
  
  <p>Does it make sense, to copy data CPU-->GPU after previous kernel callings ¿? The problem is that, I have to copy that data here at each step because it may change in each "while" step.</p>
  
  <p>Thaks a lot in advance!!</p>