Skip to content

[BUG]: cudaGraphicsGLRegisterImage returns null handle with cuda-bindings 12.9.3 #1122

Closed

Description

@pijyoi

Is this a duplicate?

Type of Bug

Silent Failure

Component

cuda.bindings

Describe the bug

On cuda-bindings 12.9.3, cudaGraphicsGLRegisterImage reports cudaSuccess but returns a null handle.
This does not happen with cuda-bindings 12.9.2

How to Reproduce

PySide6 is used to create the OpenGL context and texture.

from cuda.bindings import runtime as cudart
from PySide6 import QtGui, QtOpenGL

class GLWidget(QtOpenGL.QOpenGLWindow):
    def initializeGL(self):
        self.m_texture = QtOpenGL.QOpenGLTexture(QtOpenGL.QOpenGLTexture.Target.Target2D)
        self.m_texture.setFormat(QtOpenGL.QOpenGLTexture.TextureFormat.RGBA8_UNorm)
        self.m_texture.setSize(512, 512)
        self.m_texture.allocateStorage()

        err, self.gfx_resource = cudart.cudaGraphicsGLRegisterImage(
            self.m_texture.textureId(), self.m_texture.target().value,
            cudart.cudaGraphicsRegisterFlags.cudaGraphicsRegisterFlagsWriteDiscard
        )
        error_name = cudart.cudaGetErrorName(err)[1].decode()
        print(error_name, self.gfx_resource)

app = QtGui.QGuiApplication([])
win = GLWidget()
win.show()

# 12.9.2: cudaSuccess <cudaGraphicsResource_t 0x1b75dca8e90>
# 12.9.3: cudaSuccess <cudaGraphicsResource_t 0x0>

Expected behavior

cudaGraphicsGLRegisterImage should return a valid handle upon cudaSuccess

Operating System

No response

nvidia-smi output

No response

Activity

  1. leofang commented on Oct 10, 2025

    @leofang
    Member

    Thanks for reporting, @pijyoi!

    @mdboom It seems all graphics APIs were commented out in #914 and not forwarding to cudart, e.g.

    cdef cudaError_t _cudaGraphicsGLRegisterImage(cudaGraphicsResource** resource, cyruntime.GLuint image, cyruntime.GLenum target, unsigned int flags) except ?cudaErrorCallRequiresNewerDriver nogil:
    cdef cudaError_t err = cudaSuccess
    # cudaFree(0) is a NOP operations that initializes the context state
    err = cudaFree(<void*>0)
    if err != cudaSuccess:
    return err
    # err = <cudaError_t>cydriver._cuGraphicsGLRegisterImage(<cydriver.CUgraphicsResource*>resource, image, target, flags)
    return err

    Could you take a look?

  2. added
    P0High priority - Must do!
    cuda.bindingsEverything related to the cuda.bindings module
    on Oct 10, 2025
  3. added a commit that references this issue on Oct 10, 2025
    4e9e67e
  4. pijyoi commented on Oct 11, 2025

    @pijyoi
    Author

    A lighter-weight (wheel-size wise) MWE that may be better for CI.
    PySide6-Essentials weighs in at 75MB whereas pyglet is only 1MB.

    from cuda.bindings import runtime as cudart
    import pyglet
    
    tex = pyglet.image.Texture.create(512, 512)
    
    err, gfx_resource = cudart.cudaGraphicsGLRegisterImage(
        tex.id, tex.target,
        cudart.cudaGraphicsRegisterFlags.cudaGraphicsRegisterFlagsWriteDiscard
    )
    error_name = cudart.cudaGetErrorName(err)[1].decode()
    print(error_name, gfx_resource)
  5. linked a pull request that will close this issueFix #1122: Reinstate graphics APIs #1123on Oct 13, 2025
  6. added a commit that references this issue on Oct 13, 2025
    7b9171d
  7. added a commit that references this issue on Oct 13, 2025
    73da391
  8. added a commit that references this issue on Oct 14, 2025
    82e98e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0High priority - Must do!bugSomething isn't workingcuda.bindingsEverything related to the cuda.bindings module

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions