Cuda, PBO, is it safe? Cuda && PBO problem *sometimes*

First of all hello everybody :-)

background of the problem

Our aim is to display images from data processing at 60Hz using opengl.
We are using textures to store this data and shaders to aplly LUT and others things.
Has the needs comme greater and greater we have moved to CUDA in order to do readable filter results. We have implemented several filters in cuda (convolutions and others). To interact with cuda/opengl we start using PBO to read data from cuda process to opengl texture.
We have two CUDA critical points :

  • one kernel do a compression from 16bits to 8 bits, using a PBO to store 8bits data.
  • the result is stored in a texture directly and displayed in a FBO with parameters
  • FBO is read with glReadPixels in a pbo and that pbo is passed to another little bunch of code that do a multi resolution filter.

now the problem

All that stuff is going well is the resoltion of our data is constant.
On a resolution change pbo, fbo and cuda are deleted and reallocated to the adapted resolution.
At that step everything is ok, but sometimes, for obscure reason one kernel, compression or multi resolution crashes with cudaLaunchError on cudaMapBuffer…
Error is ‘unexpected launch failure’, which is quite obscure.

We try to search for a reproductible sequence that causes crash but we failed to found such a thing. Is pbo/cuda really safe, do we have to switch to cudaMemcpy to get our data from kernels? is there a trick somewhere to make it safer?

Thank you for your incoming responses :-)