Skip to content

Instantly share code, notes, and snippets.

@hemenkapadia
Last active May 2, 2023 20:44
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save hemenkapadia/630aef11a8ea51286777 to your computer and use it in GitHub Desktop.
Save hemenkapadia/630aef11a8ea51286777 to your computer and use it in GitHub Desktop.
[Ubuntu 14.04 on Optimus Laptop] Setting up Ubuntu 14.04 with nvidia drivers and CUDA on Dell 7559 Optimus laptop #Ubuntu #Nvidia #CUDA #setup
### NOTE ###
The below gist is converted to a blog post and available at below link. Refer that instead.
http://hemenkapadia.github.io/blog/2016/11/11/Ubuntu-with-Nvidia-CUDA-Bumblebee.html
#### Note about kernel versions ####
Between kernel versions 4.2 and 4.4 there are different options that need to bet set
to get this working. The same is highlighted below when necessary. I have not tested
version 4.3 so not sure which of the two settings work, in which case try either one.
#### GRUB settings during install and first restart ####
Add the follwoing kernel options just before `quiet splash` in the GRUB boot
menu while trying to install using a live USB and the very first start of the
machine post installation.
```
kernel 4.2 - nomodeset i915.modeset=1
kernel 4.4 - nomodeset i915_bpo.modeset=1
```
#### Make the GRUB settings persistent ####
To avoid updating the kernel options each time the system is booted, update the
GRUB settings as below, based in your Ubuntu version
`sudo vi /etc/default/grub`
kernel 4.2 - `GRUB_CMDLINE_LINUX_DEFAULT="nomodeset i915.modeset=1 quiet splash`
kernel 4.4 - `GRUB_CMDLINE_LINUX_DEFAULT="nomodeset i915_bpo.modeset=1 quiet splash`
For High DPI or Retina displays GRUB boot menu options are not readable as the font size
is too small. It can be fixed by the below two options
```
GRUB_GFXMODE=1280x1024
GRUB_GFXPAYLOAD_LINUX=keep
```
Set Windows as the default system to boot
> This setting specific to my laptop, replace accordingly with the Windows label for your
> system
`
GRUB_DEFAULT="Windows Boot Manager (on /dev/sda1)"
`
Apply the changes made to `/etc/default/grub` file
`sudo update-grub2`
#### Scaling of the Unity UI ####
This issue is only observed on HighDPI or Retina displays on 15.10. It was not experienced on 16.04
In Unity search for Display and open it. Drag the slider for
'Scale for menu and title bars:' to 2 (or any other depending in your display).
Apply the setting.
#### Scaling of Virtual Console fonts ####
On High DPI or Retina displays fonts on the Virtual Console are very small making it difficult
to read. to fix this issue, first create the configuration
`sudo dpkg-reconfigure console-setup`
select the following options
```
Encoding - UTF-8
Character Set - . Combined - Latin; Salvic Cyrillic; Greek
Font for console - Terminus
Font Size - 16x32
```
Next edit `/lib/systemd/system/console-setup.service` and in `[Service]`
section add `ExecStart=/bin/setupcon` to the bottom of the section.
Next edit `/etc/init/console-setup.conf` and add `exec /bin/setupcon` to the bottom of the file
This causes `/bin/setupcon` command to run each time on boot, applying the settings
configuredearlier modifying the console as per elected settings.
If any time virtual console is showing tiny fonts (e.g. in recovery mode) run `/bin/setupcon`
and it will fix the console.
#### Mouse pointer size ####
This issue was experienced on 15.10, but not experienced on 16.04. On High DPI or
Retina displays the mouse pointer appears considerably small in size.
Add the setting `Xcursor.size: 48` in `/etc/X11/Xresources/x11-common`
#### Conflicting/Changing time on dual boot Linux and Windows ####
this no longer is valid in 16.04
In BIOS ensure the hardware clock time is set as per UTC time. Refer to the
documentation of appropriateBIOS on how this needs to be done.
Add/Update the UTC setting in `/etc/default/rcS` to be `UTC=yes`
#### Maximum brightness ####
This issue is noticed in 15.10 and 16.04 was weell, but in 16.04 the brightness level
seems to persist once chnaged manually. This was not the case in 15.10
> Note the path of the file is dependent on your graphics card.
Fix is to add the following line above the `exit 0` line in
`/etc/rc.local` (note above exit 0)
`echo 339 > /sys/class/backlight/intel_backlight/brightness`
To get the desired number (339 in the above case), adjust brightness to the desired
level and issue comment to get the required number
`cat /sys/class/backlight/intel_backlight/brightness`
#### Restart ####
Restart your system and verify that above points are working as expected.
# Configure nvidia, bumblebee #
1. Restart the machine
2. Switch to Vconsole
3. sudo service lightdm stop (to stop the x server)
4. Remove any existing installs of nvidia, nouveau etc.
```
sudo apt-get remove --purge nvidia*
sudo apt-get remove --purge bumblebee*
sudo apt-get --purge remove xserver-xorg-video-nouveau
for 14.04.4 LTS the xservers were
xserver-xorg-video-all-lts-wily
xserver-xorg-video-nouveau-lts-wily
```
5. Blacklist nouveau drivers `sudo vi /etc/modprobe.d/blacklist.conf`
Add the following lines to the file
```
# Blacklisting nouveau to get nvidia running with bumblebee
blacklist nouveau
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off
options nouveau modeset=0
```
6. Disable gpu-manager.service for both systemctl as well as init
```
sudo systemctl mask gpu-manager.service
sudo vi /etc/init/gpu-manager.conf
```
```
# Comment these start on settings ; GPU Manager ruins our work
#start on (starting lightdm
# or starting kdm
# or starting xdm
# or starting lxdm)
task
exec gpu-manager --log /var/log/gpu-manager.log
```
7. Create initramfs `sudo update-initramfs -u -k all`
NOTE - something happened here and lightdm was not starting. vconsle was woring
in vconsole if i put sudo service lightdm start it was starting.
To fix it is ran the command
sudo dpkg-reconfigure lightdm
8. Reboot the system and verify that nouveau is successfully blacklisted. The below command
should not return any lines with the word nouveau in it.
```
lsmod | grep nouveau
```
9. Check if gpu-manager.service is disabled
```
sudo systemctl status gpu-manager.service
```
Ubuntu nvidia drivers seems to install 361. To try 352 drivers i need to add the graphics-drivers ppa
sudo apt-add-repository pps:graphics-drivers/ppa
sudo apt-get update
sudo apt-cache policy nvidia-352
Note the selected package next to the Candidate option. It picks the version from Ubuntu repositories which then link to nvidia-361. To use the
nvidia-352 we need to pin this to the graphics driver ppa
Create a file /etc/apt/preferences with the contents
Package: nvidia-352 libcuda1-352 nvidia-opencl-icd-352
Pin: origin ppa.launchpad.net
Pin-Priority:600
sudo apt-get update
sudo apt-cache policy nvidia-352 (notice that the candidate would now change to the pp one)
10. Install nvidia drivers
```
sudo service lightdm stop (in vconsole)
sudo apt-get install --no-install-recommends nvidia-361
sudo apt-get install libcuda1-361 nvidia-opencl-icd-361
sudo apt-get install --no-install-recommends bumblebee
sudo apt-get install bumblebee-nvidia primus
sudo apt-get install mesa-utils
```
```
12. Add the following two lines to the `/etc/modules-load.d/modules.conf` file
```
# for kernel 4.2, use below two lines
i915
bbswitch
#for kernel 4.4, use the below two lines
i915_bpo
bbswitch
```
13. Blacklist nvidia from loading, its insertion and removal from the kernel
will be handled by bbswitch. Add the following lines to `/etc/modprobe.d/bumblebee.conf`.
```
# 352
blacklist nvidia-352
blacklist nvidia-352-updates
blacklist nvidia-experimental-352
#361
blacklist nvidia-361
blacklist nvidia-361-updates
blacklist nvidia-experimental-361
```
14. Bumblebee configuration
```
sudo vi /etc/bumblebee/bumblebee.conf
## Configuration file for Bumblebee. Values should **not** be put between quotes
[bumblebeed]
VirtualDisplay=:8
KeepUnusedXServer=false
ServerGroup=bumblebee
TurnCardOffAtExit=false
NoEcoModeOverride=false
Driver=nvidia
XorgConfDir=/etc/bumblebee/xorg.conf.d
## Client options. Will take effect on the next optirun executed.
[optirun]
Bridge=primus
VGLTransport=proxy
PrimusLibraryPath=/usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus
AllowFallbackToIGC=false
## Section with nvidia driver specific options, only parsed if Driver=nvidia
[driver-nvidia]
KernelDriver=nvidia-361
PMMethod=bbswitch
LibraryPath=/usr/lib/nvidia-361:/usr/lib32/nvidia-361
XorgModulePath=/usr/lib/nvidia-361/xorg,/usr/lib/xorg/modules
XorgConfFile=/etc/bumblebee/xorg.conf.nvidia
## Section with nouveau driver specific options, only parsed if Driver=nouveau
# [driver-nouveau]
# KernelDriver=nouveau
# PMMethod=auto
# XorgConfFile=/etc/bumblebee/xorg.conf.nouveau
sudo vi /etc/bumblebee/xorg.conf.nvidia
Section "ServerLayout"
Identifier "Layout0"
Option "AutoAddDevices" "false"
Option "AutoAddGPU" "false"
EndSection
Section "Device"
Identifier "DiscreteNvidia"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:02:00:0"
Option "ProbeAllGpus" "false"
Option "NoLogo" "true"
Option "UseEDID" "false"
Option "UseDisplayDevice" "none"
EndSection
sudo vi /etc/X11/xorg.conf
Section "ServerLayout"
Identifier "layout"
Screen 0 "intel"
Inactive "nvidia"
EndSection
Section "Device"
Identifier "intel"
Driver "intel"
BusID "PCI:00:02:0"
Option "AccelMethod" "SNA"
EndSection
Section "Screen"
Identifier "intel"
Device "intel"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:02:00:0"
Option "ConstrainCursor" "off"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
Option "AllowEmptyInitialConfiguration" "on"
Option "IgnoreDisplayDevices" "CRT"
EndSection
```
13. Update alternatives
```
sudo update-alternatives --config x86_64-linux-gnu_gl_conf (select mesa)
11. Enable bumblebee daemon
```
sudo systemctl enable bumblebeed`
TODO - shoudl we also do for gnu_egl, i386_linux_gl_conf and egl too ? TODO yes i did everything in this comment https://github.com/Bumblebee-Project/Bumblebee/issues/759
sudo ldconfig
sync
generate initramfs
sudo systemctl
sudo usermod -a -G bumblebee $USER
exit (from the vconsole and then again come in)
optirun -b primus -vv glxinfo | grep OpenGL (should show Nvidia)
glxinfo | grep OpenGL (should show intel)
glxgears -info (shows intel)
optirun -b primus -vv glxgears -info | grep OpenGL
```
14. Reboot the system
15. Testing everything
```
optirun -b primus -vv glxinfo | grep OpenGL (should show Nvidia)
glxinfo | grep OpenGL (should show intel)
glxgears -info (shows intel)
optirun -b primus -vv glxgears -info | grep OpenGL
In another termial, while optirun commands are executed, use the below commeand to see
bbswitch getting on and off when nvidia is in action
cat /proc/acpi/bbswitch
Also see lsmod to see that nvidia drivers are getting inserted and removed from the kernel
```
everything worked by glxinfo was showing vmware string to installed xserver-xorg-video-intel-lts-wiley and then generated ramfs
restarts
that took care of it
@riot83
Copy link

riot83 commented Mar 20, 2016

Thanks for that! Do you may seem the same Issue that when Strike Ctrl+Alt+F1 it doesnt change to terminal? Same for F2 and F3. F4 brings to terminal but after that you are not able to get back to GUI. Didnt found a solution or the Root Cause for yet, may you have one

@hemenkapadia
Copy link
Author

hemenkapadia commented Apr 24, 2016

No i never encountered such a problem, Alt+Ctrl+F1 to F5 (did not check everything) does take me to the virtual console. To get back to X GUI use Alt+Ctrl+F7

@hemenkapadia
Copy link
Author

@burakkavak
Copy link

thanks alot, had so much headache installing ubuntu but this finally made me succeed

@ademcal
Copy link

ademcal commented Jul 8, 2016

thank you very much can you add for sound guide because Ubuntu doesn't automatically subwoofer or speaker.

@btantlinger
Copy link

Great work on this gist. Unfortunately, the Inspiron 7559 still isn't fit for Linux as the CPU can't get into low power states. If you check under powertop, you'll notice under the idle stats that the CPU can't get past C3. This causes the fans to run all the time, higher temps, and poor battery life. It might also shorten the life of the CPU. See https://mjg59.dreamwidth.org/41713.html

There's a bug report about it here: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1602888

@hemenkapadia
Copy link
Author

OK so I updated my working Ubuntu today and 4.4 kernel got installed - and the display is not working any more...back to work

@hemenkapadia
Copy link
Author

@btantlinger - yeah i have started noticing the CPU fan constant running thing ever since I followed the process mentioned at http://hemenkapadia.github.io/blog/2016/05/07/Ubuntu-with-Nvidia-Bumblebee.html to get my system up and running after 14.04.5 HWE update to 4.4 kernel ruined it.

Surprisingly, when things were working fine before - i had done some thing with i8kmon to handle things -- but I have lost those settings.

Will need to setup the system again - and hopefully have one more gist

@hemenkapadia
Copy link
Author

hemenkapadia commented Sep 10, 2016

Here is my powertop screenshot. I am in the higher Cstates which IMHO is a good sign. I admit i do not know enough about this...Is there are problem ?

          Package   |             Core    |            CPU 0       CPU 4
Powered On  0.0%    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
C1E-SKL     0.5%    | C1E-SKL     0.7%    | C1E-SKL     0.2%    0.5 ms  1.3%    2.8 ms
                    |                     |
C3-SKL      0.2%    | C3-SKL      0.6%    | C3-SKL      0.1%    0.4 ms  1.1%    2.3 ms
RC6pp       0.0%    | C6-SKL      1.7%    | C6-SKL      2.7%    1.4 ms  0.7%    0.5 ms
C7s-SKL     0.1%    | C7s-SKL     0.1%    | C7s-SKL     0.2%    2.5 ms  0.1%    2.9 ms
C8-SKL     18.0%    | C8-SKL     15.9%    | C8-SKL     24.0%    3.0 ms  7.7%    5.3 ms
C10-SKL    69.2%    | C10-SKL    70.4%    | C10-SKL    57.3%   13.7 ms 83.6%   21.6 ms

@jaimesx
Copy link

jaimesx commented Sep 23, 2016

I followed all your instructions for Ubuntu 16.04.1 with Linux Kernel 4.8-rc7, however I got this error: "... (EE) Failed to load module "mouse" (module does not exist, 0)...", I've found this modification works:

Adding to /etc/bumblebee/xorg.conf.nvidia:

Section "Screen"
  Identifier "Default Screen"
  Device "DiscreteNvidia"
EndSection

Source: http://askubuntu.com/questions/788532

Copy link

ghost commented Oct 21, 2016

@hemenkapadia See no PC states at your powertop output. Compare with http://farm9.staticflickr.com/8555/8836669260_df4c8930fe.jpg for example (package column)

@hemenkapadia
Copy link
Author

DO NOT REFER TO THE ABOVE GIST.

A better approach is documented at http://hemenkapadia.github.io/blog/2016/11/11/Ubuntu-with-Nvidia-CUDA-Bumblebee.html

@H21lab
Copy link

H21lab commented May 22, 2018

Don't upgrade to Ubuntu 18 LTS on Dell Inspiron 7559. There are problems with both Intel and Nvidia card. The only solution for me was to reinstall back Ubuntu 16.04 LTS.

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