Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marchelbling/14bf4157889e87eaecfd5834339e5163 to your computer and use it in GitHub Desktop.
Save marchelbling/14bf4157889e87eaecfd5834339e5163 to your computer and use it in GitHub Desktop.
Making Nvidia Drivers + CUDA 8 + Bumblebee work together on XPS 15 Early 2017 9560 kabylake.
1. disable secure boot
2. clean install windows (see https://www.reddit.com/r/Dell/comments/5qe3oh/how_to_fresh_install_on_xps_15_9560/)
2.1 in case usb does not show on boot: http://www.dell.com/support/article/us/en/19/SLN297060/xps-13-9343--how-to-install-ubuntu-developer-edition-1404-on-a-dell-pc-configured-for-the-unified-extensible-firmware-interface--uefi--bios?lang=EN
# Update kernel (is this mandatory?)
( mkdir /tmp/kernel-4.10.6
cd /tmp/kernel-4.10.6
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.6/linux-headers-4.10.6-041006_4.10.6-041006.201703260832_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.6/linux-headers-4.10.6-041006-generic_4.10.6-041006.201703260832_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.10.6/linux-image-4.10.6-041006-generic_4.10.6-041006.201703260832_amd64.deb
sudo dpkg -i *.deb )
# Install KabyLake graphics patches
( cd /tmp;
wget https://01.org/sites/default/files/downloads/intelr-graphics-linux/kbldmcver101.tar.bz2;
tar xjvf kbldmcver101.tar.bz2; cd kbl_dmc_ver1_01/; sudo ./install.sh )
( cd /tmp;
wget https://01.org/sites/default/files/downloads/intelr-graphics-linux/kblgucver914.tar.gz;
tar xvzf kblgucver914.tar.gz; cd firmware/kbl/guc/kbl_guc_ver/; chmod a+x install.sh; sudo ./install.sh )
# Add Nvidia repository
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
# Install via ubuntu drivers
sudo ubuntu-drivers autoinstall
# Install CUDA 8 (if you're interested in using gpu for ML)
# This acts as repo so install it somewhere safe and do not delete
cd ~/Downloads
wget https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64-deb
sudo dpkg -i cuda*.deb; sudo apt update; sudo apt install cuda
# The version of prime-select is BS. Patch prime select like this
cd /usr/bin
mv prime-select prime-select.bkup
sudo wget https://raw.githubusercontent.com/C11235/nvidia-prime-bugfix/master/prime-select
sudo chmod 755 prime-select
sudo reboot now
# 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.
# 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=vendor 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
# Add yourself to the bumblebee usergroup so you can make changes to the videocard.
sudo adduser $USER bumblebee
# Enable bumblebee service
sudo systemctl enable bumblebeed
# now you need to load the right driver in bumblebee because it's an old piece of software which has not been updated in a whie
# to know the nvidia driver currently loaded. Run:
lsmod | grep nvidia
# this should give you something like, nvidia-xxx
# at the time of writing this, the latest is nvidia-378 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'
# 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
# add a new entry toward the end, with nvidia-xxx, in my case:
# nvidia-375
#375
blacklist nvidia-375
blacklist nvidia-375-drm
blacklist nvidia-375-updates
blacklist nvidia-experimental-375
# 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
# 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:
Mon Feb 20 21:51:18 2017
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.39 Driver Version: 375.39 |
|-------------------------------+----------------------+----------------------+
| 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 | 0000:01:00.0 Off | N/A |
| N/A 41C P3 N/A / N/A | 6MiB / 4041MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 3351 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"
# trackpad:
https://www.reddit.com/r/Dell/comments/60a907/xps_15_9560_from_the_box_to_productivity_how_i/ + https://github.com/rcasero/doc/wiki/Ubuntu-linux-on-Dell-XPS-15-(9560)#touchpad
sudo apt-get install xserver-xorg-input-libinput
sudo apt-get remove --purge xserver-xorg-input-synaptics
sudo reboot
sudo mkdir /etc/X11/xorg.conf.d
cat """Section "InputClass"
Identifier "libinput"
Driver "libinput"
MatchDevicePath "/dev/input/event*"
MatchIsTouchpad "true"
Option "Tapping" "True"
Option "TappingDragLock" "True"
Option "PalmDetection" "True"
Option "ButtonMapping" "1 3 2"
Option "DisableWhileTyping" "True"
Option "NaturalScrolling" "False"
Option "AccelProfile" "adaptive"
Option "AccelSpeed" "0.1"
Option "ClickMethod" "clickfinger"
Option "MiddleEmulation" "True"
Option "ScrollMethod" "twofinger"
Option "HorizontalScrolling" "True"
Option "SendEventsMode" "disabled-on-external-mouse"
EndSection
""" > /etc/X11/xorg.conf.d/30-touchpad.conf
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment