Skip to content

Instantly share code, notes, and snippets.

@hemenkapadia
Last active May 1, 2016 04:41
Show Gist options
  • Select an option

  • Save hemenkapadia/1f5e1a075ab7fd1738cf to your computer and use it in GitHub Desktop.

Select an option

Save hemenkapadia/1f5e1a075ab7fd1738cf to your computer and use it in GitHub Desktop.
Ubuntu_High DPI configuration
#### 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="i915.modeset=1 nomodeset quiet splash`
kernel 4.4 - `GRUB_CMDLINE_LINUX_DEFAULT="nouveau.modeset=0 nomodeset 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.
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 ####
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
```
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. Create initramfs `sudo update-initramfs -u -k all`
7. Disable gpu-manager.service for both systemctl as well as init
```
sudo systemctl disable 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
```
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
```
10. Install nvidia drivers
```
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 mesa-utils
```
11. Enable bumblebee daemon
```
service sudo systemctl enable bumblebeed`
```
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 "Screen"
Identifier "intel"
Device "intel"
EndSection
Section "Screen"
Identifier "nvidia"
Device "nvidia"
Option "AllowEmptyInitialConfiguration" "on"
Option "IgnoreDisplayDevices" "CRT"
EndSection
Section "Device"
Identifier "intel"
Driver "intel"
BusID "PCI:00:02:0"
Option "AccelMethod" "SNA"
EndSection
Section "Device"
Identifier "nvidia"
Driver "nvidia"
BusID "PCI:02:00:0"
Option "ConstrainCursor" "off"
EndSection
```
13. Update alternatives
```
sudo update-alternatives --config x86_64-linux-gnu_gl_conf (select mesa)
sudo ldconfig
sync
```
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
```
#####################################################3
Updates needed on getting Ubuntu to work on very High resolution displays.
Follow setups in the https://gist.github.com/hemenkapadia/630aef11a8ea51286777 to ensure that the initial setup is working fine
1. use the below command to generate the xorg.conf file
Alt+Ctrl+F1 to go to virtual console
sudo service lightdm stop
sudo X -configure
This will create xorg.conf.new file in home directory
3. We do not want nouveau drivers - we will use nvidia drivers. So lets remove them
sudo apt-get remove --purge nvidia*
sudo apt-get remove --purge bumblebee*
sudo apt-get --purge remove xserver-xorg-video-nouveau
sudo cp /etc/modprobe.d/blacklist.conf /etc/modprobe.d/blacklist.conf.bak
sudo gedit /etc/modprobe.d/blacklist.conf
Add the following lines to blacklist.conf
# Blacklisting nouveau to get nvidia running with bumblebee
blacklist nouveau
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off
options nouveau modeset=0
Save the file and then update the initramfs
sudo update-initramfs -u -k all
Restart the system. Use the below command to check if nouveaue is successfully blacklisted
lsmod | grep nouveau
If it does not list nouveau then it means that nouveau driver is not loaded
4. Now install Nvidia drivers
I tried the following methods to install nvidia 352 drivers. The Software center in ubuntu and also using apt-get install nvidia-352. In both these methods by following the below steps
Use software center to install so that the same can be updated.
Start Software Center and then click Edit > Software Sources
In the new window that opens select Additional Drivers, and from there i installed nvidia 352.63 driver
To check what was installed
hemen@hemen-7559-linux:~$ sudo dpkg -l | grep nvidia
ii nvidia-352 352.63-0ubuntu0.15.10.1 amd64 NVIDIA binary driver - version 352.63
ii nvidia-opencl-icd-352 352.63-0ubuntu0.15.10.1 amd64 NVIDIA OpenCL ICD
ii nvidia-prime 0.8.1 amd64 Tools to enable NVIDIA's Prime
ii nvidia-settings 352.21-0ubuntu1 amd64 Tool for configuring the NVIDIA graphics driver
hemen@hemen-7559-linux:~$
Based on my usage I do not want PRIME to be enabled. I want the machine to run predominantly on Intel chip with selected programs to run using Nvidia chip. So i go ahead and removed prime
sudo apt-get remove --purge nvidia-prime
5. Installing bumblebee
Bumblebee uses either virtuagl or primus to copy the frame buffers from Nvidia GPU to the intel GPU, we can use either of the techniques, but it seems primus is becoming the defacto standard for the same.
http://www.webupd8.org/2012/11/primus-better-performance-and-less.html
https://wiki.archlinux.org/index.php/Bumblebee#Primus_issues_under_compositing_window_managers
Also I am not sure if i will need to use optirun with 32bit of 64 bit application so i am including everything
sudo apt-get install bumblebee bumblebee-nvidia primus
sudo systemctl enable bumblebeed
2) Add the following lines to the /etc/modules-load.d/modules.conf file
i915
bbswitch
fter doing all this and rebooting the system things worked ok. i also confirmed the working of bbswitch such that whenever optirun was executed the value in /proc/acpi/bbswitch changed to ON and once that completed it became OFF.
The problem encountered each time is that once i run glxgears using optirun on the next subsequent reboot the x server starts in low performance mode.
#################### So trying a different approach this time.
This time we will try the nvidia 358 driver from https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa instead of the nvidia-352.
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-358
This time i will not purge prime.
sudo apt-get install bumblebee bumblebee-nvidia
sudo systemctl enable bumblebeed
also verify that you userid is in the bumblebee group
cat /etc/group and see that you user id is in the same line as bumblebee
2) Add the following lines to the /etc/modules-load.d/modules.conf file
i915
bbswitch
3. ensure that nvidia driver version is blacklisted from loading /etc/modprobe.d/bumblebee.conf, so we add these lines
# 358
blacklist nvidia-358
blacklist nvidia-358-updates
blacklist nvidia-experimental-358
4. Configure bumblebee
sudo gedit /etc/bumblebee/bumblebee.conf
Changed the following
In section [bumblebeed]
Driver=nvidia
In section [optirun]
Bridge=primus
Insection [driver-nvidia]
KernelDriver=nvidia-358
PMMethod=bbswitch
LibraryPath=/usr/lib/nvidia-358:/usr/lib32/nvidia-358
XorgModulePath=/usr/lib/nvidia-358/xorg,/usr/lib/xorg/modules
so this time we do no add any ppa and install as follows
Switch to Vconsole
sudo service lightdm stop
Now instal
sudo apt-get install --no-install-recommends nvidia-352
sudo apt-get install libcuda1-352 nvidia-opencl-icd-352
sudo apt-get install --no-install-recommends bumblebee
sudo apt-get install bumblebee-nvidia primus mesa-utils
enambe bumblebee service
sudo systemctl enable bumblebeed
2) Add the following lines to the /etc/modules-load.d/modules.conf file
i915
bbswitch
Reference - https://applicative-games.cppcabrera.com/posts/hybrid-gfx-ubuntu.html
3. ensure that nvidia driver version is blacklisted from loading /etc/modprobe.d/bumblebee.conf,
so we ensured these lines are present
# 352
blacklist nvidia-352
blacklist nvidia-352-updates
blacklist nvidia-experimental-352
sudo vi /etc/bumblebee/bumblebee.conf
sudo vi /etc/bumblebee/xorg.conf.nvidia (app game)
sudo vi /etc/init/gpu-manager.conf (set as in app game)
sudo vi /etc/X11/xorg.conf (create as in app game)
sudo update-alternatives --config x86_64-linux-gnu_gl_conf
update alternatives was as expected
sync
rebooted
Loaded Ubuntu in Grub and it hanged
022 generic upstart (as nvidia was generated for this kernel)
came up YAAY - went to virtual console - fonts small but can we recovered with sudo setupcon once we login, so not an issue
verified that our xorg.conf is not overwritten
used the above method to stop lightdm and once again dump the x config..
trying to generate X config hanged the machine...
Rebooting with upstart did not hang so far so good
/etc/X11/xorg.conf seems fine...
the usual test of bbswitch etc , optirun glxgears glxinfo, lsmod | grep nvidia while running provides the desired behavior.
Now to reboot and ensure that we do not get the low graphich mode issue
NOW restart the machine...
Strangely the machine is hanging when I start the machine normally, but comes up when i use upstart options. Tried rebooting a coupld of times and it comes up with upstart.
So now tested in upstart mode
hemen@hemen-7559-linux:~$ optirun -b primus -vv glxinfo | grep OpenGL
[ 500.417869] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf
[ 500.418311] [INFO]Configured driver: nvidia
[ 500.418723] [DEBUG]optirun version 3.2.1 starting...
[ 500.418783] [DEBUG]Active configuration:
[ 500.418810] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf
[ 500.418837] [DEBUG] X display: :8
[ 500.418865] [DEBUG] LD_LIBRARY_PATH: /usr/lib/nvidia-358:/usr/lib32/nvidia-358
[ 500.418889] [DEBUG] Socket path: /var/run/bumblebee.socket
[ 500.418906] [DEBUG] Accel/display bridge: primus
[ 500.418923] [DEBUG] VGL Compression: proxy
[ 500.418940] [DEBUG] VGLrun extra options:
[ 500.418957] [DEBUG] Primus LD Path: /usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus
[ 501.627125] [INFO]Response: Yes. X is active.
[ 501.627140] [INFO]Running application using primus.
[ 501.627223] [DEBUG]Process glxinfo started, PID 2674.
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 960M/PCIe/SSE2
OpenGL core profile version string: 4.4.0 NVIDIA 358.16
OpenGL core profile shading language version string: 4.40 NVIDIA via Cg compiler
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.5.0 NVIDIA 358.16
OpenGL shading language version string: 4.50 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
[ 501.693997] [DEBUG]SIGCHILD received, but wait failed with No child processes
[ 501.694029] [DEBUG]Socket closed.
[ 501.694061] [DEBUG]Killing all remaining processes.
hemen@hemen-7559-linux:~$ glxinfo | grep OpenGL
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Skylake Halo GT2
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.0.2
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 11.0.2
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.0.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:
hemen@hemen-7559-linux:~$
So far so good we see that things are good. Lets try glx gears
hemen@hemen-7559-linux:~$ glxgears -info
Running synchronized to the vertical refresh. The framerate should be
approximately the same as the monitor refresh rate.
GL_RENDERER = Mesa DRI Intel(R) Skylake Halo GT2
GL_VERSION = 3.0 Mesa 11.0.2
GL_VENDOR = Intel Open Source Technology Center
407 frames in 5.0 seconds = 81.195 FPS
301 frames in 5.0 seconds = 60.006 FPS
301 frames in 5.0 seconds = 60.004 FPS
368 frames in 5.0 seconds = 73.364 FPS
440 frames in 5.0 seconds = 87.713 FPS
Then started with optirun
hemen@hemen-7559-linux:~$ optirun -b primus -vv glxgears -info | grep OpenGL
[ 1338.860634] [DEBUG]Reading file: /etc/bumblebee/bumblebee.conf
[ 1338.860916] [INFO]Configured driver: nvidia
[ 1338.861236] [DEBUG]optirun version 3.2.1 starting...
[ 1338.861277] [DEBUG]Active configuration:
[ 1338.861290] [DEBUG] bumblebeed config file: /etc/bumblebee/bumblebee.conf
[ 1338.861303] [DEBUG] X display: :8
[ 1338.861316] [DEBUG] LD_LIBRARY_PATH: /usr/lib/nvidia-358:/usr/lib32/nvidia-358
[ 1338.861329] [DEBUG] Socket path: /var/run/bumblebee.socket
[ 1338.861342] [DEBUG] Accel/display bridge: primus
[ 1338.861355] [DEBUG] VGL Compression: proxy
[ 1338.861368] [DEBUG] VGLrun extra options:
[ 1338.861382] [DEBUG] Primus LD Path: /usr/lib/x86_64-linux-gnu/primus:/usr/lib/i386-linux-gnu/primus
[ 1340.022697] [INFO]Response: Yes. X is active.
[ 1340.022746] [INFO]Running application using primus.
[ 1340.022831] [DEBUG]Process glxgears started, PID 2904.
primus: warning: dropping a frame to avoid deadlock
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
after 31 requests (31 known processed) with 0 events remaining.
primus: warning: dropping a frame to avoid deadlock
primus: warning: timeout waiting for display worker
[ 1384.504157] [DEBUG]SIGCHILD received, but wait failed with No child processes
[ 1384.504201] [DEBUG]Socket closed.
[ 1384.504240] [DEBUG]Killing all remaining processes.
hemen@hemen-7559-linux:~$
glxgears also started properly
In another terminal while glxgears was working i could see that bbswitch is working fine.
hemen@hemen-7559-linux:~$ cat /proc/acpi/bbswitch
0000:02:00.0 OFF
hemen@hemen-7559-linux:~$ cat /proc/acpi/bbswitch
0000:02:00.0 OFF
hemen@hemen-7559-linux:~$ cat /proc/acpi/bbswitch
0000:02:00.0 ON
hemen@hemen-7559-linux:~$ cat /proc/acpi/bbswitch
0000:02:00.0 ON
hemen@hemen-7559-linux:~$ cat /proc/acpi/bbswitch
0000:02:00.0 OFF
hemen@hemen-7559-linux:~$
And as experienced by others I get the same issue as "The system is running in low graphics mode"
2. Enable optimus and Nvidia drivers.
https://wiki.ubuntu.com/Bumblebee#Installation
sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia virtualgl linux-headers-generic
http://ubuntuforums.org/showthread.php?t=2263316
sudo gedit /etc/modprobe.d/blacklist.conf (and then added the below lines)
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment