Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.

The solution is described in the answer from this post.

Install the NVIDIA drivers

Download the driver installation runfile from their website (e.g. the 375.26 driver runfile). Run the script with the option --no-opengl-files:

sudo ./NVIDIA-Linux-x86_64-375.26.run --no-opengl-files

Reboot.

Install CUDA

Download the CUDA installation runfile from their website. It's important to download the "runfile (local)" file so that we can explicitly prevent from overwriting the driver that was just installed. Run the script:

sudo ./cuda_8.0.44_linux.run 

Respond "no" when asked "Install NVIDIA accelerated Graphics Driver for Linux-x86_65 375.26?".

Configure xorg.conf

Modify or create the file /etx/X11/xorg.conf to specify that the NVIDIA GPU should be used for a secondary screen so that it has entries in nvidia-settings. Mine looks like this:

Section "ServerLayout"
    Identifier "layout"
    Screen 0 "intel"
    Screen 1 "nvidia"
EndSection

Section "Device"
    Identifier "intel"
    Driver "intel"
    BusID "PCI:0@0:2:0"
    Option "AccelMethod" "SNA"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

Section "Device"
    Identifier "nvidia"
    Driver "nvidia"
    BusID "PCI:1@0:0:0"
    Option "ConstrainCursor" "off"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration" "on"
    Option "IgnoreDisplayDevices" "CRT"
EndSection

The BusID should match what the lspci command above returned.

Reboot.

Miscellaneous tips

If installing the NVIDIA drivers messes up the OS (e.g. it gets stuck in a login loop or it shows a black screen before the login step), you can uninstall the drivers by openning a console with Ctrl-Alt-F1 and running:

sudo apt-get remove --purge nvidia-*
sudo apt-get autoremove
echo "nouveau" | sudo tee -a /etc/modules

Reboot.

@Socramin

This comment has been minimized.

Copy link

Socramin commented Jul 10, 2018

I have created an account just to let you know how incredibly useful this piece of information has been.
Thank you very much!!!

@khoatran408

This comment has been minimized.

Copy link

khoatran408 commented Jul 25, 2018

Thank you very much. I can confirm successful install on AMD mobo desktop with integrated GPU and separated NVIDIA GeForce 710, Ubuntu 16.04, CUDA 9.2

@luiset83

This comment has been minimized.

Copy link

luiset83 commented Aug 2, 2018

This setup worked an Optiplex 9010 with the latest BIOS with Intel graphics driving the display and a Titan Xp card. Had to drill the hard drive cage out to make the GPU fit, ha. I had to remove the driver version from the repository and install the run tile with the --no-opengl-files flag to get it working. By default, it was working but in order add fan control options and overclocking this method is needed.

@lucasbrynte

This comment has been minimized.

Copy link

lucasbrynte commented Aug 17, 2018

Thanks for this one!
This was enough to make it work on my system (intel + 2 nVidia GPUs): https://gist.github.com/lucasbrynte/9b2966460832522eb6c35b44ae768667

@falaktheoptimist

This comment has been minimized.

Copy link

falaktheoptimist commented Aug 24, 2018

Hi @alexlee-gk!
The Bus Id in your file and the ones from the lspci commands above don't seem to match. Should it be BusID "PCI:1@1:0:0" ? I had the same Bus Ids and this did not work for me.

@helderc

This comment has been minimized.

Copy link

helderc commented Sep 2, 2018

The path to the xorg.conf file should be /etc/X11/xorg.conf and not /etx/X11/xorg.conf, right?

@jclevesque

This comment has been minimized.

Copy link

jclevesque commented Oct 19, 2018

I have tried this on my system, didn't work. I see the login screen, but once I login it falls back to the login prompt (with a bunch of error messages about not finding 3D acceleration in /var/log/syslog).

Anybody else?

@yitang

This comment has been minimized.

Copy link

yitang commented Oct 26, 2018

@jclevesque I have the same problem as yours.

@cjmcclellan

This comment has been minimized.

Copy link

cjmcclellan commented Dec 9, 2018

This was a really good solution. However there are a few mistakes I had to fix before it worked for me. My system, Intel i5-4690K, Nvidia RTX 2080 Ti, Nvidia-410 driver installed from the Graphics PPA, CUDA 10 installed using the local deb file (off Nvidia website), and Ubuntu 18.04

