NVIDIA graphics not working with Matlab R2017a and Ubuntu 14.04

I have the following:

  • Matlab R2017a
  • Ubuntu 14.04
  • NVIDIA graphics card: Quadro K2000M
  • Dell Precision M4700
  • Most likely turned off Optimus from BIOS
  • Problem: When I launch Matlab I get the following nasty message:
    I do not know if it is leading to bad rendering of my graphics in Matlab. I do not know what is working wrong either, apart from this message.

    com.jogamp.opengl.GLException: X11GLXDrawableFactory - Could not
    initialize shared resources for X11GraphicsDevice[type .x11,
    connection :0, unitID 0, handle 0x0, owner false,
    ResourceToolkitLock[obj 0x317fa8ef, isOwner false, <342bfc4c,
    33c0fc56>[count 0, qsz 0, owner ]]] at
    jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:326)
    at
    jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:297)
    at java.lang.Thread.run(Unknown Source) Caused by:
    com.jogamp.opengl.GLException: glXGetConfig(0x1) failed: error code
    Unknown error code 6 at
    jogamp.opengl.x11.glx.X11GLXGraphicsConfiguration.glXGetConfig(X11GLXGraphicsConfiguration.java:570)
    at
    jogamp.opengl.x11.glx.X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(X11GLXGraphicsConfiguration.java:500)
    at
    jogamp.opengl.x11.glx.X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationXVisual(X11GLXGraphicsConfigurationFactory.java:434)
    at
    jogamp.opengl.x11.glx.X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(X11GLXGraphicsConfigurationFactory.java:240)
    at
    jogamp.opengl.x11.glx.X11GLXDrawableFactory.createMutableSurfaceImpl(X11GLXDrawableFactory.java:524)
    at
    jogamp.opengl.x11.glx.X11GLXDrawableFactory.createDummySurfaceImpl(X11GLXDrawableFactory.java:535)
    at
    jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:283)
    … 2 more

    If I try to plot something. I get this error:

    MATLAB has experienced a low-level graphics error, and may not have
    drawn correctly. Read about what you can do to prevent this issue at
    Resolving Low-Level Graphics Issues then restart MATLAB. To share
    details of this issue with MathWorks technical support, please include
    this file with your service request.

    “this file” contains the following:

    com.jogamp.opengl.GLException: Profile GL_DEFAULT is not available on
    X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0,
    owner false, ResourceToolkitLock[obj 0x317fa8ef, isOwner false,
    <342bfc4c, 33c0fc56>[count 0, qsz 0, owner ]]], but: at
    com.jogamp.opengl.GLProfile.get(GLProfile.java:990) at
    com.jogamp.opengl.GLProfile.getDefault(GLProfile.java:721) at
    com.jogamp.opengl.GLCapabilities.(GLCapabilities.java:84) at
    com.mathworks.hg.peer.JavaSceneServerPeer.getCaps(JavaSceneServerPeer.java:214)
    at
    com.mathworks.hg.peer.JavaSceneServerPeer.doCreateCanvas(JavaSceneServerPeer.java:925)
    at
    com.mathworks.hg.peer.JavaSceneServerPeer.access$500(JavaSceneServerPeer.java:54)
    at
    com.mathworks.hg.peer.JavaSceneServerPeer$2.run(JavaSceneServerPeer.java:890)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source) at
    java.awt.EventQueue.dispatchEventImpl(Unknown Source) at
    java.awt.EventQueue.access$200(Unknown Source) at
    java.awt.EventQueue$3.run(Unknown Source) at
    java.awt.EventQueue$3.run(Unknown Source) at
    java.security.AccessController.doPrivileged(Native Method) at
    java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
    Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at
    java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
    Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at
    java.awt.EventDispatchThread.run(Unknown Source)

    Other symptoms:

    1. Crashes Matlab upon start at times and I have to do a process kill
    2. The plots look okay as far as I can see - tried the example plots of surf and mesh

    Other data:

    1. The content in the file: /usr/share/applications/matlab.desktop is
    #!/usr/bin/env xdg-open
            [Desktop Entry]
            Type=Application
            Icon=/usr/share/icons/matlab.png
            Name=MATLAB R2017a
            Comment=Start MATLAB - The Language of Technical Computing
            Exec=matlab -desktop
            Categories=Development;
            Comment=Scientific computing environment
            StartupNotify=true
            StartupWMClass=com-mathworks-util-PostVMInit
            Terminal=false
    
    1. The suggested NVIDIA driver on the webpage was:
    Version:375.66
    Date:2017.5.4 
    System:Linux 64-bit
    
    1. Running
    opengl info
    

    on Matlab prompt gives the following output:

    MATLAB has experienced a low-level graphics error, and may not have drawn correctly.Read about what you can do to prevent this issue at Resolving Low-Level Graphics Issues then restart MATLAB.To share details of this issue with MathWorks technical support,please include this file with your service request.

    Version: ''
                                       Vendor: ''
                                     Renderer: 'None'
                        RendererDriverVersion: ''
                    RendererDriverReleaseDate: ''
                               MaxTextureSize: 0
                                       Visual: ''
                                     Software: 1
                         HardwareSupportLevel: 'none'
                    SupportsGraphicsSmoothing: 0
                SupportsDepthPeelTransparency: 0
                   SupportsAlignVertexCenters: 0
                                   Extensions: {}
                           MaxFrameBufferSize: 0
    
    lspci | grep 'VGA'
    

    gives me the following output:

    01:00.0 VGA compatible controller: NVIDIA Corporation GK107GLM [Quadro K2000M] (rev a1)
    
    1. I have already checked the discussion thread and many other similar ones. None have helped yet:
      [1]: drivers - MATLAB com.jogamp.opengl.GLException: X11GLXDrawableFactory error - Ask Ubuntu
      [2]: 361.28 crashes Matlab R2016a - Linux - NVIDIA Developer Forums

    If you have a support agreement with MathWorks, you should be able to get technical support, I believe even for university/employer site licenses. Otherwise, try this:

    Also check post #23 and #28 of your second link if you haven’t already.