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. How to get the amount of total and available GPU(Cuda) memory?(QOpenGLFunctions)
Forum Updated to NodeBB v4.3 + New Features

How to get the amount of total and available GPU(Cuda) memory?(QOpenGLFunctions)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
18 Posts 2 Posters 5.7k Views 1 Watching
  • 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.
  • ? A Former User

    Huh? The function returns void, not 0: void glGetIntegerv(GLenum pname, GLint * data). The results you asked for are stored in total_mem_kb and cur_avail_mem_kb.

    mandruk1331M Offline
    mandruk1331M Offline
    mandruk1331
    wrote on last edited by mandruk1331
    #8

    @Wieland Yes I know. I meant that this two variables are not being init in the function.

        QOpenGLContext context;
       context.create();
    
       QOffscreenSurface surface;
       surface.create();
    
       QOpenGLFunctions func;
       context.makeCurrent(&surface);
       func.initializeOpenGLFunctions();
    
       qDebug()<<func.glGetString(GL_RENDER);
    

    qDebug prints 0x0 smth, is for sure wrong

    Mandruk1331

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #9

      Hmm.. worked for me. Tested on Nvidia GTX 1080, 64 bit desktop Linux, with Nvidia's proprietary drivers. Don't have that machine at hand right now, can't tell for sure which driver version it has.

      mandruk1331M 1 Reply Last reply
      1
      • ? A Former User

        Hmm.. worked for me. Tested on Nvidia GTX 1080, 64 bit desktop Linux, with Nvidia's proprietary drivers. Don't have that machine at hand right now, can't tell for sure which driver version it has.

        mandruk1331M Offline
        mandruk1331M Offline
        mandruk1331
        wrote on last edited by
        #10

        @Wieland Have you tried it on Windows?? ran this code on W7 and W10 different laptops, the result was 0x0

        Mandruk1331

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #11

          Wait, I can check with Windows 7 laptop.

          1 Reply Last reply
          1
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #12

            Okay, the code I posted above works here, too.

            qDebug() << QString::fromLatin1((const char*)func.glGetString(GL_EXTENSIONS)); prints all the extentions,

            qDebug() << QString::fromLatin1((const char*)func.glGetString(GL_RENDER)); prints an empty string.

            mandruk1331M 1 Reply Last reply
            2
            • ? A Former User

              Okay, the code I posted above works here, too.

              qDebug() << QString::fromLatin1((const char*)func.glGetString(GL_EXTENSIONS)); prints all the extentions,

              qDebug() << QString::fromLatin1((const char*)func.glGetString(GL_RENDER)); prints an empty string.

              mandruk1331M Offline
              mandruk1331M Offline
              mandruk1331
              wrote on last edited by mandruk1331
              #13

              @Wieland tried the above code and it gives a list of extensions. But the main thing I need is the available GPU memory.

                QOpenGLContext context;
                context.create();
                QOffscreenSurface surface;
                surface.create();
                QOpenGLFunctions func;
                context.makeCurrent(&surface);
                func.initializeOpenGLFunctions();
                GLint cur_avail_mem_kb = 0;
                func.glGetIntegerv(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX,&cur_avail_mem_kb);
                qDebug()<<cur_avail_mem_kb;
              

              cur_avail_mem_kb - is equals to the number it was initialized, in this case it's zero. What can be the problem? Does this code executes on your computer?

              Mandruk1331

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #14

                Yes, the following prints the correct results:

                GLint total_mem_kb = 0;
                func.glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX,&total_mem_kb);
                qDebug()<<total_mem_kb;
                
                GLint cur_avail_mem_kb = 0;
                func.glGetIntegerv(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX,&cur_avail_mem_kb);
                qDebug()<<cur_avail_mem_kb;
                
                mandruk1331M 1 Reply Last reply
                1
                • ? A Former User

                  Yes, the following prints the correct results:

                  GLint total_mem_kb = 0;
                  func.glGetIntegerv(GL_GPU_MEM_INFO_TOTAL_AVAILABLE_MEM_NVX,&total_mem_kb);
                  qDebug()<<total_mem_kb;
                  
                  GLint cur_avail_mem_kb = 0;
                  func.glGetIntegerv(GL_GPU_MEM_INFO_CURRENT_AVAILABLE_MEM_NVX,&cur_avail_mem_kb);
                  qDebug()<<cur_avail_mem_kb;
                  
                  mandruk1331M Offline
                  mandruk1331M Offline
                  mandruk1331
                  wrote on last edited by
                  #15

                  @Wieland A big thank you for the time you invested in solving the problem. It looks like then smth is wrong on my side, now I'm updating my drivers and after I'll give it a try again.

                  Mandruk1331

                  ? 1 Reply Last reply
                  1
                  • mandruk1331M mandruk1331

                    @Wieland A big thank you for the time you invested in solving the problem. It looks like then smth is wrong on my side, now I'm updating my drivers and after I'll give it a try again.

                    ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #16

                    @mandruk1331 You're welcome. Good luck, hope you can solve it. It's almost always driver-related issues.

                    mandruk1331M 1 Reply Last reply
                    0
                    • ? A Former User

                      @mandruk1331 You're welcome. Good luck, hope you can solve it. It's almost always driver-related issues.

                      mandruk1331M Offline
                      mandruk1331M Offline
                      mandruk1331
                      wrote on last edited by
                      #17

                      @Wieland Ok so I updated everything I could, but that did not solve the problem, but by asking the same question on StackOverflow, I now have a solution. The code above works ok, the main problem was that my main graphic card was Intel, therefore I had to switch the video card setting so that the main video card would be Nvidia, by doing that the problem has been solved.

                      Mandruk1331

                      ? 1 Reply Last reply
                      0
                      • mandruk1331M mandruk1331

                        @Wieland Ok so I updated everything I could, but that did not solve the problem, but by asking the same question on StackOverflow, I now have a solution. The code above works ok, the main problem was that my main graphic card was Intel, therefore I had to switch the video card setting so that the main video card would be Nvidia, by doing that the problem has been solved.

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #18

                        @mandruk1331 Hey, glad you solved it. And thanks for sharing the solution :)

                        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