Showing posts with label installation. Show all posts
Showing posts with label installation. Show all posts

Installing CUDA on Ubuntu

Wednesday, October 13, 2010

Its simple as counting 1, 2, 3.. (as long as everything is supported and works fine).

PART I:
NVidia (developer) driver that is required by CUDA (as mentioned in the GPU computing page). This might be different from the latest driver you might find in other pages.

Step 1: Download the driver for your nvidia graphics card. These will come as .run files.

Step 2: If you have traces of your (now obsolete) driver from nVidia, get rid of them with the following 2 commands:
sudo apt-get remove --purge nvidia
sudo nvidia-installer --uninstall

Step 3: Stop your display manager
sudo /etc/init.d/gdm stop

Step 3.5: Now you do not have your X running, so switch to console:
ctrl + alt + F1

Step 4:
sudo sh devdriver_3.2_linux_32_260.24.run

This should bring up a console based miniature GUI, enter details as required. And complete the installation.

Step 5: Bring back the X
sudo /etc/init.d/gdm start


PART II: Installing CUDA toolkit
Step 1: Download the CUDA toolkit (cudatoolkit_3.2.9_linux_32_ubuntu10.04.run) from GPU Computing page at NVidia site.

Step 2: Run the file:
sh cudatoolkit_3.2.9_linux_32_ubuntu10.04.run

Make sure you do not do it as root (or with sudo prefix).
Step 3: I prefer leaving the default locations for installation.

Step 4: Assuming default locations of installation, set environment variables

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


PART III: Installing sample projects, SDK etc.

Step 1: Download gpucomputingsdk_3.2_linux.run

Step 2: Run (do not run this in root mode)
sh gpucomputingsdk_3.2_linux.run

Step 3: Give default locations to CUDA installation (or the modified locations, if you have modified them)

Step 4: Test if its fine
cd ~/NVIDIA_GPU_Computing_SDK/C
make

This should build all example projects included in the SDK without any error. If that goes fine, it means you have a working CUDA environment to work with.

Now try running one of the programs (one I like is to query the GPU)
cd bin/linux/release/
./deviceQuery

It gives me an output like this:
./deviceQuery Starting...

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

There is 1 device supporting CUDA

Device 0: "GeForce GT 240M"
CUDA Driver Version: 3.20
CUDA Runtime Version: 3.20
. . . . .
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 3.20, CUDA Runtime Version = 3.20, NumDevs = 1, Device = GeForce GT 240M



Components that I have/chose:

  1. Ubtuntu 10.04 (32bit)
  2. NVidia GT240M graphics card
  3. devdriver_3.2_linux_32_260.24.run driver
  4. cudatoolkit_3.2.9_linux_32_ubuntu10.04.run
  5. gpucomputingsdk_3.2_linux.run

Read more...