First cautious steps with CUDA | What You’re Doing Is Rather Desperate
I recently obtained an account on our GPU cluster,
so I thought I should get my head around some of the technology that
drives GPU computing.
Put simply, GPUs can be used to perform calculations and since there are
many processors on a GPU, this can lead to quite substantial speed
increases as compared with CPUs. NVIDIA are
leading the way and they provide libraries and
software tools for people interested in this field.
Development is typically performed using C, C++ or Fortran. I’m not a
compiled languages guy – I could just about manage a hello world
in C – so I’m relying on tools built by other people, such as R
Step 1 is to download and install the required libraries, toolkit and
possibly, drivers. I ran into a couple of minor problems on my machine,
so I thought I’d document them here.
I run Ubuntu 10.04 on a 64-bit machine with a quad-core AMD Phenom II X4
955 Processor and a GeForce 9600 GT nVidia 512 MB card. The issues
documented here relate largely to Ubuntu 10.04.
Install the CUDA toolkit
This is reasonably straightforward. Note that the latest version of the
toolkit is for Ubuntu 9.04.
The installer asks where you would like to install the toolkit. I
chose /opt/cuda, over the default /usr/local/cuda. You then add
/opt/cuda/bin to your PATH and /opt/cuda/lib64 to LD_LIBRARY_PATH.
There are several ways to achieve this; I like to edit ~/.profile:
Download and unpack the SDK
This is also quite easy.
This simply unpacks the SDK to the default destination of
Fix up issues with compilation
In theory, the next step is to cd to
~/NVIDIA_GPU_Computing_SDK/C, type “make” and watch the sample
applications compile. There are a couple of problems with Ubuntu 10.04.
First, the version of GCC in the distribution is 4.4.3, whereas the SDK
requires, at most, 4.3.x. We need to install gcc-4.3:
Next, we have to tell the SDK which GCC to use. Open up
~/NVIDIA_GPU_Computing_SDK/C/common/common.mk in a text editor and:
# look for this line
# NVCCFLAGS :=
# and change it to this
At this point, make still failed with errors related to
libraries. Ubuntu 10.04 has an up-to-date version of the NVIDIA video
driver, so there should be no need to update it. However, check whether
your system has libxi-dev, libxmu-dev and libglut3-dev
and install them if required.
My final make error was “unable to find -lcuda”. On my system,
it lives in /usr/lib/nvidia-current/libcuda.so. A temporary symbolic
link to /usr/lib did the trick:
Finally, make works and creates 68 executables in the
directory ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release. If everything
went well, you can now enjoy a fast rendering of a smoke cloud, like
the one in the video at the top of this post, by running smokeParticles.
Next step – figuring out how to do something useful and
bioinformatics-related with this new toy.
I used several very helpful blog posts by other people to
troubleshoot these issues. Unfortunately, I don’t have the links with
me right now, so I’ll update this post later in the day.