Optimus Manager

optimus-manager

This Linux program provides a solution for GPU switching on Optimus laptops (a.k.a laptops with dual Nvidia/Intel GPUs).

Manjaro is supported: Only Xorg sessions are supported (no Wayland).

Supported display managers are : SDDM, LightDM, GDM. The program may still work with others but you have to configure them manually (see this section).

Regression: GDM support is currently broken (see this issue : https://github.com/Askannz/optimus-manager/issues/4). You can still use optimus-manager but you will have to manually logout and stop the X server before switching GPUs.

The “why”

On Windows, the Optimus technology works by dynamically offloading rendering to the Nvidia GPU when running 3D-intensive applications, while the desktop session itself runs on the Intel GPU.

However, on Linux, the Nvidia driver does not provide such offloading capabilities (yet), which makes it difficult to use the full potential of your machine while keeping a reasonable battery life.

Currently, if you have Linux installed on an Optimus laptop, there are three methods to use your Nvidia GPU :

  • Run your whole X session on the Intel GPU and use Bumblebee to offload rendering to the Nvidia GPU. While this mimic the behavior of Optimus on Windows, this is an unofficial, hacky solution with three major drawbacks : 1. a noticeable performance hit (because Bumblebee has to use your CPU to copy frames over to the display) 2. no support for Vulkan (therefore, it is incompatible with DXVK and any native game using Vulkan, like Shadow of the Tomb Raider for instance) 3. you will be unable to use any video output (like HDMI ports) connected to the Nvidia GPU, unless you have the open-source nouveau driver loaded to this GPU at the same time.

  • Use nvidia-xrun to have the Nvidia GPU run on its own X server in another virtual terminal. You have to keep two X servers running at the same time, which can be detrimental to performance. Also, you do not have acess to your normal desktop environment while in the virtual terminal of the Nvidia GPU, and in my own experience, the nvidia driver is prone to crashing when switching between virtual terminals.

  • Run your whole X session on the Nvidia GPU and disable rendering on the Intel GPU. This allows you to run your applications at full performance, with Vulkan support, and with access to all video outputs. However, since your power-hungry Nvidia GPU is turned on at all times, so it has a massive impact on your battery life.
    This method is often called Nvidia PRIME, although technically PRIME is just the technology that allows your Nvidia GPU to send its frame to the built-in display of your laptop via the Intel GPU.

An acceptable middle ground could be to use the third method on demand : switching the X session to the Nvidia GPU when you need extra rendering power, and then switching it back to Intel when you are done, to save battery life.

Unfortunately the X server configuration is set-up in a permanent manner with configuration files, which makes switching a hassle because you have to rewrite those files every time you want to switch GPUs. You also have to restart the X server for those changes to be taken into account.

This is what this tool does for you : it dynamically writes the X configuration at boot time, rewrites it every time you need to switch GPUs, and also loads the appropriate kernel modules to make sure your GPUs are properly turned on/off.

Note that this is nothing new : Ubuntu has been using that method for years with their prime-select script.

In practice, here is what happens when switching to the Intel GPU (for example) :

  1. Your login manager is automatically stopped, which also stops the X server (warning : this closes all opened applications)
  2. The Nvidia modules are unloaded and nouveau is loaded instead to switch off the card (this can also be done with bbswitch if nouveau does not work)
  3. The configuration for X and your login manager is updated (note that the configuration is saved to dedicated files, this will not overwrite any of your own configuration files)
  4. The login manager is restarted.

We are well-aware this is still a hacky solution and we will happily deprecate this tool the day Nvidia implements proper GPU offloading in their Linux driver.

Installation

pamac install optimus-manager

Once the package is installed, do not forget to enable the daemon so that it is started at boot time :

# systemctl enable optimus-manager.service

IMPORTANT : make sure you do not have any configuration file conflicting with the ones autogenerated by optimus-manager. In particular, remove everything related to displays or GPUs in /etc/X11/xorg.conf, /etc/X11/xorg.conf.d/ and also in /etc/X11/mhwd.d/. Avoid running nvidia-xconfig or using the Save to X Configuration file in the Nvidia control panel. If you need to apply specific options to your Xorg config, see the Configuration section.

If you have bumblebee installed on your system, uninstall it or at least make sure the bumblebeed service is disabled. Finally, make sure the bbswitch module is not loaded at boot time (check /etc/modules-load.d/).

If you want to disable optimus-manager completely, then first disable the SystemD service :

# systemctl stop optimus-manager.service
# systemctl disable optimus-manager.service

Then run optimus-manager --cleanup as root to remove any leftover autogenerated configuration file. Make sure to do this step before uninstalling the program.

Usage

Make sure the SystemD service optimus-manager.service is running, then run

optimus-manager --switch nvidia

to switch to the Nvidia GPU, and

optimus-manager --switch intel

to switch to the Intel GPU.

WARNING : Switching GPUs automatically restarts your display manager, so make sure you save your work and close all your applications before doing so.

You can setup autologin in your display manager so that you do not have to re-enter your password every time.

You can also specify which GPU you want to be used by default when the system boots :

optimus-manager --set-startup MODE

Where MODE can be intel, nvidia, or nvidia_once. The last one is a special mode which makes your system use the Nvidia GPU at boot, but for one boot only. After that it reverts to intel mode. This can be useful to test your Nvidia configuration and make sure you do not end up with an unusable X server.

Configuration

The default configuration file can be found at /usr/share/optimus-manager.conf. Please do not edit this file ; instead, create your own config file at /etc/optimus-manager/optimus-manager.conf.

Any parameter not specified in your config file will take value from the default file.

Please refer to the comments in the default config file for descriptions of the available parameters. In particular, it is possible to set common Xorg options like DRI version or triple buffering, as well as some kernel module loading options.

Those parameters probably do not cover all use cases (yet), but feel free to open an issue if you think something else should be added there.

FAQ / Troubleshooting

General troubleshooting advice : you can view the logs of the optimus-manager daemon by running journalctl -u optimus-manager.service. Also, check systemctl status optimus-manager.service to see if the daemon is properly loaded and running.

The Arch wiki can be a great resource for troubleshooting. Check the following pages : NVIDIA, NVDIA Optimus, Bumblebee (even if optimus-manager does not use Bumblebee, some advices related to power switching can still be applicable)

How can I check which GPU my X session is running on ?

You can run glxinfo | grep "server glx vendor string". If you see SGI, you are running on the Intel GPU. If you see NVIDIA Corporation, you are running on the Nvidia GPU.

When I switch GPUs, my system completely locks up (I cannot even switch to a TTY with Ctrl+Alt+Fx)

It is very likely your laptop is plagued by one of the numerous ACPI issues associated with Optimus laptops on Linux, and caused by manufacturers having their own implementations. The symptoms are often similar : a complete system lockup if you try to run any program that uses the Nvidia GPU while it is powered off. Unfortunately there is no universal fix, but the solution often involves adding a kernel parameter to your boot options. You can find more information on this GitHub issue, where people have been reporting solutions for specific laptop models. Check this Arch Wiki page to learn how to set a kernel parameter at boot.

You can also try changing the power switching backend in the configuration file (section [optimus], parameter switching).

GPU switching works but my system locks up if I am in Intel mode and start any of the following programs : VLC, lspci, anything that polls the PCI devices

This is due to ACPI problems, see the previous question.

I think my Nvidia GPU stays powered on even in Intel mode (my battery drains too fast)

Maybe there is a problem with nouveau not handling power switching properly. Check dmesg for errors related to nouveau or PCI power management. You can also try switching the power switching backend to bbswitch (option switching, Section [optimus])

Nothing happens when I ask to switch GPUs (the display manager does not stop)

By default, the daemon assumes that your display manager service has the name alias display-manager (should be the default on Arch and Manjaro). If it isn’t the case, you have to specify the name manually so that optimus-manager can find it. See the login_manager parameter in the configuration file, in the [optimus] section.

My display manager is not SDDM, LightDM nor SDDM

Set the login_manager parameter in the configuration file to the name of your login manager service. You must also configure it manually so that it executes the script /usr/bin/optimus-manager_Xsetup on startup. The X server may still work without that last step but you will see a black screen on your built-in monitor instead of the login window.

The display manager stops but does not restart (a.k.a I am stuck in TTY mode)

This is generally a problem with the X server not restarting. Refer to the next question.

When I try to switch GPUs, I end up with a black screen (or a black screen with only a blinking cursor)

First, make sure your system is not completely locked up and you can still switch between TTYs with Ctrl+Alt+F1,F2,etc. If you cannot, refer to this question.

If you can, it generally means that the X server failed to restart. In addition to the optimus-manager logs, you can check the Xorg logs at /var/log/Xorg.0.log for more information.

Some fixes you can try :

  • Setting the power switching backend to bbswitch in the configuration file (section [optimus], parameter switching)
  • Setting modeset to no in the [intel] and [nvidia] sections
  • Changing the DRI versions from 3 to 2

If that does not fix your problem and you have to open a GitHub issue, please attach both the Xorg log and the daemon log.

GPU switching works but I cannot run any 3D application in Intel mode (they fail to launch with some error message)

Check if the nvidia module is still loaded in Intel mode. That should not happen, but if it is the case, then logout, stop the display manager manually, unload all Nvidia modules (nvidia, nvidia_modeset,nvidia_drm, in that order) and restart the display manager.

Consider opening a GitHub issue about this, with logs attached.

I do not use a display manager, or I do not want optimus-manager to stop/restart my display manager

You can disable control of the login manager by leaving blank the option login_manager in the section [optimus] of the config file. Please note that you will have to manually stop your X server before switching GPUs, because the rendering kernel modules cannot be unloaded while the server is running.

If you use startx or xinitrc, you also have to add the line /usr/bin/optimus-manager_Xsetup to your .xinitrc so that this script is executed when X starts. This may be necessary to set up PRIME.

When I switch to Nvidia, the built-in screen of the laptop stays black but I can still input my password or use monitors plugged to the video output

It seems that PRIME is not properly configured. Please open a GitHub issue with logs attached, and include as much details about your login manager as you can.

Even after disabling the daemon, it is still doing something to my Xorg or login manager configuration.

Make sure to remove any leftover autogenerated config file by running optimus-manager --cleanup.


Please report any issues with this tool upstream.

22 Likes
Nvidia Prime vs Optimus-manager
Finalizing Manjaro Gnome 18.0 installation - help a Linux newbie pls :)
Options for Nvidia Optimus graphics
Installing nvidia and intel driver problem
HDMI port not recognized on Acer Nitro V
Blackscreen on boot after removing bumblebee from systemctl
[Steam] Recently Civ VI stops to launch
Laptop not booting after installing proprietary drivers
Optimus-manager alternative
Nvidia drivers not working in fresh install
System crashes on reboot or poweroff
How to install nvidia driver for secondary GPU on laptop
System crashes on reboot or poweroff
How to install nvidia driver for secondary GPU on laptop
Issues with gaming on Manjaro i3 with Optimus
No more Login screen and xorg got deleted after uninstalling libinput drivers
Did anyone installed drivers for Nvidia GTX1070?
Optimus laptop issues
Manjaro KDE and Nvidia
Hardware configuration hangs out
Nvidia Drivers with Intel Integrated Graphics - Current Status?
HDMI port not recognized on Acer Nitro V
Manjaro KDE and Nvidia
Poweroff doesn't work after install
Switch from bumblebee to optimus-manager
No possibility to get Nvidia GT 610M working
Manjaro boot stuck at 'started Network Manager script dispatcher service'
Bumblebee fullscreen problem
NVIDIA driver not working properly (+ poor rendering performance in Chrome)
Can't detect HDMI cable for another monitor when using bumblebee
I3 Manjaro - unable to detect secondary monitor
Acer V5 573G Default PrtScSysRq Screenshot Error
GPU drivers: Where is the "video-hybrid-intel-nouveau-prime" in MWHD?
Free or non free for Nvidia GTX960?
After install video-nvidia manjaro can't boot
Unable to detect GPU - Dell XPS 9570
Optirun problem on Manjaro KDE
There is a new amazing solution for Nvidia Optimus that needs to join manjaro ! Optimus-manager
Manjaro KDE works perfectly live but freezes once installed
Manjaro Setting Manager - Hardware Configuration shows no installed display controller
Bumblebee not working with Steam
[Stable Update] 2019-05-26 - Kernels, XFCE 4.14-pre1, Virtualbox, LibreOffice
deepin / openbox / gnome - Lenovo IdeaPad 520-15ikb installation problems
optimus-manager not working
Semi-reproducible weird freezes
Bumblebee is not able to activate NVIDIA GPU
Thinkpad T430s Grafiktreiber
Manjaro's graphics switching features
[Dell XPS 15] Enable Nvidia drivers
How To Install NVIDIA Drivers
Unable to boot after nvidia-prime-select install
Restore nvidia settings
Problemas para Suspender e Hibernar
No gaming for me
Low screen resolution after installing nvidia driver
Upgrade to kernel 5.0 broke display
Nvidia "Prime Profiles" Not Show
Installing video-nvidia using mhwd always leads to Failed to start load kernel modules

