# Proprietary Nvidia Optimus. How to switch between GPUs?

## g-virus

Hello everybody! I'm sorry if I've created duplicated theme, but I'm not found an answer needed me.

I have a laptop with Intel GPU and Nvidia GT635M. When I had Debian installed I used bumblebee to switch between GPUs and I worked fine, but now I have installed and tuned the Nvidia's proprietary solution. I've put xrandr commands and etc. as it said Gentoo Wiki and only Nvidia GPU is working now. Can I switch between GPUs in this case and how?

my xorg.conf

```

Section "InputDevice"

    # generated from data in "/etc/conf.d/gpm"

    Identifier     "Mouse0"

    Driver         "mouse"

    Option         "Protocol"

    Option         "Device" "/dev/input/mice"

    Option         "Emulate3Buttons" "no"

    Option         "ZAxisMapping" "4 5"

EndSection

Section "InputDevice"

    # generated from default

    Identifier     "Keyboard0"

    Driver         "kbd"

EndSection

Section "ServerLayout"

    Identifier "layout"

    Screen 0 "nvidia"

    Inactive "intel"

EndSection

Section "Device"

    Identifier "nvidia"

    Driver "nvidia"

    BusID "PCI:1:0:0"

EndSection

Section "Screen"

    Identifier "nvidia"

    Device "nvidia"

    # Uncomment this line if your computer has no display devices connected to

    # the NVIDIA GPU.  Leave it commented if you have display devices

    # connected to the NVIDIA GPU that you would like to use.

    #Option "UseDisplayDevice" "none"

EndSection

Section "Device"

    Identifier "intel"

    Driver "modesetting"

    BusID "PCI:0:2:0"

EndSection 

Section "Screen"

    Identifier "intel"

    Device "intel"

EndSection

Section "Module"

    Load "dbe"

EndSection

```

Thank you!

----------

## Fitzcarraldo

This is how I did it on my Clevo W230SS laptop with Optimus hardware:

Switching between Intel and NVIDIA graphics processors on a laptop with NVIDIA Optimus hardware running Gentoo Linux

My slightly-updated files since above-mentioned 2015 blog post:

intel.sh

```
#!/bin/bash

echo

echo "Your installation is currently configured to use the following graphics processor:"

echo

GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`

if [ "$GPU" = "xorg-x11" ]; then

  echo "Intel HD 4600 Integrated Graphics Processor"

  echo

  echo "You do not need to do anything. Please close this window."

elif [ "$GPU" = "nvidia" ]; then

  echo "NVIDIA GeForce GTX 860M"

  echo

  echo "This script will configure your installation to use the"

  echo "Intel HD 4600 Integrated Graphics Controller all the time."

  echo

  echo "Enter your own password."

  echo

  sudo eselect opengl set xorg-x11

#  sudo cp /home/fitzcarraldo/Xsetup.intel /usr/share/config/kdm/Xsetup # KDE no longer uses KDM

  sudo cp /home/fitzcarraldo/xorg.conf.intel /etc/X11/xorg.conf

  echo

  echo "Now you should logout to restart X Windows."

fi

echo

echo -n "Press ENTER to end: "

read ACKNOWLEDGE
```

nvidia.sh

```
#!/bin/bash

echo

echo "Your installation is currently configured to use the following graphics processor:"

echo

GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`

if [ "$GPU" = "nvidia" ]; then

  echo "NVIDIA GeForce GTX 860M"

  echo

  echo "You do not need to do anything. Please close this window."

elif [ "$GPU" = "xorg-x11" ]; then

  echo "Intel HD 4600 Integrated Graphics Processor"

  echo

  echo "This script will configure your installation to use the NVIDIA GeForce GTX 860M GPU all the time."

  echo

  echo "Enter your own password."

  echo

  sudo eselect opengl set nvidia

#  sudo cp /home/fitzcarraldo/Xsetup.nvidia /usr/share/config/kdm/Xsetup # KDE no longer uses KDM

  sudo cp /home/fitzcarraldo/xorg.conf.nvidia /etc/X11/xorg.conf

  echo

  echo "Now you should logout to restart X Windows."

fi

echo

echo -n "Press ENTER to end: "

read ACKNOWLEDGE
```

Xsetup.intel

```
#! /bin/sh

# Xsetup - run as root before the login dialog appears

#xconsole -geometry 480x130-0-0 -notify -verbose -fn fixed -exitOnFail -file /dev/xconsole &
```

Xsetup.nvidia

```
#! /bin/sh

# Xsetup - run as root before the login dialog appears

#xconsole -geometry 480x130-0-0 -notify -verbose -fn fixed -exitOnFail -file /dev/xconsole &

xrandr --setprovideroutputsource modesetting NVIDIA-0

xrandr --auto
```

