Using cudaMalloc pointers in OpenGL CUDA kernel interop

I have a parallel reduction kernel that computes an images min and max. The calling C code cudaMallocs memory space for the min and max reductions and those pointers are used in the CUDA code. If I execute the kernel from the C program, it works fine. If I execute the kernel from a program that is getting a PBO from an OpenGL graphics context, the kernel can not access the cudaMalloc’ed pointers. I get an access violation error. If I modify the kernel to use globally declared device arrays, it works fine. Why can I not access the cudaMalloc’ed memory from the kernel when it is called from within an OpenGL context? I have no problem accessing the PBO.

Thanks.

I believe that the device may be getting reset when the graphics is initialized so my allocations go away. I may go back and try to allocate the memory on the first render pass and see if that works.