That is awesome!

I made popup launcher like prime-select gui :slight_smile:
“optimus-manager --switch intel --no-confirm” and “optimus-manager --switch nvidia --no-confirm” with *.desktop file works perfect for lazy like me :smiley:

And It better than ubuntu’s prime-select script …

5 Likes

Can you post a guide how to do that? Thanks.

https://wiki.manjaro.org/index.php?title=Optimus_Manager here we go :joy:

1 Like

Not that. I mean the graphical switch.

Oh okey. Its just kde plasmoid named mylauncher just create x.desktop file and add to launcher

1 Like

Not good a lot of optimus gamers laptop have difficulties or incompatibilities with bbswitch

After applying the guide session correctly reloads but I’m still on intel mode. To not spam this thread I started a new support topic:

EDIT: I found solution. It was simple… reboot. So the tutorial above should include it. Besides, tutorial should be updated from the original readme file.
I also reported it to optimus-manager developer:

So all in all, it works as intended and setup is fairly simple. The only downside is I cannot revert to correct bumblebee setup now, but now that Steam Play is important, bumblebee is not optimal solution anymore.

1 Like

I couldn’t find mylauncher plasmoid but I had already pop up launcher, so I use this, however, something is not working correctly with the desktop file. Can you post your configuration? At the moment I have for example:

