cudaStreamAddCallback cause deadlock

I use cuda kernels and nvenc int the same thread. In callback function, I just check the “cudaError_t status”. A deadlock always occurs after encoding few frames. If I do not use cudaStreamAddCallback, everything goes ok. Any help ? Thanks a lot!

You might want to note what the documentation says:

[url]http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#stream-callbacks[/url]

“A callback must not make CUDA API calls (directly or indirectly), as it might end up waiting on itself if it makes such a call leading to a deadlock.”

I have no idea if that applies to your case or not, since you’ve indicated almost nothing about what your callback is doing.

In callback function, I just check the “cudaError_t status”, that is " if (status != cudaSuccess){
printf(“ConvertCallback fail\n”);}";