I am using Ubuntu 16.04, on a dell XPS 9560 a laptop which is highly compatible with linux. This laptop provides two graphic cards:

  • NVIDIA GeForce GTX 1050
  • Intel HD Graphics 630

I wanted to use NVIDIA card only for CUDA, since it only have 4GB of RAM and the Intel Card for the graphical user interface.


  • If it works the nvidia card is no longer visible. So if I call nvidia-smi the video card is disabled.
  • If do not works I get a black screen.

2 Answers 2


The solution is based on this GitHub gist

Information on my system:

  • Dell XPS 9560
  • I have already installed the CUDA 9.2 and Nvidia display driver 396.37
  • Ubuntu kernel is 4.15.0-24-generic
  • I am using gd3

Step 1

Modify the GRUB configuration by editing this file:

sudo vim /etc/default/grub

And change:



GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_rev_override=1"

Finally update GRUB using this command:

sudo update-grub

If you want you can use the tool grub-customizer by adding the text highlighted in blue:

GRUB editor screen - text added to line beginning linux

Restart your computer - very important!!

Step 2

Create a service that will select the Intel GPU when the computer turns off, to this end create a new file:

sudo vim /etc/init.d/intel-gpu

With this content:

# /etc/init.d/intel-gpu

# Provides:          intel-gpu
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Selects the intel GPU over the NVIDIA

case "$1" in 
        /usr/bin/prime-select intel
        echo "Usage: /etc/init.d/intel-gpu start|stop"
        exit 1

exit 0

Add executable rights:

sudo chmod +x /etc/init.d/intel-gpu

And register the new service:

sudo update-rc.d intel-gpu defaults

Step 3

Now we have ensured that when we start the computer the lightdm, gdm3, etc will use the Intel GPU since we have been enabled this GPU last time that we turned off the computer. Now we have to enable the NVIDIA GPU when we log into our account. However we need root access to do this and we don't want to prompt a window asking for a password each time we log in. To overcome this problem, we will create a command alias into the sudo configuration file.

First of all open the sudo configuration file using the following command:

sudo visudo

Then append this content to the end of the file:

User_Alias ADMINS = <your_user>
Cmnd_Alias PRIME_SELECT = /usr/bin/prime-select

where <your_user> is your user name.

This allows us to call prime-select without having to introduce a password.

Step 4

Add an autostart script to change the graphics card to NVIDIA once the lighdm has already started using the Intel's GPU. To this end append this command create a new file like this:

vim ~/.config/autostart/nvidia-gpu.desktop

And add this content:

[Desktop Entry]
Exec=sudo prime-select nvidia

Restart you computer

Now you can use all the memory in your NVIDIA GPU. You can verify that by calling the command `nvidia-smi:

nvidia-smi output

  • Lately I discovered that after configuring using this method, the nvidia card will only be enabled if the laptop is plugged into the power. So make sure that before turning on your laptop (and if you plan to use CUDA) plug the computer to the power!!
    – Marcus
    Jul 21, 2018 at 23:49

To avoid problems when logging off and logging in some cases it is recommended to avoid step 4. It also helps to increase the battery life of your laptop if you only activate the NVIDIA card when it is needed. However it is not very practical since you have to open a terminal and write sudo prime-select nvidia each time. To overcome this "problem" I did a gnome 3 extension that does that.

To make it work you only have to go to this folder:

cd ~/.local/share/gnome-shell/extensions/

And then clone this repository:

git clone https://github.com/marcvivet/enable_cuda
mv enable_cuda enable_cuda@vivet.cat

Then press Alt+F2, enter 'r' (to restart the desktop) or just reboot.

Once you are done go to the gnome 3 Tweak Tool and enable the extension.

The result should be and NVIDIA gray icon when it is disabled:

icon in top bar

And green when you click on the icon to enable CUDA.

same icon in green colour

This extension is very very simple and I do not make any check of the current state of the NVIDIA card. So If you use this icon do not use the terminal ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.