I am running two host threads that both use the same texture that is shared between their referenced OpenGL-contexts. I thought that each of these threads has to run cudaGLSetGLDevice at the very first step to:
- bind device to current thread
- bind device to currently made OpenGL-context
Note that thread 1 is still working when thread 2 calls cudaGLSetGLDevice. That would include that neither cudaDeviceReset has been called from thread 1 nor its OpenGL-context has been set to be done afterwards.
What I get as error-output is:
“cannot set while device is active in this process”
What can I do or what am I doing wrong?
My system consists of one NVIDIA GTX 550Ti and I’m using boost::thread.
The solution is to switch from runtime- to driver-api that does NOT hide context-management. Then we can create a CUDA-context for each host-thread and everything is fine, even with OpenGL-interoperability 🙂