Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Making Nvidia Drivers + CUDA 8 + Bumblebee work together on XPS 15 Early 2017 9560 kabylake.
# Update to 4.9 kernel do not delete the old kernel as it will be your failsafe if something happens to this one
# 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/; 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
# Update Path to have /usr/local/cuda/bin incase using dotfiles.
# <optional> Install CuDNN for running things like tensorflow
# Download cudnn from nvidia
tar -xvzf cudnn-8.0-linux-x64-v6.0.tgz
sudo cp -r cuda/* /usr/local/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"
# 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