Ubuntu – Discrete graphics always DynOff

atihybrid-graphicsradeonvgaswitcheroo

I'm using the default open source driver and when I run

  # cat /sys/kernel/debug/vgaswitcheroo/switch

I always have my discrete AMD adapter as DynOff. I tried

  echo ON > /sys/kernel/debug/vgaswitcheroo/switch

But nothing happens. What should I do?

Best Answer

On my Ubuntu 18.04, I solved it this way. There is no need to edit /etc/default/grub file.

  1. Check that the integrated GPU is used by default by running glxheads

    $ glxheads                                                              
       ...                                                                     
       GL_VERSION:  3.0 Mesa 18.0.5                                            
       GL_VENDOR:   Intel Open Source Technology Center                        
       GL_RENDERER: Mesa DRI Intel(R) Sandybridge Mobile
    
  2. Check that the discrete GPU is visible but DynOff

    $ sudo cat /sys/kernel/debug/vgaswitcheroo/switch                       
      0:DIS: :DynOff:0000:01:00.0                                             
      1:IGD:+:Pwr:0000:00:02.0     
    
  3. Enable the discrete GPU for the glxheads and run it again. You can see that the renderer has changed.

    $ DRI_PRIME=1 glxheads                                                  
      GL_VERSION:  3.0 Mesa 18.0.5                                            
      GL_VENDOR:   X.Org                                                      
      GL_RENDERER: AMD TURKS (DRM 2.50.0 / 4.15.0-32-generic, LLVM 6.0.0)
    
  4. Additionally, while running DRI_PRIME=1 glxheads, in the different window check that now the discrete GPU is DynPwr instead of DynOff

    $ sudo cat /sys/kernel/debug/vgaswitcheroo/switch                         
      0:DIS: :DynPwr:0000:01:00.0                                             
      1:IGD:+:Pwr:0000:00:02.0
    
  5. So you need to run each application with DRI_PRIME=1 in order to use discrete GPU. Also, you can set this environmental variable permanently https://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables

Related Question