xorg.conf.intel

```
Section "Device" 

   Identifier  "Intel Graphics" 

   Driver      "intel" 

   Option      "AccelMethod" "sna" 

   Option      "TearFree" "true" 

EndSection
```

xorg.conf.nvidia

```
Section "ServerLayout"

    Identifier     "Layout0"

    Screen      1  "nvidia" 0 0

    Inactive       "intel"

EndSection

#Section "Files"

#EndSection

Section "Monitor"

    Identifier     "Monitor0"

    Option         "DPMS"

    Option         "DPI" "96 x 96"

EndSection

Section "Device"

    Identifier     "nvidia"

    Driver         "nvidia"

    BusID          "PCI:1:0:0"

EndSection

Section "Device"

    Identifier     "intel"

    Driver         "modesetting"

    BusID          "PCI:0:2:0"

EndSection

Section "Screen"

    Identifier     "nvidia"

    Device         "nvidia"

    Monitor        "Monitor0"

    DefaultDepth    24

    Option         "UseDisplayDevice" "none"

    SubSection     "Display"

        Depth       24

#        Modes      "nvidia-auto-select"

        Virtual     1920 1080

    EndSubSection

EndSection

Section "Screen"

    Identifier     "intel"

    Device         "intel"

    Monitor        "Monitor0"

EndSection
```

Select Intel HD Graphics.desktop

```
[Desktop Entry]

Comment[en_GB]=Run a script to configure your installation to use Intel Integrated Graphics when you restart X Windows

Comment=Run a script to configure your installation to use Intel Integrated Graphics when you restart X Windows

Exec=konsole -e sh /home/fitzcarraldo/intel.sh

GenericName[en_GB]=Configure your installation to use Intel HD Graphics

GenericName=Configure your installation to use Intel HD Graphics

Icon=/home/fitzcarraldo/Pictures/Icons/intel-hd-icon.png

MimeType=

Name[en_GB]=Intel HD Graphics

Name=Intel HD Graphics

Path=

StartupNotify=true

Terminal=false

TerminalOptions=\s--noclose

Type=Application

X-DBUS-ServiceName=

X-DBUS-StartupType=none

X-KDE-SubstituteUID=false

X-KDE-Username=fitzcarraldo
```

Select NVIDIA GPU.desktop

```
[Desktop Entry]

Comment[en_GB]=Run a script to configure your installation to use the NVIDIA GeForce GTX 860M GPU when you restart X Windows

Comment=Run a script to configure your installation to use the NVIDIA GeForce GTX 860M GPU when you restart X Windows

Exec=konsole -e sh /home/fitzcarraldo/nvidia.sh

GenericName[en_GB]=Configure your installation to use the NVIDIA GeForce GTX 860M GPU

GenericName=Configure your installation to use the NVIDIA GeForce GTX 860M GPU

Icon=/home/fitzcarraldo/Pictures/Icons/nvidia_icon.png

MimeType=

Name[en_GB]=NVIDIA GPU

Name=NVIDIA GPU

Path=

StartupNotify=true

Terminal=false

TerminalOptions=\s--noclose

Type=Application

X-DBUS-ServiceName=

X-DBUS-StartupType=none

X-KDE-SubstituteUID=false

X-KDE-Username=fitzcarraldo
```

You also need to configure the Desktop Manager to work with Optimus hardware. If you use KDE, I couldn't get SDDM to work with the Optimus hardware despite following the Gentoo Wiki to the letter, so I switched to LightDM which works fine both with the NVIDIA GPU and the Intel HD Graphics providing it is configured as explained in my Gentoo Forums post: https://forums.gentoo.org/viewtopic-p-8114392.html#8114392

----------

## g-virus

 *Quote:*   

> If you use KDE, I couldn't get SDDM to work with the Optimus

 

Oh, that is sadly because I'm using SDDM as desktop manager  :Sad:  Why did you have problems with this DM? How it depends on?

----------

## Fitzcarraldo

 *g-virus wrote:*   

> Why did you have problems with this DM? How it depends on?

 

No idea I'm afraid, but it seems others have trouble with SDDM too (see e.g. https://bugs.gentoo.org/show_bug.cgi?id=584960). I gave up messing around trying to get SDDM to work on my Optimus-based laptop, and I switched to LightDM which works fine on that laptop. I find LightDM more sophisticated than SDDM in any case (I'm using SDDM successfully on another laptop that also runs Plasma 5 but which has a Mobility Radeon GPU).

----------

## g-virus

Fitzcarraldo, ok, thank you, I will try to use your configs and post results here

----------

## NTwoO

Shouldn't this be in the wiki? I'm looking into switching mechanisms and this looks fine for most laptop users (since laptops with Gentoo are often single user machines).

----------

