cuGraphicsGLRegisterImage operating system error

Hello,

I am getting the cudaOperatingSystemError 63 304 when I try to call cuGraphicsGLRegisterImage.
I have a program that works using a test setup where the code in question is in the same thread as the OGL stuff. I then have another program (the one that fails) which is the target project, that runs the code in question on a different thread from the OGL stuff.

I have only one graphics card, and the OGL part of the program (the bad version) is using that same graphics card (GTX1080).

My cuda version is 9.1 and my GTX driver is 397.64.

Do I need to somehow pass in a OGL context or something into the thread where this call is called?

P.S. I read through https://devtalk.nvidia.com/default/topic/1006671/?comment=5138848, but nothing seemed to work. Based on this post I added cudaGLSetGLDevice(0) to my code, with no change.

Here is my call:

res = cuGraphicsGLRegisterImage(&cuInpTexRes, m_inputTexture, GL_TEXTURE_2D, CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY);

Edit:
I came across this https://devtalk.nvidia.com/default/topic/492442/opengl-interoperability-and-cpu-multithreading/ which says that the call above needs to be on the same thread as the OpenGL calls so the context is the same. However, even when I do this I get the OS error.

SOLVED

I have resolved this by putting the calls in the same thread as the OGL context.

I tried to move the context to the thread calling the cuda interop calls, and this caused some OpenGL errors. So the fix was break up my code a bit more, then do the cuda/gl interop in the OGL thread, followed by the strictly cuda stuff in its own thread.

hello folk, I have the same problem here, could you show your code please, I cannot solve this problem, any help will be highly appreciated, thanks alot