Friday, 14 October 2011

Installing and getting CUDA to work under ubuntu 11.04 x64 bit

So I want to play with CUDA in the coming months, getting it to work under ubuntu 11.04 was a challenge in itself specially running x64bit!

so here is how I got it working..

sudo add-apt-repository ppa:aaron-haviland/cuda-4.0
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 libcudart4 libcublas4 libcufft4 libcusparse4 libcurand4 nvidia-current nvidia-opencl-dev nvidia-current-dev nvidia-cuda-dev opencl-headers

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

this is really important, if you didnt have nvida drivers already installed, you have to run this
sudo nvidia-xconfig

the next thing to do even if you skipped the last line is to REBOOT - you MUST do this!!

CUDA should now be working :)

-- to get compiling working is another ball ache!
in somewhere like your home folder do the following

mkdir gcc44
cd gcc4
ln -s /usr/bin/cpp-4.4 cpp
ln -s /usr/bin/gcc-4.4 gcc
ln -s /usr/bin/g++-4.4 g++


edit /etc/nvcc.profile to look in the gcc44 directory (give it the full path)

compiler-bindir =/home/xxx/gcc44

now your ready to compile stuff - here is an example
nvcc -c yourprog.cu

that should give you a .o file then run the next
g++-4.4 -lcudart yourprog.o

that should give you a a.out file - just run it as ./a.out

No comments: