Run CUDA on Ubuntu 14.04 (Desktop)

19 Jul

What is CUDA?

Modern video card on desktop/laptop can be used for general parallel computing. CUDA is such a platform developed by Nivida. On my laptop, the Nvidia card has 96 CUDA cores. A desktop Nvidia card can easily have 1000 CUDA cores. For the purpose of simplicity, you can think of one CUDA core as one CPU core when doing some parallel math computations.

Setup CUDA 7 on Ubuntu 14.04 (Desktop)

My laptop has two video cards: one is intel HD, the other is Nvidia 5200M. Ubuntu uses the Intel card for GUI, Nvidia card is not activated. After quite a few search & try, I setup CUDA on my laptop. Below is the steps that works for me.

Hardware: Thinkpad T430s two video cards: Intel & Nvidia NVS 5200M
OS: Ubuntu 14.04 (Desktop)

  • Remove all Nvidia default driver in Ubuntu
  • Create a file at /etc/modprobe.d/blacklist-nouveau.conf with the following contents:
blacklist nvidiafb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist vga16fb
options nouveau modeset=0

Regenerate the kernel initramfs: sudo update-initramfs -u

  • Remove all other Nvidia packages:
    sudo apt-get purge nvidia*
  • Search all packages related to nouveau: dpkg –get-selections | grep -v deinstall|grep -i nouveau, you might have to sudo apt-get purge xserver-xorg-video-nouveau-lts-vivid
  • Sometime you must run sudo update-initramfs -u so the initramfs can be purged of nouveau
  • Download CUDA 7 toolkit here, and then reboot Ubuntu to a text/console mode (basically hold shift key and then edit with ‘e’ and continue boot with ctrl-x. For detail help, see this), and then run the downloaded file:
$ sudo sh cuda__version__linux.run
  • When prompt, install Nvidia driver
  • When prompt, remember NOT to install OpenGL driver: I mistakenly installed OpenGL and got blank GUI when reboot.
  • Install CUDA toolkit & examples & reboot
  • verify your installation:
$ cd
$ cd 1_Utilities/deviceQuery
$ make
$ ./deviceQuery
./deviceQuery Starting...

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVS 5200M"
CUDA Driver Version / Runtime Version 7.0 / 7.0
CUDA Capability Major/Minor version number: 2.1
Total amount of global memory: 1024 MBytes (1073479680 bytes)
( 2) Multiprocessors, ( 48) CUDA Cores/MP: 96 CUDA Cores
GPU Max Clock rate: 1250 MHz (1.25 GHz)

What does not work

The nvidia-346 and nvidia-340 drivers in ppa:xorg-edgers/ppa do NOT work.

What if cuda does not work after laptop wake up from sleep

put following 2 lines in your /etc/rc.local

/usr/bin/nvidia-smi -pm ENABLED
/usr/bin/nvidia-smi -c EXCLUSIVE_PROCESS

Advertisements
%d bloggers like this: