Saturday, April 23, 2011

HOWTO : nVidia CUDA 4.0 RC on Ubuntu 10.10 Desktop

If you have nVidia display card that have several CUDAs on it, you will interested in this tutorial. This time, I would like to show you how to install CUDA 4.0 RC on Ubuntu 10.10 Desktop.

You will experience a faster desktop after the installation of CUDA 4.0. Meanwhile, if you installed SMPlayer, you can playback 1080p videos with the help of vdpau.

Step 1 :

Add the CUDA 4.0 PPA.
sudo add-apt-repository ppa:aaron-haviland/cuda-4.0

Step 2 :

sudo apt-get update
sudo apt-get upgrade


64-bit :
sudo apt-get install nvidia-cuda-gdb nvidia-cuda-toolkit nvidia-compute-profiler libnpp4 nvidia-cuda-doc nvidia-current-modaliases libcudart4 libcublas4 libcufft4 libcusparse4 libcurand4 nvidia-current nvidia-opencl-dev nvidia-current-dev nvidia-cuda-dev nvidia-kernel-common opencl-headers

32-bit :
sudo apt-get install nvidia-cuda-gdb nvidia-cuda-toolkit nvidia-compute-profiler lib32npp4 nvidia-cuda-doc nvidia-current-modaliases lib32cudart4 lib32cublas4 lib32cufft4 lib32cusparse4 lib32curand4 nvidia-current nvidia-opencl-dev nvidia-current-dev nvidia-cuda-dev nvidia-kernel-common opencl-headers

Step 2a :

If you do not have any nVidia driver installed before, you need to do the following command. Otherwise, this step is not required at all.

sudo nvidia-xconfig

Step 3 :

Reboot your system.

Step 4 (Optional) :

To install SMPlayer.

sudo apt-get install smplayer smplayer-translations smplayer-themes

Then set it to use "vdpau" at "Output Driver" at "Preference".

Step 5 - Compiling of nVidia CUDA sample codes (Optional)

Some sample codes at gpucomputingsdk_4.0.13_linux.run cannot be compiled successfully. However, I would like to share how I compile some of them.

(a) Install the gupcomputingsdk with the following command and accepted the default setting that it provides.

sudo apt-get install freeglut3-dev libxi-dev libXmu-dev

Go to the following link :
http://developer.nvidia.com/cuda-toolkit-40#Linux

wget http://developer.download.nvidia.com/compute/cuda/4_0_rc2/sdk/gpucomputingsdk_4.0.13_linux.run

sudo chmod +x gpucomputingsdk_4.0.13_linux.run
sh gpucomputingsdk_4.0.13_linux.run

(b) Set the environment :

sudo nano /etc/environment

Append the following at the end of the entry.

:/usr/lib/nvidia-current:/usr/lib/nvidia-cuda-toolkit

source /etc/environment

(b1) Set LD_LIBRARY_PATH :

sudo nano /etc/ld.so.conf.d/cuda.conf

Append the following lines to the file.

/usr/lib/nvidia-current
/usr/lib/nvidia-cuda-toolkit

sudo ldconfig

(b2) Create a softlink of libcuda.so :

sudo ln -s /usr/lib/nvidia-current/libcuda.so /usr/lib/
sudo ln -s /usr/lib/nvidia-current/libcuda.so.1 /usr/lib/


(c) Make softlink to the /usr/include/thrust :

sudo mkdir /usr/lib/include
sudo ln -s /usr/include/thrust /usr/lib/include/


(c1) Add the path of new location of thrust to the common/common.mk :

sudo nano ~/NVIDIA_GPU_Computing_SDK/C/common/common.mk

Go to line 64 and add "-I/usr/lib/include" :

Change from -
INCLUDES += -I. -I$(CUDA_INSTALL_PATH)/include -I$(COMMONDIR)/inc -I$(SHAREDDIR)/inc

Change to -
INCLUDES += -I. -I$(CUDA_INSTALL_PATH)/include -I/usr/lib/include -I$(COMMONDIR)/inc -I$(SHAREDDIR)/inc

(d) Compiling of the sample code :

cd NVIDIA_GPU_computing_SDK/C
make


The executable sample codes will be situated at ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/

Run the sample codes as the following, e.g. nbody and deviceQuery :

./nbody
./deviceQuery

(e) According to the developer of the PPA, this issue (Step 5(b) to Step 5(c1)) (Step 5(c) to Step 5(c1)) may be caused by the SDK itself and nvcc compiler. However, if you install the official SDK, there is no such problem.

***(f) The CUDA 4.0 PPA just updated today (April 26, 2011 GMT+8) and it solved the Step 5(b) to Step 5(b2) problem.

That's all! See you.