[Desktop Entry]
Comment=Switches session to use Intel GPU
Encoding=UTF-8
Exec=optimus-manager --switch intel --no-confirm
Icon=/home/michaldybczak/Obrazy/ikony/intel.png
Name=Intel-GPU-mode
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

And it won’t switch to intel that way, although in terminal all works.

Okey Im not at home now. When Im arrived home I can send :slight_smile:

I found the solution. Exec command needed some tweaking. That works:


Exec=bash -c 'optimus-manager --switch intel --no-confirm'

or

Exec=bash -c 'optimus-manager --switch nvidia --no-confirm'

So all is good now. It would be nice if the launcher had a switchable icon depending on which mode is on, but I guess we would have to fork and modify some plasmoid for that. Bumblebee notifier works like that - it switches icons depending on some state in the system) so maybe someone can fork it and rewrite for custom icons depending on the custom command state, like

if

optimus-manager --print-mode

is intel

then ‘path to icon’

and so on. I’m not into scripting, just laying out the logic behind such applet. So sort of like pop-up launcher and bumblebee notificator in one.

1 Like

That will be awesome but Im not good at develop…

Maybe someone from here will know what to do. I’m also clueless about programming, so I can only give the idea. Someone else must execute it :stuck_out_tongue_winking_eye: .

Anyway, GUI switcher works well now, so I’m happy.

1 Like

I forgot to say U can use optimus-manager --switch auto --no-confirm

Auto is intel to nvidia, nvidia to intel automatically

I know but one can be lost in which mode is on, so without any notification I would have to check it with a command. However for a GUI switcher applet this could be a nice solution if someone will write it.

Weird, it broke my plasma desktop today. I tried to use gnome but its worse on gnome…

Maybe xfce will be stable with it …

When I’m using cinnamon it just worked like a beast but in plasma works and broke desktop randomly

That is strange. Are you checking what is happening? How switching GPU settings is messing with DE?

Idk it happens twice in a month. Plasma gona open notifications are coming then everythink is gonna freeze :stuck_out_tongue:

I love plasma very much but I need that script :confused: I’m downloading cinnamon again…

Hmm… Will see how it goes for me then. So far no complains.

But really weird It isnt only changing xorg.conf ? Maybe optimus-manager’s daemon cause it who knows…