# cuGraphicsGLRegisterImage operating system error

**URL:** <https://forums.developer.nvidia.com/t/cugraphicsglregisterimage-operating-system-error/61640>\
**Category:** CUDA Programming and Performance\
**Created:** [May 24, 2018, 2:08pm UTC](https://forums.developer.nvidia.com/t/cugraphicsglregisterimage-operating-system-error/61640 "2018-05-24T14:08:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian.mcelhenny](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ian.mcelhenny](https://forums.developer.nvidia.com/u/ian.mcelhenny)\
**Post date:** [May 24, 2018, 2:08pm UTC](https://forums.developer.nvidia.com/t/cugraphicsglregisterimage-operating-system-error/61640/1 "2018-05-24T14:08:43Z")

</div>

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](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:

```auto
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/](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.

---

<div class="post-metadata">

**Author:** ![ian.mcelhenny](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ian.mcelhenny](https://forums.developer.nvidia.com/u/ian.mcelhenny)\
**Post date:** [May 25, 2018, 5:47pm UTC](https://forums.developer.nvidia.com/t/cugraphicsglregisterimage-operating-system-error/61640/2 "2018-05-25T17:47:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![foroot\_08](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@foroot\_08](https://forums.developer.nvidia.com/u/foroot_08)\
**Post date:** [August 27, 2020, 3:34am UTC](https://forums.developer.nvidia.com/t/cugraphicsglregisterimage-operating-system-error/61640/3 "2020-08-27T03:34:49Z")

</div>

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
