Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Proprietary Nvidia Optimus. How to switch between GPUs?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
g-virus
n00b
n00b


Joined: 26 Aug 2017
Posts: 50

PostPosted: Tue Sep 05, 2017 8:22 pm    Post subject: Proprietary Nvidia Optimus. How to switch between GPUs? Reply with quote

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

Code:

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!
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Tue Sep 05, 2017 9:51 pm    Post subject: Reply with quote

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
Code:
#!/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
Code:
#!/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
Code:
#! /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
Code:
#! /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
Code:
Section "Device"
   Identifier  "Intel Graphics"
   Driver      "intel"
   Option      "AccelMethod" "sna"
   Option      "TearFree" "true"
EndSection


xorg.conf.nvidia
Code:
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
Code:
[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
Code:
[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
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
g-virus
n00b
n00b


Joined: 26 Aug 2017
Posts: 50

PostPosted: Thu Sep 07, 2017 3:48 pm    Post subject: Reply with quote

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 :( Why did you have problems with this DM? How it depends on?
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Thu Sep 07, 2017 5:45 pm    Post subject: Reply with quote

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).
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
g-virus
n00b
n00b


Joined: 26 Aug 2017
Posts: 50

PostPosted: Mon Sep 11, 2017 12:49 pm    Post subject: Reply with quote

Fitzcarraldo, ok, thank you, I will try to use your configs and post results here
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum