cuGraphicsMapResource failure

I am trying to map an OpenGL buffer to a CUDA device pointer to display the output of a kernel.

I am registering the OpenGL buffer using

cuGraphicsGLRegisterBuffer()

and then I am mapping the graphics resource obtained with this call using:

cuGraphicsMapResources().

I have checked that the handle has been initialised by the GLRegisterBuffer() call and that no error has been reported. Nonetheless, when I call GraphicsMapResource(), I get an error code:

CUDA_ERROR_INVALID_HANDLE

According to the CUDA library (Driver API) this is returned if there are duplicate entries in the resource. As far as I am aware, there is only one resource, the GL buffer that has been registered (and whose CUDA buffer has been retrieved).

I have 2 questions:

  1. Is my assumption incorrect, that there is only one resource (having only made one call to GLRegisterBuffer() to map the GL buffer)?

  2. What else could generate the error? (I have checked that the handle has not been altered between the 2 function calls)

Thanks,