Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Making Nvidia Drivers + CUDA 8 + Bumblebee work together on XPS 15 Early 2017 9560 kabylake. Ubuntu, KDE Neon, Linux Mint, debian.
# Instructions for 4.13 and cuda 9.0 RC
# If upgrading from 4.11 and cuda 8.0
$ sudo apt-get purge --auto-remove libcud*
$ sudo apt-get purge --auto-remove cuda*
$ sudo apt-get purge --auto-remove nvidia*
# also remove the container directory direcotory at /usr/local/cuda-8.0/
# Install Intel Graphics Patch Firmwares (This should reboot your system):
bash -c "$(curl -fsSL http://bit.ly/IGFWL-install)"
# Update to 4.13 kernel. nvidia-384 compiles fine with this.
cd /tmp
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13/linux-headers-4.13.0-041300_4.13.0-041300.201709031731_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13/linux-headers-4.13.0-041300-generic_4.13.0-041300.201709031731_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.13/linux-image-4.13.0-041300-generic_4.13.0-041300.201709031731_amd64.deb
sudo dpkg -i *.deb
# Add Nvidia repository
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
# Install via ubuntu drivers
sudo ubuntu-drivers autoinstall
# <optional for ML Folks> Install CUDA 8 (if you're interested in using gpu for ML) ~> requires nvidia stable drivers
# This acts as repo so install it somewhere safe and do not delete
# cuda is now available with membership only, download from https://developer.nvidia.com/cuda-release-candidate-download
sudo dpkg -i cuda-repo-ubuntu1604-9-0-local-rc_9.0.103-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda
# Update Path to have /usr/local/cuda/bin incase using dotfiles.
# <optional for ML Folks> Install CuDNN for running things like tensorflow
# Download cudnn7 for cuda9 from nvidia https://developer.nvidia.com/cudnn
sudo dpkg -i libcudnn7_7.0.2.43-1+cuda9.0_amd64.deb
# Testing cuda.
$ sudo prime-select intel
$ nvidia-smi
# This should give an error, no drivers found
# Try this
$ sudo prime-select nvidia
# displays CUDA info.
# At this point the nvidia drivers work well enough. Search for "nvidia x server settings"
# in your applications menu and you can switch between intel and nvidia PRIME profiles.
# But the nvidia card is still ON (bbswitch will report it off, but the battery consumption is (20 +- 5) Watts
# You can leave it here if you're not worried about battery but if you are then continue with this.
# Install powertop and tlp
sudo apt install tlp powertop
# Run powertop:
sudo powertop
# You should see battery discharge around 20w +/- 5W, this eats up my battery 4 times faster.
# Add command line params:
sudo nano /etc/default/grub
# Make the following look like this, do not ask why.
GRUB_CMDLINE_LINUX_DEFAULT='pcie_port_pm=off acpi_backlight=none acpi_osi=Linux acpi_osi=! acpi_osi="Windows 2009"'
sudo update-grub2
# Install bumblebee - now this is the danger zone, this software has not been updated in a while and I am not sure when will this available.
# Avoid updating your system if you're fine with this.
sudo add-apt-repository ppa:bumblebee/testing
sudo apt update
sudo apt install bumblebee bumblebee-nvidia
# at the time of writing this, the latest is nvidia-381 but cuda 8 requires the stable, which is nvidia-375
# add them to bumblebee config file.
sudo nano /etc/bumblebee/bumblebee.conf
# Change 'Driver=' to 'Driver=nvidia'
# Change all occurences of 'nvidia-current' to 'nvidia-xxx'
# Change KernelDriver=nvidia-384
# save and run
sudo service bumblebeed restart
# this should give you daemon already running
sudo bumblebeed
# Since the driver load will now be handled by bumblebee, we need to stop the OS from loading it.
sudo nano /etc/modprobe.d/bumblebee.conf
# Make the following section look like this (the drm line will be added):
#375
blacklist nvidia-384
blacklist nvidia-384-drm
blacklist nvidia-384-updates
blacklist nvidia-experimental-384
# once that is done, you'll need bbswitch dkms module
sudo apt-get install bbswitch-dkms
# Load this with the kernel.
sudo nano /etc/modules-load.d/modules.conf
# add following
i915
bbswitch
# now make sure nvidia-settings has nvidia prime profile selected.
# So what actually happened:
# The control for switching between graphics has been moved from nvidia's driver to bumblebee. This helps
# maximize battery life because now you can selectively switch between which graphics card to use. In case
# you want to provide access to nvidia gpu for the current application run it using optirun.
# e.g. if you want to run steam with nvidia gpu, run something like: $ optirun steam
# or if you're using gpu to run ml tasks, just run them with optirun and they would work just fine.
# Additional
# TLP is known to interfere with bumblebee, make it avoid using this https://wiki.archlinux.org/index.php/Talk:Bumblebee#Bumblebee_and_TLP_interferening
# Run powertop to see if battery consumption is in check: 10w +/- 5W
# Testing bumblebee
cat /proc/acpi/bbswitch # Ouput:0000:01:00.0 OFF
optirun glxgears -info # Runs the Gears demo
optirun nvidia-smi # Should give an error
sudo prime-select nvidia # Should select nvidia hardware for cuda
optirun nvidia-smi # Outputs:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.98 Driver Version: 384.98 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1050 Off | 00000000:01:00.0 Off | N/A |
| N/A 45C P0 N/A / N/A | 6MiB / 4041MiB | 2% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 13778 G /usr/lib/xorg/Xorg 6MiB |
+-----------------------------------------------------------------------------+
cat /proc/acpi/bbswitch # Still Outputs:0000:01:00.0 OFF which means, we're using nvida hardware only when we run applications using optirun
# Getting mouse freezes, random misses?
dmesg -w | grep psmouse #check if your trackpad is out of sync frequently
# Add this boot flag:
"psmouse.resetafter=0"
# Other Helpful links:
http://en.community.dell.com/techcenter/os-applications/f/4613/t/19629103
https://karlgrz.com/dell-xps-15-ubuntu-tweaks/
https://hemenkapadia.github.io/blog/2016/05/07/Ubuntu-with-Nvidia-Bumblebee.html
https://askubuntu.com/questions/879856/nvidia-prime-cant-switch-to-intel/885487
http://www.webupd8.org/2016/08/how-to-install-and-configure-bumblebee.html
#Benchmarks
==================================
GpuTest 0.7.0
http://www.geeks3d.com
Module: TessMark X64
Score: 5243 points (FPS: 87)
Settings:
- 1920x1080 windowed
- antialiasing: Off
- duration: 60000 ms
Renderer:
- GeForce GTX 1050/PCIe/SSE2
- OpenGL: 4.5.0 NVIDIA 384.98
==================================
==================================
GpuTest 0.7.0
http://www.geeks3d.com
Module: Plot3D
Score: 11340 points (FPS: 189)
Settings:
- 1920x1080 windowed
- antialiasing: Off
- duration: 60000 ms
Renderer:
- GeForce GTX 1050/PCIe/SSE2
- OpenGL: 4.5.0 NVIDIA 384.98
==================================
=================================
GpuTest 0.7.0
http://www.geeks3d.com
Module: FurMark
Score: 2670 points (FPS: 44)
Settings:
- 1920x1080 windowed
- antialiasing: Off
- duration: 60000 ms
Renderer:
- GeForce GTX 1050/PCIe/SSE2
- OpenGL: 4.5.0 NVIDIA 384.98
==================================

