Multiple NVidia graphics cards in Ubuntu

Two NVidia GTX/GT graphics cards + two monitors + Intel motherboard + Ubuntu 12.04 + 64 bit Nvidia driver + CUDA installation

Disconnect the secondary one of the two monitors.

Select the primary video adaptor in BIOS setup. If the BIOS persists not to change the order, try to change it to automatic or something else, then to change it to manual with your favoured order in the next reboot.

This ensures that you have POST messages and tty1–6 consoles displayed in your primary graphics card correctly.

Update xorg.conf. nvidia-settings can do it for you. Ensure that:
you have a “Device” section which identifies correctly the graphics card you want to use for X11.
This will have your X11 server use the graphics card you want.

Install the graphics card driver in the following order.

Download the suitable graphics card driver and the CUDA toolkit in the following pages, both the .run installers.

EDIT: Check which version of gcc was used to build the kernel:

cat /proc/version

Set compiler version the same as that used to compile kernel:

sudo update-alternatives --config gcc


export CC=/usr/bin/gcc-x.x

If you’re in GUI environment, press ctrl-alt-F1 to change to a tty console.

Stop X server:

sudo service lightdm stop

Remove the old NVidia driver:

sudo apt-get remove nvidia-*

Remove the nouveau driver which causes problems with maya and potentially with other software:

sudo apt-get remove xserver-xorg-video-nouveau

If you installed the driver without using apt-get you may need:

sudo /usr/bin/nvidia-uninstall

Remove the NVidia kernel module:

sudo dkms remove -m nvidia -v <version> --all

To identify the kernel module that’s running:

lsmod | grep nvidia
find /lib/modules | grep nvidia

To get more info about the kernel module:

modinfo <module name>

nvidia apt-get uninstaller removes kernel modules, so better reboot before checking it.

Install the driver—run the downloaded graphics card driver (the .run file):

sudo sh ./NVIDIA-Linux-x86_64-<version>.run

After installing the driver, remove xorg.conf file:

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

Set your gcc version back if you had to change it for the driver compilation:

sudo update-alternatives --config gcc


sudo reboot

Install CUDA—run the downloaded CUDA toolkit .run installer:

sudo sh ./cuda_<version>

During the installation, do not install the driver, but only the CUDA toolkit and sample code.

After the installation add path and library path.

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

Connect the second monitor.

Failed to run `/usr/sbin/dkms add -m nvidia -v 331.20 -k 3.2.0-57-generic`: Error! DKMS tree already contains: nvidia-331.20 You cannot add the same module/version combo more than once.


Multiple NVidia graphics cards in Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s