title: Reset Cuda Context after exception
body: <p>I have a working app which uses Cuda / C++, but sometimes, because of memory leaks,  throws exception. I need to be able to reset the GPU on live, my app is a server so it has to stay available.</p>
  
  <p>I tried something like this, but it doesnt seems to work:</p>
  
  <pre><code>try
  {
      // do process using GPU
  }
  catch (std::exception &amp;e)
  {
      // catching exception from cuda only
  
      cudaSetDevice(0);
      CUDA_RETURN_(cudaDeviceReset());
  }
  </code></pre>
  
  <p>My idea is to reset the device each times I get an exception from the GPU, but I cannot manage to make it working. :(
  Btw, for some reasons, I cannot fix every problems of my Cuda code, I need a temporary solution. Thanks !</p>