I followed the instructions but was having the same issue as @jclevesque (but creating xorg.conf in etc/X11/). The issue was that the BusID was wrong in the above example as @falaktheoptimist pointed out. Once I changed the BusID to "PCI:1@1:0:0" everything worked. :)

@agisubagio

This comment has been minimized.

Copy link

agisubagio commented Jan 3, 2019

I have an old mainboard with ATI ES1000 onboard. I add 4 GTX 1060 3GB to that mainboard as a CUDA compute, but still want to see my ubuntu desktop from onboard VGA. Do you have any recommedation for xorg.conf and nvidia-settings?

@pulver22

This comment has been minimized.

Copy link

pulver22 commented Jan 16, 2019

I modify the xorg.conf but after rebooting the laptop it turns back to its default config. It may be overwritten by the nvidia-setting. How can I avoid that? Did it happen to someone else?

Edit: I must say that I installed the nvidia driver from the "additional drivers" applet and not the .run downloaded from the web.

@pgbarletta

This comment has been minimized.

Copy link

pgbarletta commented Jan 27, 2019

Thanks for this. Worked like a charm.

@sausthapit

This comment has been minimized.

Copy link

sausthapit commented Apr 5, 2019

Wow, thanks for posting this. For me the /etc/X11/xorg.conf (Ubuntu 18.04) wasn't there so created a new one and it worked.

@hdsingh

This comment has been minimized.

Copy link

hdsingh commented Apr 10, 2019

This did not worked for me on Ubuntu 18.04. Got stuck in infinite login loop. And even unable to open terminal (tried almost all combinations including Ctrl-Alt-F1. Then deleted xorg.conf through dual booted windows and logged in.

@LanternD

This comment has been minimized.

Copy link

LanternD commented Apr 21, 2019

A small tip: before you work on the nvidia driver, you can install and enable the openssh server, such that you can edit everything on another computer via SSH in the same LAN.

@lexxwork

This comment has been minimized.

Copy link

lexxwork commented May 24, 2019

thank you so much bro!
one more tips:
if you have a black screen or any issue with loading gui you can run a console terminal with ctrl+alt+F2 for example and login.
as aditor would advice a 'micro' (apt install micro)
to see if something changed you should run
sudo service lightdm restart to load gui session
if all is fine you should atumaticaly switch to gui session

@0x6d3f9c

This comment has been minimized.

Copy link

0x6d3f9c commented Aug 25, 2019

I use ArchLinux and I updated Nvidia to version 430.40 and Xorg-server to version 1.20.5, this configuration didn't work as before. Just saw black screen with cursor after Lightdm login.

Just removing all configuration about Nvidia in xorg.conf, then it worked again. It doesn't bother MATLAB to find the Nvidia driver to do
GPU computing jobs.

/etc/X11/xorg.conf

Section "ServerLayout"
Identifier "layout"
Screen 0 "intel"
EndSection

Section "Device"
Identifier "intel"
Driver "intel"
BusID "PCI:0@0:2:0"
EndSection

Section "Screen"
Identifier "intel"
Device "intel"
EndSection

PS: I first suspected the black screen should be blame to /usr/share/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf , because the configuration is setting PrimaryGPU as nvidia. I changed "yes" to "no" or setting PrimaryGPU as intel, but both had no effect.

@ulisesbussi

This comment has been minimized.

Copy link

ulisesbussi commented Aug 26, 2019

I use ArchLinux and I updated Nvidia to version 430.40 and Xorg-server to version 1.20.5, this configuration didn't work as before. Just saw black screen with cursor after Lightdm login.

Just removing all configuration about Nvidia in xorg.conf, then it worked again. It doesn't bother MATLAB to find the Nvidia driver to do
GPU computing jobs.

/etc/X11/xorg.conf

Section "ServerLayout"
Identifier "layout"
Screen 0 "intel"
EndSection

Section "Device"
Identifier "intel"
Driver "intel"
BusID "PCI:0@0:2:0"
EndSection

Section "Screen"
Identifier "intel"
Device "intel"
EndSection

PS: I first suspected the black screen should be blame to /usr/share/X11/xorg.conf.d/10-nvidia-drm-outputclass.conf , because the configuration is setting PrimaryGPU as nvidia. I changed "yes" to "no" or setting PrimaryGPU as intel, but both had no effect.

Man you saved me a lot of time! thanks for this! you're awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.