jwaring commented Mar 29, 2017

Hi whizzzkid,

Thank you, your gist was invaluable.

I am not particularly needing CUDA so I only installed nvidia-375. Also, I couldn't get suspend to work reliably until I installed 4.9.17 and then I had to set to the boot cmdline to GRUB_CMDLINE_LINUX_DEFAULT='acpi_osi=! acpi_osi="Windows 2009"'.

Cheers, J

nwh commented Apr 7, 2017

Thanks for this! It was very helpful. I was not able to get the system going with nvidia-378, but things worked when I downgraded to nvidia-375. I am mainly interested in CUDA development and not concerned with battery life and have modified instructions here.

rajeeja commented Apr 25, 2017

Do you have instruction for installing Ubuntu on XPS 15 9560? I want to dual boot, have a lot of stuff already installed on my windows.

Owner

whizzzkid commented Apr 27, 2017

@rajeeja there are a lot of instructions on how to dual boot, you basically turn the secure boot off and install as you would normally do. This is after you have done dual booting.

dhfromkorea commented May 10, 2017

Hi, I am running a KDE Neon Ubuntu LTS which currently appears bound to the kernel version of 4.8. Would you recommend updating my kernel to 4.9 before rolling out the instructions above?

[update] Okay, I just went ahead going through the instruction right before installing bumblebee. Everything seems working as intended so far. I am a bit hesitant to install bumblebee as you labeled it "danger zone". Would you share any advice on just how risky that move is? I am willing to manually prime-select/reboot for a while until bumblebee gets settled fine. @

SvenMeyer commented May 10, 2017

Great work! I managed to install Ubuntu MINT, but the XPS15 is still eating too much power.

  1. If I'm happy with the internal Intel grafic for my display and only want the GPU for tensorflow, etc , do I need Bumblebee? Would I even need to install the NVIDIA (display) driver?
  2. Would PRIME (https://wiki.ubuntuusers.de/Hybrid-Grafikkarten/PRIME/) be a (better) alternative?
  3. I thought I have to keep the original 16.04 / 4.4 kernel to use CUDA8 and cudnn 5.x or is this not true?

sergeevii123 commented May 14, 2017

@whizzzkid
When running on Intel gpu cursor freezes complitly after waking up from suspend.
I added psmouse.resetafter=0 to GRUB_CMDLINE_LINUX_DEFAULT but cursor still freezes.

@whizzzkid @sergeevii123 I am having the cursor issue as well...

Owner

whizzzkid commented May 17, 2017

@sergeevii123 @idoshamun did you update your bios? I had this issue 3 days after my first install, turns out bios was problematic. Next day dell released an update for the bios which fixed the annoying freezing issue. Since then there have been 2 more updates to the bios. Update and see if it fixes that for you.

Owner

whizzzkid commented May 17, 2017

@dhfromkorea @SvenMeyer bumblebee is the real deal. In my case I can selectively allow access to the apps that need nvidia gpu. e.g if I am training a keras mnist example. I can simply run:

$ python mnist_cnn.py
This takes up ~58s/epoch and 100% cpu utilization.

To run this on gpu, I just need to do (provided tensorflow was built with gpu support):

$ optirun python mnist_cnn.py
This is done in ~12s/epoch and 10% cpu utilization

Similarly I am guessing if you're using steam, you can allow steam to access your GPU using the same method. Also I use this bumblebee indicator which makes it obvious if the gpu is on or off.

@whizzzkid
You updated bios with UEFI Capsule updates?
It says here that system will auto update bios

sergeevii123 commented May 20, 2017

After bios update to 1.3 no more troubles with cursor. Thanks @whizzzkid

Sijoma commented May 21, 2017

After doing these steps, my internal graphics card is not found anymore and i can only use the nvidia

Do I have to keep the original 16.04 / 4.4 kernel to use CUDA8 and cudnn 5.x or is this not true?
Anybody tries / was successful with 4.11 kernel, as this should save additional power with NVMe SSD?

I've tried this on a Dell Inspiron 15 7559. Followed the basic recommendations, up to installing powertop. It worked fine for a few hours until I ran into the frozen mouse bug right after I woke my laptop up from suspend. Checked for a bios update on Dell's website but I am already on the latest version.
Any thoughts on what I can do?

Owner

whizzzkid commented May 24, 2017

@dhfromkorea yes, install the 4.11.2 kernel, it seems to work great. I added the instructions to install that kernel from ubuntu mainline. If you want more of a gui experience check this out: https://github.com/teejee2008/ukuu

Owner

whizzzkid commented May 24, 2017

@sergeevii123 good to know, however, since I got a copy of "free" windows, I just dual booted my system with less than 100gigs to windows. might as well try some games (I am not a gamer btw)

Owner

whizzzkid commented May 24, 2017

@Sijoma this is weird, try booting the older kernel to see if issue persists.

Owner

whizzzkid commented May 24, 2017

@SvenMeyer no, kernels after 4.10 broke nvidia drivers, it was only fixed in 4.11.1. So either use <= 4.10 or >=4.11.1

I am on 4.11.2 and it seems to be working fine.

Owner

whizzzkid commented May 24, 2017

@kjp4life probably a touchpad driver issue, I am clueless in this case.

When I followed this guide my screen was set to minimum brightness, and now I seem to be stuck on minimum brightness. My brightness buttons bring up and adjust the brightness bar in the top right as if they are working, but the brightness does not adjust. When I boot the screen is bright, but at some point during the boot sequence it dims and stays that way. Changing "acpi_backlight=none" to "acpi_backlight=vendor" in /etc/default/grub and running update-grub does not help. Any ideas?

Owner

whizzzkid commented May 24, 2017

@ihendley in the latest kernel update the backlight control is messed up again. change it back to acpi_backlight=none see this https://gist.github.com/whizzzkid/37c0d365f1c7aa555885d102ec61c048#file-xps-15-9560-getting-nvidia-to-work-on-kde-neon-L68

Thanks for the reply. I have tried both acpi_backlight=none and acpi_backlight=vendor, making sure to update-grub and reboot each time, but neither fix the issue.

For now I am able to adjust the brightness from the command line as described here

I tried adding acpi_backlight=none to the GRUB_CMDLINE_LINUX_DEFAULT string in /etc/default/grub, running sudo update-grub2 and rebooting one more time and this solved my problem. The brightness keys now correctly control my screen brightness. I don't know why this didn't work on the first try.

napgab commented May 24, 2017

i followed the guide and it seems that all is working good, but hardware acceleration is not supported with chrome and when i open a video in full screen (for example from youtube), the video freeze and lags. instead, fullscreen mode works good with firefox. am i the only one with this problem?

Owner

whizzzkid commented May 25, 2017

@ihendley you needed sudo update-grub2

@napgab try running chrome from command line: $ optirun google-chrome considering $ optirun nvidia-smi already shows the gpu info else select the nvidia card first.

napgab commented May 26, 2017

@whizzzkid i can see gpu info from optirun nvidia-smi, but if i run optirun google-chrome, it opens an empty transparent window and i have this log:

optirun google-chrome
Using PPAPI flash.
--ppapi-flash-path=/usr/lib/adobe-flashplugin/libpepflashplayer.so --ppapi-flash-version=
primus: warning: reusing initial X connection for display thread
libGL error: MESA-LOADER: failed to retrieve device information
libGL error: unable to load driver: i915_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i915
libGL error: MESA-LOADER: failed to retrieve device information
libGL error: unable to load driver: i915_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i915
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
[14815:14968:0526/115557.594092:ERROR:x11_util.cc(76)] X error received: serial 39, error_code 169, request_code 155, minor_code 6
primus: fatal: failed to acquire direct rendering context for display thread

it seems to fail during the loading of i915 driver, but i followed all the steps in the guide. i don't know what is it.

pavan71198 commented May 27, 2017

@whizzkid I'm getting unknown as return value for sudo prime-select query.
sudo prime-select nvidia is returning :
Info: selecting nvidia-375 for the nvidia profile
update-alternatives: using /usr/lib/nvidia-375/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-375/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf (x86_64-linux-gnu_egl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-375/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-375/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_EGL.conf (i386-linux-gnu_egl_conf) in manual mode

sudo prime-select intel is returning :
Info: selecting nvidia-375-prime for the intel profile
update-alternatives: using /usr/lib/nvidia-375-prime/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf (x86_64-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-375-prime/ld.so.conf to provide /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf (x86_64-linux-gnu_egl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-375-prime/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_GL.conf (i386-linux-gnu_gl_conf) in manual mode
update-alternatives: using /usr/lib/nvidia-375-prime/alt_ld.so.conf to provide /etc/ld.so.conf.d/i386-linux-gnu_EGL.conf (i386-linux-gnu_egl_conf) in manual mode

Why is it selecting nvidia-prime-375 for intel and nvidia-375 for nvidia.

@whizzkid I doubt it's the touchpad, because the whole system freezes over. I did some reading and it seems it was a bug from the previous nvidia drivers. version 381 was supposed to fix it, but to no avail. I deleted every nvidia driver and reinstalled 381, reinstalled xorg, updated my kernel to 4.11, but it seems that whatever I do, my system will wake up from suspend, work fine for a couple minutes until something triggers it to freeze. I have contemplated reinstalling from scratch but it's difficult to throw away the time I spent customizing it to my liking. Hope this adds some clarity.

Owner

whizzzkid commented May 30, 2017

@napgab you're probably missing the intel graphics drivers. Run this to install them:
$ curl -fsSL http://bit.ly/igfwl-installer | bash

@pavan71198 that's fine, it's just a copy making use of the non-nvidia drivers.

@kjp4life I am on 375, it's not a problem. Did you update the bios?

napgab commented May 31, 2017

@whizzzkid i have already installed the drivers. Also, re-installing it, the problem persist.

paines commented Jun 6, 2017

Unfortunatley the situation on Ubuntu 17.04 seems to be the same. Bubmlebee won't work, independend of notebook vendor, as e.g. nvidia-prime/prime-select cannot switch to intel, it freezes on firing up X. While the prime-select version from https://raw.githubusercontent.com/C11235/nvidia-prime-bugfix/master/prime-select offers to switch between mesa-gl and nvidia (the system default one does not even manage that) , but it still freezes too on firing up X.

e-nikolov commented Jun 7, 2017

# Install Intel Graphics Patch Firmwares (This should reboot your system):
bash -c "$(curl -fsSL http://bit.ly/IGFWL-install)"

How necessary is this part? What is wrong with the default intel graphics drivers?

SvenMeyer commented Jun 7, 2017

  1. I got an error message while installing kernel 4.11.2 (see below)
  2. Anybody tried 4.11.3 or 4.11.4 ?
  3. Can I just install 4.11.3 / 4.11.4 later or do I have to redo some of the steps following the initial kernel update again?

Error! Bad return status for module build on kernel: 4.11.2-041102-generic (x86_64)
Consult /var/lib/dkms/ndiswrapper/1.60/build/make.log for more information.

DKMS make.log for ndiswrapper-1.60 for kernel 4.11.2-041102-generic (x86_64)
Wed Jun 7 14:37:36 CEST 2017
make: Entering directory '/usr/src/linux-headers-4.11.2-041102-generic'
LD /var/lib/dkms/ndiswrapper/1.60/build/built-in.o
MKEXPORT /var/lib/dkms/ndiswrapper/1.60/build/crt_exports.h
MKEXPORT /var/lib/dkms/ndiswrapper/1.60/build/hal_exports.h
MKEXPORT /var/lib/dkms/ndiswrapper/1.60/build/ndis_exports.h
MKEXPORT /var/lib/dkms/ndiswrapper/1.60/build/ntoskernel_exports.h
MKEXPORT /var/lib/dkms/ndiswrapper/1.60/build/ntoskernel_io_exports.h
MKEXPORT /var/lib/dkms/ndiswrapper/1.60/build/rtl_exports.h
MKEXPORT /var/lib/dkms/ndiswrapper/1.60/build/usb_exports.h
MKSTUBS /var/lib/dkms/ndiswrapper/1.60/build/win2lin_stubs.h
CC [M] /var/lib/dkms/ndiswrapper/1.60/build/crt.o
CC [M] /var/lib/dkms/ndiswrapper/1.60/build/hal.o
CC [M] /var/lib/dkms/ndiswrapper/1.60/build/iw_ndis.o
CC [M] /var/lib/dkms/ndiswrapper/1.60/build/loader.o
CC [M] /var/lib/dkms/ndiswrapper/1.60/build/ndis.o
/var/lib/dkms/ndiswrapper/1.60/build/ndis.c: In function ‘NdisMIndicateReceivePacket’:
/var/lib/dkms/ndiswrapper/1.60/build/ndis.c:2261:15: error: ‘struct net_device’ has no member named ‘last_rx’
wnd->net_dev->last_rx = jiffies;
^
/var/lib/dkms/ndiswrapper/1.60/build/ndis.c: In function ‘EthRxIndicateHandler’:
/var/lib/dkms/ndiswrapper/1.60/build/ndis.c:2349:14: error: ‘struct net_device’ has no member named ‘last_rx’
wnd->net_dev->last_rx = jiffies;
^
/var/lib/dkms/ndiswrapper/1.60/build/ndis.c: In function ‘NdisMTransferDataComplete’:
/var/lib/dkms/ndiswrapper/1.60/build/ndis.c:2464:14: error: ‘struct net_device’ has no member named ‘last_rx’
wnd->net_dev->last_rx = jiffies;
^
scripts/Makefile.build:294: recipe for target '/var/lib/dkms/ndiswrapper/1.60/build/ndis.o' failed
make[1]: *** [/var/lib/dkms/ndiswrapper/1.60/build/ndis.o] Error 1
Makefile:1492: recipe for target 'module/var/lib/dkms/ndiswrapper/1.60/build' failed
make: *** [module/var/lib/dkms/ndiswrapper/1.60/build] Error 2
make: Leaving directory '/usr/src/linux-headers-4.11.2-041102-generic

fractal commented Jun 10, 2017

This list looks great, at least it seems to touch on most issues. However, i'm a bit sceptical to try it just yet given the amount of possible problems.

My main concern is around GPU / Battery usage. I only need GPU on rare occasions if I want to game or use something like Tensorflow (i'm not an ML guy, just trying to get into it). But the GPU shouldn't trash the battery.

I have a VirtualBox in windows where i'm trying an Ubuntu 17.04 to validate the config before I take the plunge. I'd rather have a working Windows 10 for the time been instead a molten battery because of the GPU always on.

Does anyone have a concise, up to date recipe to follow?

MeirBon commented Jun 14, 2017

@fractal This guide is about the best you can get. You could also install Manjaro where everything stated in this guide will be done for you, but that is Arch-based. Using Bumblebee your GPU won't drain your battery unless you use it, so everything should be fine. The only issue I have with Bumblebee is that I can't get rid of a little bit of screen tearing sometimes, but that could also be just me alone. Haven't heard anyone else about this issue.

Owner

whizzzkid commented Jun 15, 2017

@paines that should not happen :-/
@e-nikolov it'll keep bugging you always, also bumblebee would complain it couldn't get intel to switch to.
@SvenMeyer Nvidia driver builds for the current kernel only, most likely you'll need to redo everytime you update the kernel.
@fractal exactly, this resolves that. in case you want to run anything with gpu support just do $ optirun <command> else nvidia will always remain off.
@MeirBon Thanks :) I am more comfortable with debian based distros. Ubuntu sucks plain and simple, mint was good for a while but then it got weirder, kde neon is the best looking linux OS, IMO.

MajorTotem commented Jun 15, 2017

@whizzkid thanks for writing this up, previous version of this worked for me, although the newest one causes issues (i think because of the 4.11.2 kernel) with boot (x doesn't start and just freezes up) and causes some random system hangs.

I do have a question though, anybody has some experience with PRIME offloading [0] on Ubuntu / KDE Neon? I want to get rid of the tearing issues as well as use the intel card for output, because currently the nvidia proprietary drivers make XRANDR unable to scale the output display (and I'm using xrandr --scale to properly display stuff on a 1080p monitor plugged in to my 4K XPS 9560)

Anywho, thank you again for the time spent writing this up :)

[0] - http://us.download.nvidia.com/XFree86/Linux-x86_64/375.66/README/randr14.html

@whizzkid my bios is up to date. At this point I've taken a break from the issue, hoping that some new kernel update or nvidia driver update will address it. Sucks having to reboot after every session but at this point I'm out of ideas.

Owner

whizzzkid commented Jun 21, 2017

@MajorTotem you're welcome, I am on 4.11.2-041102-generic and everything seems to work. Not sure about your other issue either.

@kjp4life that's surprisingly awful. I am not sure what's the problem with reformatting the system? It's pretty simple to retain your configs and packages. I use dotfiles for most of my stuff. But kde specific configs (like ui stuff can be backed up from ~/.config and ~/.kde).

@whizzkid When I installed Ubuntu I chose to have the home partition encrypted. If I reformat it, will this cause any problems? All my important files are backed up on Google Drive, but the way I have my computer set up and the packages I have installed is what I am worried about.

e-nikolov commented Jun 23, 2017

@MeirBon Have you managed to install Manjaro on an XPS 15 9560? For me it gets stuck on the boot screen before getting into the live cd. It says "Started TLP system startup/shutdown" and just stays there forever.

Owner

whizzzkid commented Jun 26, 2017

@kjp4life use this approach to backup a list of installed packages and restoring them later: https://askubuntu.com/a/99151

For anyone who might be having suspend issues on kernel 4.12, I had to edit the follow line:

Make the following look like this, do not ask why.

--
  | GRUB_CMDLINE_LINUX_DEFAULT='pcie_port_pm=off acpi_backlight=none acpi_osi=Linux acpi_osi=! acpi_osi="Windows 2009"'

removing the "acpi_osi=Linux" portion.

I'm currently using kernel 4.11.8 which works fine and gives me ~ 8.5 W before installing Nvidia driver.
I had problems with lspci freezing and timeout when shutting down, but GRUB_CMDLINE_... option solved that.
I noticed that kernel 4.12.0 did not need GRUB_CMDLINE_... options to fix that, but idle power rose to ~ 15.5 W with that kernel.
So, no reason to try kernel 4.12 ?

SvenMeyer commented Jul 13, 2017

is this the right code?
acpi_osi=! acpi_osi="Windows 2009"
elsewhere I always saw
acpi_osi="!Windows 2009"
which supposes to remove the 'Windows 2009' key

Hey, thanks for the guide @whizzzkid. It's been well helpful. I followed it almost to a tee and got really great results. I'm having a rather strange problem though and would like your insight.

From time to time I get a black screen just before the Ubuntu login screen. I even hear that nice little double drum sound, but the screen stays blank.

It seems to me that there is some sort of mislead of the drivers. I have spent hours trying to figure this out. It's super weird because it'll not happen for a few restarts and then suddenly give me grief trying to log in and I have to force reset several times. Sometimes if I'm having no luck I have to add "nouveau.modeset=0" to the grub load file.

Anybody got any clues?

sevko commented Sep 1, 2017

FYI, the Intel firmware installation script at http://bit.ly/IGFWL-install seems broken. It creates an fw directory in your current directory, and then cds into /tmp/ and expects to find the fw directory there, which causes all of the tar commands to fail. If run as is, the installation steps will fail and you probably won't notice because the script immediately reboots your machine.

Donwey commented Sep 8, 2017

sevko, Any solution on this please?

Owner

whizzzkid commented Sep 8, 2017

@sevko and @Donwey for some reason short links do not point at the right version of the gist. Here try this

bash -c "$(curl -fsSL https://gist.githubusercontent.com/whizzzkid/d5f9491cd60f09be51920e973a60e401/raw/fe038b61617fe91ac276d8b3c4041e7e0df962a0/IGFWL.sh)"

Or this

curl -o- http://bit.ly/igfwl-installer | bash

hlavki commented Sep 15, 2017

Hi, thanks for this. I am running openSUSE tumbleweed and it looks like it works, but if I run optirun glxspheres on HiDPi and change to resize to fullscreen, than FPS is 44. Its slower than intel.

Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)
Visual ID of window: 0x21
Context is Direct
OpenGL Renderer: GeForce GTX 1050/PCIe/SSE2
208.091512 frames/sec - 298.622997 Mpixels/sec
46.062645 frames/sec - 357.829368 Mpixels/sec
44.692185 frames/sec - 347.183198 Mpixels/sec
44.929472 frames/sec - 349.026516 Mpixels/sec
44.540262 frames/sec - 346.003007 Mpixels/sec

optirun nvidia-smi

Fri Sep 15 11:49:00 2017       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.69                 Driver Version: 384.69                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1050    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   34C    P0    N/A /  N/A |      6MiB /  4041MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0     18941    G   Xorg                                             6MiB |
+-----------------------------------------------------------------------------+

Do you also have this problem? Thank you

hlavki commented Sep 15, 2017

And also you can use boot options:

acpi_rev_override=5 acpi_backlight=none

instead of

pcie_port_pm=off acpi_backlight=none acpi_osi=Linux acpi_osi=! acpi_osi="Windows 2009"

Owner

whizzzkid commented Sep 16, 2017

@hlavki Here is the output for:

$ optirun glxgears
14096 frames in 5.0 seconds = 2819.109 FPS
11460 frames in 5.0 seconds = 2290.427 FPS
$ optirun ./glxspheres64
Polygons in scene: 62464 (61 spheres * 1024 polys/spheres)
Visual ID of window: 0x21
Context is Direct
OpenGL Renderer: GeForce GTX 1050/PCIe/SSE2
347.675228 frames/sec - 388.005555 Mpixels/sec
358.998031 frames/sec - 400.641803 Mpixels/sec
351.300209 frames/sec - 392.051033 Mpixels/sec
356.592040 frames/sec - 397.956717 Mpixels/sec
359.251480 frames/sec - 400.924652 Mpixels/sec
350.943396 frames/sec - 391.652830 Mpixels/sec
356.542326 frames/sec - 397.901236 Mpixels/sec
357.434807 frames/sec - 398.897245 Mpixels/sec
347.815407 frames/sec - 388.161995 Mpixels/sec
$ optirun nvidia-smi
Fri Sep 15 18:38:17 2017
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.69                 Driver Version: 384.69                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1050    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   35C    P0    N/A /  N/A |      6MiB /  4041MiB |      2%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|    0     30920    G   /usr/lib/xorg/Xorg                               6MiB |
+-----------------------------------------------------------------------------+

hlavki commented Sep 19, 2017

@whizzzkid thanks for reply. Can you please try to run:

optirun glxgears -fullscreen

I am getting low FPS:

227 frames in 5.0 seconds = 45.246 FPS
238 frames in 5.0 seconds = 47.571 FPS
235 frames in 5.0 seconds = 46.935 FPS
237 frames in 5.0 seconds = 47.285 FPS

When i run optirun it says
[ 200.660549] [ERROR]No bridge found. Try installing primus or virtualgl.
I am using linux mint 18 with nvidia 940MX kernel 4.13.

Moulick commented Sep 26, 2017

@whizzzkid Thank You. After Trying dozens of tutorials all over the internet, your's is the only one that worked reliably. I am so thankful to you for finally getting my GPU properly running selectively. I had very nearly given up on Linux and moved back to windows before your Gist solved everything.

mark-bucknell commented Sep 29, 2017

I found that after I did this with 4.11 it worked fine but once I rebooted I got AHCI errors and cant use anything but my onboard graphics. Any suggestions?
I am temped to give 4.13 a go.

Further Details:
Ubuntu 16.04
Kernel: 4.11.2-041102-generic

Error on boot (doesn't stop booting)
ACPI Error: Namespace lookup failure, AE_NOT_FOUND.

Then when I attempt to shut down I get:
NMI watchdog: BUG: soft lockup - CPU#1 stuck....

I am keen to know what BIOS version everyone has.. I am running on v1.2.4 and im not sure if I need to upgrade or if that will cause me more headaches.

@whizzzkid

@mark-bucknell I am getting the same errors, pls let me know if you find a solution. Also I have tried Manjaro, solus, Ubuntu 17:10, Elementary as well getting same errors on everyone.

@bajubullet no such luck but I am keeping an eye on this thread

Owner

whizzzkid commented Nov 2, 2017

Sorry guys, I was away. Also I noticed, there was an update for nvidia-384 yesterday, I am not sure what it's supposed to do but it did not mess up anything.

Let me respond to you one by one:

@hlavki
Here is the output:

$ optirun glxgears -fullscreen
1035 frames in 5.0 seconds = 206.857 FPS
953 frames in 5.0 seconds = 190.546 FPS
1017 frames in 5.0 seconds = 203.210 FPS
1010 frames in 5.0 seconds = 201.939 FPS
1012 frames in 5.0 seconds = 202.285 FPS

@rjcrystal
During my initial setup I started by installing mint, and it had too much stuff missing, ubuntu sucked too. KDE Neon looked like the best contender as it had most of the stuff working out of the box. I am not sure what the error here is but do post if you find a solution, btw primux should have been installed when installing bumblebee.

@Moulick
thanks :)

@mark-bucknell
As far as I remember I was having problems with 4.11, I moved to 4.13 already. I am on 4.13.0-041300-generic also I am on bios 1.4 planning to go to 1.5 soon

So I just did the dell bios upgrade from v1.2.4 to 1.4.0 and I followed everything down to line 23. All looks good. I am now able to support 3 monitors (just) and the error message on shut down has gone. I still have an error message showing on startup but I know that is something to do with the linux kernel and ACPI so I'll wait for updates that will fix that.
@whizzzkid thankyou for maintaining this gist

Hi,
Just to let you know, I have followed this tutorial a month ago when I have received my laptop.

I am using it daily with Kubuntu 16.04 + backports to get Plasma 5.08, Bios 1.5, Linux 4.13.8, Nvidia 387, Bumblebee...

I have about 7W in powertop on IDLE.

Options in GRUB:

acpi_rev_override=1 pcie_port_pm=off

Everything is fine, so thank you so much!

Owner

whizzzkid commented Nov 12, 2017

@mark-bucknell: good for you!

@romainreignier: cheers :) I am still on Driver Version: 384.98 because CUDA9.

dhfromkorea commented Nov 13, 2017

I seek advice from you wise folks. I am having a hard time making this installation work with nvidia 384 (with cuda 8.0 ga_2 and libcudnn 6.0 on KDE Neon LTS 16.04) It seems kde neon does not like it atm because of this bug[1]

I tried rolling back to nvidia 375, but apt-get won't let me because 375 is a transitional version and automatically force-enable nvidia 384.

I tried installing nvidia 381, instead of 384, but cuda 8.0 deb installation forces -> nvidia 384.

Do you have any advice for a workaround I may try?

Also a dumb question--Is updating the kernel to 4.13 required for getting nvidia.384 to work?
[1] https://blog.martin-graesslin.com/blog/2017/08/warning-nvidia-driver-384-69-seems-to-be-broken-with-qtquick/

Owner

whizzzkid commented Nov 16, 2017

@dhfromkorea with this setup you will not be loading nvidia drivers when normally using the system. That bug is a problem when you're explicitly loading nvidia drivers at boot. Since this setup does not do that and instead loads them only when running a program with optirun it shouldn't be a problem.

This is probably a dumb question, but what does bumblebee do? It sounds like it allows optionally use the nvidia card--ie take the output of the nvidia card and route it to the intel graphics unit. Why would you want to do this? Just for power savings or it there something else?

Thanks

great gist @whizzzkid ! Many thanks.
After a lot of effort, black screens with no proper display adapter and reinstalls, I finally managed to get it properly working. For me, what was missing from the whole gist and caused trouble was sudo apt-get install primus. It gave me an errors something like "proper bridge missing".

Also, very useful for ML folks: Since you can run only what you need in your GPU, tensorflow and other ML and DL libraries are now faster than ever 👍
Just type optirun jupyter notebook and you are ready to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment