Configure integrated GPU for rendering and NVIDIA GPU for CUDA works in Ubuntu 18.04

Share on:

In fact, besides CUDA tasks (which could be deep neural network training), our operating system also consumes a decent amount of memory for graphic rendering. This article will guide you to use onboard graphic card for display, thereby saving a considerable amount of GPU VRAM for model training. It's especially useful when you have an NVIDIA GPU with a small memory size.

  • First, you need:
    • A computer using Ubuntu or equivalent operating system. Here I use Ubuntu 18.04.
    • Your computer has an onboard graphics card (from Intel) and (of course) an NVIDIA GPU.
    • You plug the monitor cord into the graphics output port (possibly HDMI) on the mainboard instead of on the GPU card. ** You may need to configure the BIOS for the system to output the video to the HDMI port on the motherboard when booting. **

Step 1: Install drivers for NVIDIA GPU and CUDA (optional - you can skip if you already have GPU drivers and CUDA toolkit installed)

I will guide you through these steps to install necessary drivers and CUDA packages.

First, open Terminal (Ctrl+Alt+t).

You need to delete the preinstalled CUDA PPA and nvidia-cuda-toolkit package. This will ensure that you can properly install the desired version of drivers:

1sudo rm /etc/apt/sources.list.d/cuda*
2sudo apt remove --autoremove nvidia-cuda-toolkit

Remove old driver (recommended)

1sudo apt remove --autoremove nvidia-*

Update your system packages:

1sudo apt update && sudo apt full-upgrade

Add PPA and setup key server:

1sudo add-apt-repository ppa:graphics-drivers/ppa
2sudo apt-key adv --fetch-keys

Add driver repositories:

1sudo bash -c 'echo "deb /" > /etc/apt/sources.list.d/cuda.list'
2sudo bash -c 'echo "deb /" > /etc/apt/sources.list.d/cuda_learn.list'

Update package database again:

1sudo apt update

And, install CUDA 10.0. Please note that, when you type the following command, the suitable driver version for GPU is also installed.

1sudo apt install cuda-10-0

Install cudnn package (for deep learning applications):

1sudo apt install libcudnn7

Finnaly, you need to open ~/.profile (using Nano: nano ~/.profile) and append following content:

1# set PATH for cuda 10.0 installation
2if [ -d "/usr/local/cuda-10.0/bin/" ]; then
3    export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
4    export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

After this step, you will need to restart your computer and check if CUDA is installed correctly using nvcc --version.

Step 2: Configure the system to use integrated GPU card for displaying and NVIDIA GPU for CUDA works

  • Create file at /etc/X11/xorg.conf with following content (using Nano: sudo nano /etc/X11/xorg.conf):
Section "Device"
    Identifier      "intel"
    Driver          "intel"
    BusId           "PCI:0:2:0"

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

Note that you have to change BusId (PCI:0:2:0) to your integrated GPU. List all graphic cards by following command: (Note that my Intel graphic card is 00:02.0, so I use PCI:0:2:0 for BusId.)

1lspci  | grep VGA

00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (Desktop) 01:00.0 VGA compatible controller: NVIDIA Corporation TU106 [GeForce RTX 2070] (rev a1)

  • Restart your workstation again to check the result.

Step 3: Check the result

If everything goes in the right direction, after restarting the computer, your workstation will use the onboard card for rendering and NVIDIA GPU for CUDA works. Check with the following command when you are not running any CUDA work yourself:


If you see No running processes found like following figure, your system is using integrated card for displaying. You can run a training task (or any other CUDA task) to ensure that the CUDA system can still operate properly.

nvidia-smi output

nvidia-smi output

Note that a wrong configuration in step 2 can break your system. If it happens, please reboot into recovery mode and remove /etc/X11/xorg.conf by using rm /etc/X11/xorg.conf command. Thank you for reading my post!

Related Posts