/ ubuntu

Ubuntu 18.04, Steam and nvidia 390

After a lot of struggles I managed to get nvidia-driver-390 work with bumblebee and Steam on Ubuntu 18.04. This post is an attempt to summarize my findings before I forget it all and then have to struggle with it again in the future.

Before upgrading to Ubuntu 18.04, my discreet Nvidia card had been running just fine with bumblebee, I could run games on steam using optirun and life was good. After the upgrade things went south and even though I managed to get optirun to work again, games on Steam would not start. Lots of googling later, I managed to fix it

My setup

I have Dell Inspiron 17 (7746), which comes with Intel HD Graphics 5500 (rev 09) and Nvidia GM108M [GeForce 845M] (rev ff). My desktop runs on the Intel card and I mainly use Nvidia to run games on Steam. To get the drivers and friends I use the awesome repo ppa:graphics-drivers/ppa, which I find very reliable.

nvidia-driver-390 installation

The installation is pretty straightforward and it has been covered in many other blogs, so I'll go over it quickly for completeness.

sudo apt-get purge nvidia* bumblebee*

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update

sudo apt-get install \
    nvidia-driver-390 \
    nvidia-modprobe \
    bumblebee \
    bumblebee-nvidia \
    primus \
    linux-headers-generic

The purging (first step) is recommended to avoid any dodgy leftovers which could screw up your evening. Then we add the graphics-drivers repo and finally install the packages.

Some of the packages are pretty obvious - nvidia-driver-390, bumblebee and bumblebee-nvidia are pretty obvious. linux-headers-generic are necessary for the driver to be built. primus because first of all, it supposedly offers better performance than VirtualGL, and secondly - because I could only make Steam work on primus bridge. nvidia-modprobe because my bumblebee was having a hard time loading the nvida module.

Important service changes for bumblebee and nvidia

Now we need to make sure that the bumblebee service will start at the boot time, that nouveau won't be loaded as a fallback and that the Intel card will be used by default. You may also disable the gpu-manager service, which overwrites xorg.cong on each boot. Here we go:

sudo systemctl enable bumblebeed
sudo systemctl disable nvidia-fallback.service
sudo systemctl disable gpu-manager.service
sudo prime-select intel

Bumblebee and modules configuration

Once the packages are installed, appropriate services switched either on or off, it's time to apply a few tweaks here and there in the configuration. Let's start with bumblebee.

bumblebee.conf

Using your favourite editor open the file /etc/bumblebee/bumblebee.conf, like so:

sudo nano /etc/bumblebee/bumblebee.conf

There is just a handful of changes required.

Driver
In the section [bumblebeed], should be line 22, change the driver to nvidia, because you don't want to use nouveau (I always have troubles spelling it):

Driver=nvidia

Bridge
In the section [optirun], should be line 32, change the bridget to primus. I'm suggesting this step, because virtualGL does not work for me in Steam anymore and none of the games wants to start:

Bridge=primus

Library Path
In the section [driver-nvidia], should be line 60, change the library path. It has changed for the new drivers (nvidia-driver-390):

LibraryPath=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu

Xorg Module Path
Again in the section [driver-nvidia], should be line 63, change the Xorg module path. Again, it has changed for the new drivers (nvidia-390):

XorgModulePath=/usr/lib/x86_64-linux-gnu/nvidia/xorg,/usr/lib/xorg/modules,/usr/lib/xorg/modules/input

environment

As explained by clover, there was a major change in the nvidia drivers, which now use glnvd. That prevents bumblebee from working with primus bridge. The fix is simple, you just need to:

sudo nano /etc/environment

and add the following line:

__GLVND_DISALLOW_PATCHING=1

modules

bbswitch and i915
We want to make sure that the bbswitch module and Intel card module are loaded upon boot.

sudo nano /etc/modules

and make sure you have the following two lines in there:

i915
bbswitch

Blacklisting
There is one more thing, which needs to be taken care of, otherwise the nvidia module either won't be loading or unloading when the Nvidia card is not in use.

sudo nano /etc/modprobe.d/blacklist-nvidia.conf

There is a warning at the top of the file, which discourages modifications. This can be safely ignored, because otherwise things won't work. We're acting on behalf of the greater good here. You need to make sure, that setting the alias for nvidia is commented out or the module won't load. Also, the alias for nvida-drm has to be set to off or bumblebee won't be able to unload the module and switch off the Nvidia card when it is not in use. nvidia-modeset is not harmful, so can be spared the alias as well. In essence, make sure you have the following three lines in this file:

#alias nvidia off
alias nvidia-drm off
alias nvidia-modeset off

Does nvidia-driver-390 work with bumblebee?

After all of that configuration you can now reboot your laptop and check if everything works correctly. First of all, none of the discreet GPU modules should be loaded, and the following commands should not yield any output.

lsmod | grep nvidia
lsmod | grep nouveau

If you want to see if optirun works correctly, glxspheres64 included in the package virtualgl does quite a good job.

optirun glxspheres64

It should open a window with lots of colourful, rotating spheres, and the output in the console should be similar to the following:

optirun glxspheres64

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)
Visual ID of window: 0x129
Context is Direct
OpenGL Renderer: GeForce 845M/PCIe/SSE2
61.676735 frames/sec - 68.831237 Mpixels/sec
60.006045 frames/sec - 66.966746 Mpixels/sec
60.023603 frames/sec - 66.986340 Mpixels/sec
60.037726 frames/sec - 67.002102 Mpixels/sec

If it doesn't work, the best advice I can give is this. First of all, try to understand the error message and see if it relates to any of the changes I have discussed above. It might have happened that you skipped something by accident. Secondly, ask Google and please let me know in the comments.

(small) caveat

primusrun doesn't work for me at all, but I don't care that much, because optirun does the job just as well with the primus bridge. Most importantly, I can run my Steam games on the Nvidia card again.

If you found this post useful, please share.

Edit 2018.07.27: As Roland rightly pointed out, the nvidia-390 is a transitional package, and nvidia-driver-390 is the actual driver. I changed that throughout the text.

Edit 2018.07.28 As Roland figured out, if bbswitch does not switch off the Nvidia card when its not active it's worth checking if your GRUB_CMDLINE_LINUX defined in /etc/default/grub contains acpi_osi=Linux. If you need to add it, remember to run sudo update-grub afterwards.

Thanks for reading,
Jacek

comments powered by Disqus
Ubuntu 18.04, Steam and nvidia 390
Share this