cant register textrures with CUDA


I’m working on porting some windows code using CUDA to Linux.
I’m using Ogre on both plaftorms, but DirectX subsystem on Windows and GL on linux.

Texture is created via Ogre, so I would assume it’s created correctly.
I get the textureID and do:

cudaGraphicsGLRegisterImage ( &handle, textureID, GL_TEXTURE_2D, cudaGraphicsRegisterFlagsNone);
but it returns error 33: cudaErrorInvalidResourceHandle.

Any help or direction will be greatly appreciated

Edit: during initialization I do cudaGLSetGLDevice(0) and it returns success.