Jacques Mattheij

Technology, Coding and Business

CUDA for beginners

Notes on getting started with the NVidia CUDA architecture.

this is in ‘sh’ script format so that you can copy and paste

including the comments, but be sure to go step by step, your

machine may not match mine (ubuntu 9.0.4), and you will have

switch users and exit X windows at some point.

Uninstall any existing NVidia drivers that you have or you might run into trouble later.

First, you have to get the CUDA implementation and toolkit for your machine:

http://www.nvidia.com/object/cuda_get.html

Shut down X windows

run the cudadriver file as ‘root’

sudo sh cudadriver_XXX (fill in details of your file here)

you can restart X at this point.

I still had to install a bunch of stuff to get the examples to compile:

as root:

apt-get install libglut3-dev

apt-get install libxi-dev apt-get install libxmu-dev

as your normal user you should now run the cudatoolkit

and the cuda sdk shell archives

sh cudatoolkit_XXX sh cudasdk_XXX

then add this to your .bashrc:

PATH=“$PATH:/usr/local/cuda/bin” LD_LIBRARY_PATH=“$LD_LIBRARY_PATH:/usr/local/cuda/lib”

(if you’ve changed any of the paths during the installation you’ll have to make these changes in the paths above as well)

start a new shell and check if the environment has been changed

now you’re ready to build the examples.

I installed the sdk archive in the default directory so

cd ~/NVIDIA_GPU_Computing_SDK/C

make

this will compile the examples. It’s possible you will run into missing bits

and pieces while you compile, fix them and retry

now update the dynamic linker configuration

cd /etc/ld.so.conf.d cat > cuda.conf /usr/local/cuda/lib ctrl-d

ldconfig

once done you will find a bunch of binaries in

cd ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release

try one:

./Mandelbrot

HN Submission/Discussion
If you read this far you should probably follow me on twitter: