Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem with QOpenGLWidget and CUDA interoperabilitly
Forum Update on Monday, May 27th 2025

Problem with QOpenGLWidget and CUDA interoperabilitly

Scheduled Pinned Locked Moved Mobile and Embedded
openglqopenglwidgetcuda
4 Posts 2 Posters 2.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mandre
    wrote on last edited by
    #1

    Hi All.

    I am trying to implement OpenGL/CUDA interoperability on a Jetson TK1 (R21.3) with QOpenGLWidget and Qt 5.4.1. I use the same approach as described in
    https://blog.qt.io/blog/2015/03/03/qt-weekly-28-qt-and-cuda-on-the-jetson-tk1/

    By the way, according to the lastest CUDA programming guide the call to cudaGLSetGLDevice() is not needed anymore. But the problem exists either way. Interestingly when using cudaGLSetGLDevice(), also any subsequent cudaMalloc fails with segfault.

    In the meantime for testing I have stripped down my initializeGL() to minimal code:

    initializeOpenGLFunctions();
    
    cudaError_t err;
    err = cudaSetDevice(0);
    if ( err != cudaSuccess ) {
        QMessageBox::critical(NULL, "Error", "cudaSetDevice failed");
    }
    
    glGenBuffers(1, &m_pbo);
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_pbo);
    glBufferData(GL_PIXEL_UNPACK_BUFFER, 768 * 768 * sizeof(GLubyte) * 4, NULL, GL_DYNAMIC_COPY);
    glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
    
    err = cudaGraphicsGLRegisterBuffer(&_pcudagl_pbo_resource, m_pbo, cudaGraphicsMapFlagsNone);
    
    QMessageBox::critical(NULL, "Error", "Here");
    

    I have the following member variables in the class:

    GLuint  m_pbo;
    cudaGraphicsResource_t _pcudagl_pbo_resource = NULL;
    

    The function cudaGraphicsGLRegisterBuffer() crashes with a segmentation fault. m_pbo gets set to 1 by glGenBuffers();

    Does anybody have an idea what causes this issue? Any tips to solve it?

    M 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      That might be a driver issue. In any case, I'd recommend posting that question on the interest mailing list You'll find there Qt's developers/maintainers (this forum is more user oriented)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M mandre

        Hi All.

        I am trying to implement OpenGL/CUDA interoperability on a Jetson TK1 (R21.3) with QOpenGLWidget and Qt 5.4.1. I use the same approach as described in
        https://blog.qt.io/blog/2015/03/03/qt-weekly-28-qt-and-cuda-on-the-jetson-tk1/

        By the way, according to the lastest CUDA programming guide the call to cudaGLSetGLDevice() is not needed anymore. But the problem exists either way. Interestingly when using cudaGLSetGLDevice(), also any subsequent cudaMalloc fails with segfault.

        In the meantime for testing I have stripped down my initializeGL() to minimal code:

        initializeOpenGLFunctions();
        
        cudaError_t err;
        err = cudaSetDevice(0);
        if ( err != cudaSuccess ) {
            QMessageBox::critical(NULL, "Error", "cudaSetDevice failed");
        }
        
        glGenBuffers(1, &m_pbo);
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_pbo);
        glBufferData(GL_PIXEL_UNPACK_BUFFER, 768 * 768 * sizeof(GLubyte) * 4, NULL, GL_DYNAMIC_COPY);
        glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
        
        err = cudaGraphicsGLRegisterBuffer(&_pcudagl_pbo_resource, m_pbo, cudaGraphicsMapFlagsNone);
        
        QMessageBox::critical(NULL, "Error", "Here");
        

        I have the following member variables in the class:

        GLuint  m_pbo;
        cudaGraphicsResource_t _pcudagl_pbo_resource = NULL;
        

        The function cudaGraphicsGLRegisterBuffer() crashes with a segmentation fault. m_pbo gets set to 1 by glGenBuffers();

        Does anybody have an idea what causes this issue? Any tips to solve it?

        M Offline
        M Offline
        mandre
        wrote on last edited by
        #3

        I've solved it. It was a driver issue.

        The issue was related to the wrong libEGL.so being used. In fact mesa-egl overwrites the tegra-egl in /usr/lib/arm-linux-gnueabihf in the L4T system.

        See also: https://devtalk.nvidia.com/default/topic/810657/?comment=4460041

        Replacing the link back to tegra-egl version fixed it.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Good !

          Thanks for sharing the solution

          Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved