Kindly support DOTSLASHLINUX on Patreon to keep the website up and running while remaining ads free.

Setting Up Bumblebee on Gentoo Linux

bumblebee
Firas Khalil Khana | 04/06/2017

Optimus support on a GNU/Linux distro has always been a hassle thanks to NVIDIA… Therefore projects were created to compensate for this powersaving feature. Enter bumblebee a project aimed to replicate NVIDIA’s optimus function on GNU/Linux!.

In this article I’ll be talking about setting up a working bumblebee setup on Gentoo Linux. Worry not because setting up bumblebee on Arch Linux/Void Linux is easy. Not that it’s hard on Gentoo, but several steps are required to get a fully working bumblebee setup.

When we talk bumblebee, several things should come to one’s mind:

  1. A laptop with 2 GPUs an iGPU (integrated intel gpu) and a dGPU (discrete NVIDIA gpu).
  2. A kernel that supports loading and unloading modules.
  3. A proper /etc/portage/make.conf that works with this setup.
  4. The packages bumblebee, primus and bbswitch must be installed.
  5. Your user must be added to the following groups video and bumblebee.
  6. You should enable the service bumblebee.
On Gentoo, extra steps are required to get bumblebee working, but guess what, you won’t be going back to Arch Linux ever again because bumblebee on Gentoo is hard to setup.

Before we get started, I want to point out that bumblebee is a fairly old project (last release was on 26 April 2013), but it still works perfectly. Until NVIDIA decides to make optimus working properly on GNU/Linux, you should be using bumblebee.

1- Checking if Your Laptop Uses NVIDIA Optimus


This is pretty much straightforward. If you have an intel processor (2nd Gen +) and a NVIDIA gpu, then you probably have optimus on your laptop. For those who want to check fire up your favorite terminal and run:

lspci -k
...
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)
	Subsystem: Toshiba America Info Systems 4th Gen Core Processor Integrated Graphics Controller
	Kernel driver in use: i915
01:00.0 3D controller: NVIDIA Corporation GK208M [GeForce GT 740M] (rev ff)
...


In my case I’m using an Intel HD4600 (cpu is 4th Gen Core i7 4700MQ) as my iGPU and my dGPU is a NVIDIA GT740M.
Don’t worry if your drivers in use (for now) are different, in my case I have built-in modules and my NVIDIA card is OFF (NVIDIA driver isn’t loaded at boot which means bumblebee is working perfectly).

As you can see, optimus laptops have VGA compatible controller which is the integrated intel card that manages the display and uses the i915 kernel driver, and a 3D controller which is the stronger NVIDIA card which is going to be used when needed via bumblebee.

If your GNU/Linux experience was awful so far because your laptop was on fire 247, then you probably have an optimus laptop that needs correct configuration.


2- Checking if Your Kernel Supports Loading/Unloading Modules


In order for bumblebee to work, then bbswitch must be loaded at boot time and nvidia mustn’t.

Make sure that CONFIG_MODULES=y and CONFIG_MODULE_UNLOAD=y are enabled.

3- Optimizing your ‘/etc/portage/make.conf’


Now make sure that you have the following in your /etc/portage/make.conf:

vim /etc/portage/make.conf
...
VIDEO_CARDS="intel i965 nvidia"
...


In most cases using i965 should be fine, however if you were using an older card then please check the following Intel Feature Support on Gentoo Linux.

Now sync and update your system:

emerge --sync && emerge -avuDN @world


Now simply reboot your system, and continue this article.

shutdown -r now

4- Installation


For the installation part, we need 3 packages, bumblebee,primus and bbswitch. It’s recommended to download the live (git or -9999) versions of the previous packages to ensure that they work well with recent kernel and nvidia-drivers versions.

Fire up your favorite text editor, and make sure your /etc/portage/package.accept_keywords -(which in my case is a single file and not a directory)- contains the following:

=sys-power/bbswitch-9999 ∗∗
=x11-misc/bumblebee-9999 ∗∗
=x11-misc/primus-0.2 ~amd64


Now simply run:

emerge -av bbswitch primus bumblebee

5- Adding Your User to the Groups video and bumblebee


After installing the previous packages, add your USER to the groups video and bumblebee:

gpasswd -a USER video && gpasswd -a USER bumblebee


Don’t forget to replace USER with your real username.

Now logout and relogin and your user should be in these groups.


6- Modifying /etc/init.d/bumblebee


Here’s where it gets tricky, this file is the one responsible for the hassle. Notice at the beginning of the file it depends on xdm and vgl and we don’t need both of them for our setup to work.

You see it depends on xdm to make sure that bumblebee isn’t started if there’s no Xorg server installed. As for vgl, then we’re using primus which is much better performance wise.

Open a terminal emulator and edit /etc/init.d/bumblebee with your favorite editor (vim is my favorite editor now), and delete the first 5 lines (or their equivalent; the depend() part) as shown below:

vim /etc/init.d/bumblebee
depend() {
    need xdm
    need vgl
	after sshd
}

PIDFILE="${PIDFILE:-/var/run/bumblebee.pid}"

start() {
	ebegin "Starting BumbleBee Daemon"
		start-stop-daemon -S -p "${PIDFILE}" -x /usr/sbin/bumblebeed -- -D ${BUMBLEBEE_EXTRA_OPTS} --pidfile "${PIDFILE}"
	eend $?
}

stop() {
	ebegin "Stopping BumbleBee Daemon"
		start-stop-daemon -K -p "${PIDFILE}" -R SIGTERM/10
	eend $?
}


So your file should look like this:

PIDFILE="${PIDFILE:-/var/run/bumblebee.pid}"

start() {
	ebegin "Starting BumbleBee Daemon"
		start-stop-daemon -S -p "${PIDFILE}" -x /usr/sbin/bumblebeed -- -D ${BUMBLEBEE_EXTRA_OPTS} --pidfile "${PIDFILE}"
	eend $?
}

stop() {
	ebegin "Stopping BumbleBee Daemon"
		start-stop-daemon -K -p "${PIDFILE}" -R SIGTERM/10
	eend $?
}

7- Modifying /etc/bumblebee/bumblebee.conf


We need to change some of the default settings that bumblebee uses, start that terminal emulator and with your favorite editor (vim), edit the file /etc/bumblebee/bumblebee.conf:

# Configuration file for Bumblebee. Values should ∗∗not∗∗ be put between quotes

## Server options. Any change made in this section will need a server restart
# to take effect.
[bumblebeed]
# The secondary Xorg server DISPLAY number
VirtualDisplay=:8
# Should the unused Xorg server be kept running? Set this to true if waiting
# for X to be ready is too long and don't need power management at all.
KeepUnusedXServer=false
# The name of the Bumbleblee server group name (GID name)
ServerGroup=bumblebee
# Card power state at exit. Set to false if the card shoud be ON when Bumblebee
# server exits.
TurnCardOffAtExit=false
# The default behavior of '-f' option on optirun. If set to "true", '-f' will
# be ignored.
NoEcoModeOverride=false
# The Driver used by Bumblebee server. If this value is not set (or empty),
# auto-detection is performed. The available drivers are nvidia and nouveau
# (See also the driver-specific sections below)
Driver=nvidia
# Directory with a dummy config file to pass as a -configdir to secondary X
XorgConfDir=/etc/bumblebee/xorg.conf.d

## Client options. Will take effect on the next optirun executed.
[optirun]
# Acceleration/ rendering bridge, possible values are auto, virtualgl and
# primus.
Bridge=primus
# The method used for VirtualGL to transport frames between X servers.
# Possible values are proxy, jpeg, rgb, xv and yuv.
VGLTransport=rgb
# List of paths which are searched for the primus libGL.so.1 when using
# the primus bridge
PrimusLibraryPath=/usr/lib/primus:/usr/lib32/primus
# Should the program run under optirun even if Bumblebee server or nvidia card
# is not available?
AllowFallbackToIGC=false


# Driver-specific settings are grouped under [driver-NAME]. The sections are
# parsed if the Driver setting in [bumblebeed] is set to NAME (or if auto-
# detection resolves to NAME).
# PMMethod: method to use for saving power by disabling the nvidia card, valid
# values are: auto - automatically detect which PM method to use
#         bbswitch - new in BB 3, recommended if available
#       switcheroo - vga_switcheroo method, use at your own risk
#             none - disable PM completely
# https://github.com/Bumblebee-Project/Bumblebee/wiki/Comparison-of-PM-methods

## Section with nvidia driver specific options, only parsed if Driver=nvidia
[driver-nvidia]
# Module name to load, defaults to Driver if empty or unset
KernelDriver=nvidia
PMMethod=bbswitch
# colon-separated path to the nvidia libraries
LibraryPath=/usr/lib64/opengl/nvidia/lib:/usr/lib/opengl/nvidia/lib
# comma-separated path of the directory containing nvidia_drv.so and the
# default Xorg modules path
XorgModulePath=/usr/lib64/opengl/nvidia/lib,/usr/lib64/opengl/nvidia/extensions,/usr/lib64/xorg/modules/drivers,/usr/lib64/xorg/modules
XorgConfFile=/etc/bumblebee/xorg.conf.nvidia


I’ve highlighted the lines that you should check, just make sure that:

KeepUnusedXServer=false
Driver=nvidia
Bridge=primus
VGLTransport=rgb (for vgl users)
KernelDriver=nvidia
PMMethod=bbswitch


8- Enabling and Starting bumblebee Service


Simply add the service bumblebee to the runlevel default:

rc-update add bumblebee default


Now simply reboot and you should be good to go!

shutdown -r now

9- Modifying /etc/modprobe.d/nvidia-rmmod.conf


In order for bbswitch to work properly, the nvidia module should be removed with ease without spitting any errors. Therefore, we’ve disable the kms and uvm USE flags of nvidia-drivers.

Now we should only have the nvidia module, no nvidia-uvm, no nvidia-drm, no nvidia-modeset. We need to instruct modprobe -r nvidia to remove only nvidia and nothing else (as there’s nothing else to be removed). So fire up your favorite editor and edit /etc/modprobe.d/nvidia-rmmod.conf:

vim /etc/modprobe.d/nvidia-rmmod.conf
# Nvidia UVM support

remove nvidia modprobe -r --ignore-remove nvidia-drm nvidia-modeset nvidia-uvm nvidia


and remove every other module except for nvidia so the end file should look like this:

remove nvidia modprobe -r --ignore-remove nvidia


This is an extremely important step as attempting to remove the nvidia module without it will result in errors.


(Optional) Checking if bumblebee is Working


If you’ve followed along with this article then your bumblebee setup should be working 100%. I recommend using primusrun instead of optirun since optirun tends to spit out more errors than primusrun (but after our configuration they should both be using the primus bridge and provide similar performance.

To test our bumblebee configuration, install the package mesa-progs:

emerge --sync && emerge -av mesa-progs


Now before testing anything the NVIDIA card should be OFF, and the nvidia module shouldn’t be loaded, instead the module bbswitch should be loaded. To double check fire up that terminal emulator and run:

lsmod
Module                  Size  Used by
bbswitch                5461  0


then run:

cat /proc/acpi/bbswitch
0000:01:00.0 OFF


As you can see:
1- bbswitch is loaded
2- nvidia isn’t loaded
3- card is OFF as reported by bbswitch

Now let’s check if the NVIDIA card will be switched ON and the nvidia module will be loaded once optirun/primusrun are executed, and if it’ll switch OFF and the nvidia module will be unloaded once optirun/primusrun finish executing.

Inside your terminal emulator (and while you’re running in a Xorg session… obviously…) run:

optirun glxgears


or (but not both):

primusrun glxgears


A window showing glxgears should open. While it’s running check the following:

lsmod
Module                  Size  Used by
nvidia              10652360  51
bbswitch                5461  0


and:

cat /proc/acpi/bbswitch
0000:01:00.0 ON


Notice how the nvidia module got loaded and the card switched on. Now end the running glxgears and do a simple check, the card should be OFF and the nvidia module should be unloaded and bbswitch will stay loaded.

Some of you may say that using vgl gets me more fps when running glxgears or any benchmark application. That is simply not the case as vgl doesn’t adjust itself to the screen’s refresh rate like primus does. Try running the following and see how primus crushes vgl:

vblank_mode=0 primusrun glxgears


If your card was refusing to turn OFF and the nvidia module is still loaded upon finishing the execution, then run the following:

rmmod nvidia && echo "OFF" >> /proc/acpi/bbswitch

(Optional) USE Flags


For those of you that are wondering what USE flags I’m using for my packages:

For nvidia-drivers(notice how I disabled uvm and kms USE flags, as they can lead to errors when unloading the nvidia module unless you’re using a patched version of bumblebee):

equery u nvidia-drivers
∗ Found these USE flags for x11-drivers/nvidia-drivers-381.22:
 U I
 + + X           : Install the X.org driver, OpenGL libraries, XvMC libraries, and VDPAU libraries
 + + acpi        : Add support for Advanced Configuration and Power Interface
 + + compat      : Install non-GLVND libGL for backwards compatibility
 + + driver      : Install the kernel driver module
 + + gtk3        : Install nvidia-settings with support for GTK+ 3
 - - kms         : Enable support for kernel mode setting (KMS)
 - - pax_kernel  : PaX patches from the PaX project
 - - static-libs : Build static versions of dynamic libraries as well
 + + tools       : Install additional tools such as nvidia-settings
 - - uvm         : Install the Unified Memory kernel module (nvidia-uvm) for sharing memory between CPU and GPU in CUDA programs
 - - wayland     : Enable dev-libs/wayland backend


For xf86-video-intel:

equery u xf86-video-intel
∗ Found these USE flags for x11-drivers/xf86-video-intel-2.99.917_p20170313:
 U I
 - - debug : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see
             https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
 + + dri   : Enable direct rendering: used for accelerated 3D and some 2D, like DMA
 + + dri3  : (Restricted to <=x11-drivers/xf86-video-intel-2.99.917_p20160621)
             Enable DRI3 support
 + + sna   : Enable SandyBridge's New Acceleration (useful on all chipsets, not just SandyBridge)
 - - tools : Build the intel-virtual-output tool
 + + udev  : Enable virtual/udev integration (device discovery, power and storage device support, etc)
 - - uxa   : Enable UMA Acceleration Architecture
 + + xvmc  : Enables X-Video Motion Compensation support


For bumblebee:

equery u bumblebee
∗ Found these USE flags for x11-misc/bumblebee-3.2.1:
 U I
 + + bbswitch            : Add dependency on sys-power/bbswitch for PM feature
 - - video_cards_nouveau : VIDEO_CARDS setting to build reverse-engineered driver for nvidia cards
 + + video_cards_nvidia  : VIDEO_CARDS setting to build driver for nvidia video cards

(Optional) Workarounds

If bbswitch was unable to switch the ACPI state of the dGPU then you might want to double check your nvidia-drivers USE flags and make sure that only nvidia is being loaded and both uvm and kms are disabled. Make sure that no other power management services are running (as they may interfere with bbswitch and prevent it from turning the card off). These include tlp, powertop and laptop-mode-tools (either disable these services or uninstall them completely).

If bbswitch is still refusing to turn off the card (which is unlikely if you followed what I mentioned earlier) try adding

"acpi_osi=!Windows\x202013" acpi_osi=Linux nogpumanager i915.enable_hd_vgaarb=1 enable_hd_vgaarb=1


to your kernel command-line (this has worked for a couple of users, especially those with Thinkpads and Lenovo laptops).

Some users were receiving vgaarb errors:

dmesg | grep vgaarb
...
vgaarb: this pci device is not a vga device
vgaarb: this pci device is not a vga device
...


Make sure that CONFIG_VGA_ARB=y and CONFIG_VGA_ARB_MAX_GPUS=2. If you’re still seeing this error (even though it was fixed in 3.10 according to this Bugzilla Kernel 63641 and Bumblebee Github Issue #159), you can try to patch your kernel with this vgaarb patch by running this (after downloading the patch file of course).

If bbswitch was working fine for you until a kernel version update killed it (in some cases it won’t be working in the first place), then you can add pcie_port_pm=off to your kernel command line and notify your bootloader about the changes and hopefully it’ll work for you.

The reason I said hopefully is that this workaround used to work in earlier versions of the Linux kernel (4.8) but several users reported that it’s not working as of (4.13). Still it won’t hurt if you try it.


Chinese Translation

One of DOTSLASHLINUX’s followers from china 杨鑫 (Yang Mame), has provided a chinese translation of this guide on his blog.

To read this guide in chinese click here.

36 Comments

Drakkar

09/07/2017


Hi. I am Spanish and I am writing from the Google translator, I hope it is understood well. I followed your tutorial and I never turned off the Nvidia card, it always stays on. “cat /proc/acpi/bbswitch 0000:01:00.0 ON “ E followed the tutorial step by step. And the only way I have to shut down my Nvidia is this way “rmmod nvidia rmmod nvidia_modeset tee /proc/acpi/bbswitch <<< OFF “ Even without having switched it on before, bbswitch does not seem to be working. If you could lend me a hand I would be grateful. regards

DOTSLASHLINUX

09/07/2017


@Drakkar, Hey there, thanks for reading the article above. Yes, I completely understood what you said. As I mentioned above, setting up bumblebee on Gentoo GNU/Linux can really be a hassle. Looks like nvidia_modeset is being loaded along side nvidia, this may prevent bbswitch from correctly turning off the card after boot and will definitely prevent bumblebee from turning off the card using bbswitch after using optirun unless you’re using a patched version of bumblebee. I listed my USE flags above and I recommend that you disable the kms USE flag for nvidia-drivers package and re-emerge it again. Disabling kms should remove the nvidia-modeset kernel module. Another thing to do would be to double check if bumblebee -the service- is actually running or not. Might as well confirm that the USE flags on your packages match the ones listed in the article above. Hope this helps! Best of luck!

Drakkar

12/07/2017


Hi. I compile with the USE that you have in the manual, but there is no way, do not turn off nvidia, I skipped no manual step, bbswitch does not seem to work

DOTSLASHLINUX

12/07/2017


@Drakkar, sorry to hear that. Can you share your dmesg output?

Drakkar

13/07/2017


Hello Goodnight. Sorry for the delay in passing the dmesg exit and for being these hours so late, but only now. Thank you very much for your attention and interest in helping me. I leave you the file with the output dmesg here.

DOTSLASHLINUX

13/07/2017


@Drakkar, that dmesg output doesn’t look so good. I suggest you stick around here until the kernel configuration guide comes out. For now here’s what you can do.

1- Disable “CONFIG_VGA_SWITCHEROO”, we’re already relying on bbswitch so there’s no need for vga_switcheroo.

2- Looks like you’re using more than one driver for you nvidia card which is creating conflicts, I suggest that you disable “CONFIG_DRM_NOUVEAU” and blacklist it’s driver. The nvidia driver that you’re supposed to use for this setup to work is “nvidia.ko” provided by the package “nvidia-drivers”.

3- You should also disable “nvidiafb” the only framebuffer kernel config that you should be using is “CONFIG_DRM_FBDEV_EMULATION”.

Keep me updated after you try the suggestions listed above. Best of luck!

Drakkar

16/07/2017


Having done what you recommend, it seems that now it works for me and now bbswitch seems to be working, my nvidia card goes out. I’m going to follow your web closely, it helped me a lot with bumblebee and with the guide intel-ucode, congratulations for your great work and thank you very much. Greetings from the Canary Islands

DOTSLASHLINUX

16/07/2017


@Drakkar, you’re welcome! Glad that it worked for you! Let me know whenever you need any help. Thanks for your feedback!

Michael Mounteney

23/07/2017


I’d be obliged if you could look over my configuration. I think I’ve done everything as you said. Mine is a x86_64 build on a Lenovo W520. When I start lightdm, for example, the system switches to another virtual console but never leaves text-mode (the blinking cursor never disappears). Relevant output: (1) lspci -v https://pastebin.com/g4GDD21J (2) dmesg https://pastebin.com/Fy2WsuFZ (3) build use flags for nvidia-drivers https://pastebin.com/4CLDvPVa (4) build use flags for xf86-video-intel https://pastebin.com/ZnPM9MmB (5) build use flags for bumblebee https://pastebin.com/J8n0zqBB (6) Xorg.0.log https://pastebin.com/WAMACsNR (7) lsmod https://pastebin.com/AcLuyYq9 . I had ‘modprobe nvidia’ which accounts for the appearance of that driver in the lspci and lsmod output

DOTSLASHLINUX

23/07/2017


@Michael Mounteney, thanks for visiting the website. After reading through the log files you provided, it seems that bbswitch doesn’t want to switch the nvidia card OFF leaving the card always ON (in D0 power state). I’m not sure I fully understood the problem you’re going through. Is it related to bumblebee or lightdm? Is the card OFF once you boot your system? Is the nvidia driver being loaded automatically upon booting? Can you turn off your card manually as suggested in the article? Is the problem only with lightdm? Hopefully we can figure something out once I fully understand what the problem is. I also noticed that you enabled both uxa and sna USE flags on xf86-video-intel. It’d be better if you disabled the uxa USE flag and check if you’re using sna as your acceleration method as it may have something to do with your problem. Thanks for passing by! Have a great day!

Michael Mounteney

23/07/2017


Sorry for re-posting. I didn’t appreciate that my OP would only appear when you reviewed it. Thank you for the answer.

DOTSLASHLINUX

23/07/2017


@Michael Mounteney, oh don’t you worry about it. Comments are being monitored to prevent spam, so it may take a while before your comment appears.

Michael Mounteney

24/07/2017


Thank you for the reply.

Here are two more relevant files: (8) /etc/bumblebee/bumblebee.conf https://pastebin.com/SjWZmK wV (9) kernel .config https://pastebin.com/gvs5ES .

I removed use flag uxa and rebuilt.

After rebooting, /proc/acpi/bbswitch contains “0000:01:00.0 OFF”

If I run “primusrun X”, the output is as per Xorg.0.log in https://pastebin.com/WAMACsNR includi ng the “no screens found(EE)” line.

After running “primusrun X” /proc/acpi/bbswitch still contains “0000:01:00.0 OFF” so it seems th at the nvidia driver is not being loaded.

Kernel module “nvidia_drm” is loaded; is that significant?

DOTSLASHLINUX

24/07/2017


@Michael Mounteney, primusrun X? Are you trying to run a Xorg session on your discrete GPU? I’d suggest checking eselect opengl list and switching it to xorg-x11. Another thing I’d recommend is test older or stable versions of both the kernel and nvidia-drivers. I had problems getting the kernel and nvidia-drivers to work with bbswitch on the ~amd64 unstable branch , but it’s working fine on the amd64 stable branch (kernel version 4.9.34, nvidia-drivers version 381.22). You might want to disable runtime power manager as well for the nvidia card such as TLP/powertop and see how things go. Oh and the link to the kernel .config you shared is broken. It’d be better as well if you clarified what the problem is because it’s still vague to me, and perhaps mention the steps required to recreate it. Thanks for stopping by! Have a great day!

peedub

16/08/2017


@DOTSLASHLINUX, Great job documenting the process! I have run into a similar issue as to what @drakkar had. On boot bumblebee is running but the card is on and i have the 3 nvidia modules loaded “nvidia nvidia_modeset nvidia_drm”. I’ve compiled nvidia-drivers with USE=“-kms” but the module is still being loaded and I was under the impression that getting rid of the kmd use flag would get rid of the modeset module but its not seaming to.. nvidia-drivers-384.59-r1. If I rmmod the modules after boot and turn off the card that works. also the card is turned back on when running primusrun glxgears but is not turned back off after exiting due to having the nvidia_modeset module loaded again. I’m pretty sure my solution here is to blacklist the nvidia_modeset module but haven’t given it a shot to verify if in fact this fi xes the issue or causes yet another. any ways, thanks and cheers for the docs so far, great work!! keep em coming!

DOTSLASHLINUX

17/08/2017


@peedub, thanks for your reply! Indeed, the problem is from nvidia_drm and nvidia_modeset being loaded at boot time. Unless bumblebee and bbswitch were patched to prevent these 3 from loading (which is unlikely), the only way to do that is by disabling the kms USE flag. The reason that they’re still being loaded on your end is that the modules were previously built for your kernel so you have to remove them manually or remove the /lib/modules/linux* dir and build the kernel and nvidia-drivers and bbswitch again. That can be troublesome for some users, but give it a shot along with the blacklisting and tell me how things go! Glad you liked the article!

peedub

25/08/2017


@DOTSLASHLINUX after removing the drivers from /lib/modules I now have for the most part everything working as expected. One exception is is with blender, blender loads the nvidia_uvm module and it does not seam that primusrun is able to unload nvidia drivers after nvidia_uvm has been loaded. My /etc/modprobe.d/nvidia-rmmod.conf file has “remove nvidia modprobe -r –ignore-remove nvidia-drm nvidia-modeset nvidia-uvm nvidia” so im kinda at a loss as to why it isn’t able to unload uvm. Other than that, seams to be working for most other stuff, glxgears tests are as expected. Cheers

DOTSLASHLINUX

25/08/2017


@peedub, well if it was working for the rest of your system as expected, then you can put up with turning it manually when uvm is being loaded when using blender. The correct order is to unload nvidia-uvm first then nvidia: modprobe -r nvidia-uvm nvidia. It’s related to CUDA and your blender USE flags, so I’ll double check these if I were you. Glad that it worked for everything else though!

VICTORGUERRAVELOSO

19/08/2017


@DOTSLASHLINUX Thanks for the Tutorial. Finally i can use Gentoo on my notebook. I`ve been stuck on Arch since the last year cause i couldn’t figure out what i was doing wrong. I followed your steps exactly as you said, and it’s working!

DOTSLASHLINUX

20/08/2017


@VICTORGUERRAVELOSO Thanks for your stopping by, glad that it worked for you!

HerrSchafer

28/08/2017


Thanks for sharing! Applications must be started with “optirun app” in order to use Nvidia card? Switch it ON and OFF should be automatic, as far as I understand the goal of bumblebee. By the way, how will the program knows when to use or not the dGPU?

DOTSLASHLINUX

28/08/2017


@HerrSchafer, thanks for your reply! Applications will use the iGPU when the dGPU is turned off, you don’t have to specify anything (the iGPU will be picked by default since it’s responsible for the display). Using optirun app or primusrun app will fire up your dGPU and will start the program you specify on the dGPU. You can install mesa-progs (or mesa-demos or glxinfo) and see for yourself, glxinfo | grep ‘OpenGL renderer’ will show the internal card, try adding optirun or primusrun optirun glxinfo | grep ‘OpenGL renderer’ and you’ll get the nvidia card in the output. Hope that helps!

Mike

05/10/2017


Hi, thank you very much, everything was very clear. However, I get this error message when I arrive at:

optirun glxgears

libGL error: unable to load driver: i965_dri.so libGL error: driver pointer missing

Did you ever see this before? How can I debug it?

DOTSLASHLINUX

05/10/2017


@Mike, Thanks for your feedback. To debug this problem (and any libGL related problem), you’ll want to add this environment variable before the command you want to execute (perhaps share its output as well):

LIBGL_DEBUG=verbose optirun glxgears

As for the problem you’re receiving, would you mind sharing your system logs?

1- dmesg

2- kernel config (if possible)

3- lsmod

4- lspci -nnkkvvv

5- /var/log/rc.log (if it exists)

6- the USE flags for mesa, bumblebee, xf86-video-intel, nvidia-drivers, bbswitch and primus

I’d also check if CONFIG_DRM_I915_USERPTR is included in your respective kernel configuration or not.

According to the error message you’ve provided, it seems that the i965 driver refused to load, which may be due to a disabled i965 USE flag (which is unlikely if you’ve followed the guide above).

Hopefully, we’ll be able to solve this problem! Keep me updated Mike!

Mike

05/10/2017


Thank you so much! Actually I found the problem - between the chair and the computer. I had put the wrong driver name in make.conf (i915 instead of i965, duh) Everything is working exactly as advertised now. Your guide is really great!

Just another question - I tried optirun nvidia-settings, the program starts (and runs on nvidia) but doesn’t allow any settings because the xorg.server is not running on nvidia, I suppose this is perfectly normal and expected behavior, right?

So, my laptop will only use nvidia if and when I need it, and any program needing it must be launched with a preceding optirun.

And bbswitch must be recompiled with every kernel, together with nvidia driver and intel drivers.

I’m on a HP ENVY Notebook - 15-ae106nl (ENERGY STAR) Thanks again!

DOTSLASHLINUX

05/10/2017


@Mike, That’s really nice to hear, I’m super glad that it worked for you!

As for running nvidia-settings, yes it’s perfectly normal, you just have to disable the bridge and specify a display and you’ll be good to go:

optirun -b none -c nvidia-settings :8

Yes, you’ll have to recompile bbswitch and nvidia-drivers as they’re the only out of tree kernel modules. You can simply execute:

emerge -av @module-rebuild

and it’ll automatically recompile all out of tree kernel modules after updating your kernel version.

Hope that helps! Thanks for stopping by!

Mike

10/10/2017


I tried:

optirun -b none -c nvidia-settings :8

but I get

Error running ‘:8’: No such file or directory ‘

DOTSLASHLINUX

11/10/2017


@Mike, you’ll need to enable the gtk3 USE flag on the nvidia-drivers package and ensure that nvidia-settings is installed.

Mike

12/10/2017


Ok, there were two problems: first, you can only run an xserver on :8 if you are working from X started with startx. From a desktop environment started with xdm it won’t work. Second, the correct command is apparently

optirun -b none nvidia-settings :8 ( without -c option )

However, nvidia-settings still complains about xserver not running on nvidia.

Actually, I tried to get nvidia working on this laptop without bumblebee (stopping bumblebee service, unloading bbswitch module, loading nvidia module, using an xorg.conf file which should be ok) and I get a black screen. But no error messages from startx. I also tried adding the xrandr lines in .xinitrc as someone suggested, but doesn’t solve the problem.

So, now I have two questions:

1) should I bother about getting my laptop working with just the nvidia driv er at all, since apparently apps with bumblebee work? Or is this going to bite me somehow?

2) if you think it would be safer to check that nvidia-driver works without bumblebee, isn’t there some script somewhere that can do a proper nvidia setup? I mean, distro’s like Ubuntu or Mint do this automagically. Or what should I try?

DOTSLASHLINUX

12/10/2017


@Mike, You’re asking too many questions in this regard. This setup is for those who have an Intel integrated GPU and a NVIDIA discrete GPU and want to get an optimus-like setup on a GNU/Linux distro. It isn’t a setup for disabling the integrated GPU completely and running everything on the discrete GPU.

As for the nvidia-settings command that’s weird. Last time I checked I had to use the ‘-c’ in order to get it working.

Don’t remove the xdm part above if you’re intending to use xdm (which makes me wonder why not stick to xinit)…

Yes, on Arch Linux setting bumblebee is as easy as it gets. Getting bumblebee running on Arch is a pretty straightforward, error-free and no-hacks-required way (probably the easiest among all distributions out there).

Raptor

14/10/2017


I just wanted to say thanks a lot ! worked like a charm ! the only guide that is truly thorough about gentoo & bumblebee . My battery time literally jumped to more than double thanks to this.

DOTSLASHLINUX

14/10/2017


@Raptor, Thanks so much for your feedback! Glad that it worked for you!

Dorian Silenus

11/11/2017


Hello and thank you for this tutorial!

I would like to add something here… First off, I am not sure whether disabling laptop_mode daemon is mandatory (for me, it works with laptop_mode enabled - but I’m going to test it a bit more as soon as I can). However, what was apparently mandatory for my system, was adding “pcie_port_pm=off” in the kernel GRUB line (GRUB_CMDLINE_LINUX_DEFAULT=“pcie_port_pm=off” in /etc/default/grub, and updating grub.cfg afterwards). Supposedly, this (sometimes?) happens with kernel >=4.8, so you might want to consider adding it to your article.

Thanks again!

DOTSLASHLINUX

14/10/2017


@Dorian Silenus, Thanks for stopping by and sharing your thought and experience on the matter. To be honest I’ve been trying to remember the workaround that fixed bbswitch which 4.8 broke but to no avail.

Thanks for taking some of your time to share the workaround and the article will be updated as soon as possible.

Dorian Silenus

11/11/2017


@DOTSLASHLINUX null sheen. Your article pointed me in the right direction in the first place, and it’s good to have all the bells and whistles in one place. Have you considered editing the Gentoo Wiki and putting your tutorial there? Also, some of those things (e.g. the /etc/inint.d/bumblebee file) should really be updated by the package maintainers… I honestly don’t understand why that isn’t happening.

As for the workaround, I should probably mention that it renders PCIe-related powersaving unusable, FWIW.

DOTSLASHLINUX

11/11/2017


@Dorian Silenus, well several parts of the articles written on DOTSLASHLINUX were added to the Gentoo Wiki where appropriate. The thing is, I consider my articles (especially this one) to be extrememly hacky, meaning that they probably won’t appeal to the majority of users hence maintainers choose to go with what’s safe or used by a bigger userbase.

Another thing is that I’m using the unstable branch and maintainers expect users to use similar hacks to fix some of these problems until fixes are pushed into the stable branch.

I believe that adding xdm as a dependency for the bumblebee service is to appeal to the larger user base that rely on display managers instead of using xinit. This is just a wild guess though.

Thanks for your valued replies!

Leave A Comment