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 gputools.
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
wget http://developer.download.nvidia.com/compute/cuda/3_0/toolkit/cudatoolkit_3.0_linux_64_ubuntu9.04.run chmod +x cudatoolkit_3.0_linux_64_ubuntu9.04.run sudo ./cudatoolkit_3.0_linux_64_ubuntu9.04.run
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:
# CUDA if [ -d "/opt/cuda/bin" ] ; then PATH="/opt/cuda/bin:$PATH" LD_LIBRARY_PATH="/opt/cuda/lib64:$LD_LIBRARY_PATH" fi
Download and unpack the SDK
wget http://developer.download.nvidia.com/compute/cuda/3_0/sdk/gpucomputingsdk_3.0_linux.run chmod +x gpucomputingsdk_3.0_linux.run ./gpucomputingsdk_3.0_linux.run
This simply unpacks the SDK to the default destination of ~/NVIDIA_GPU_Computing_SDK.
Fix up issues with compilation
sudo apt-get 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 NVCCFLAGS := --compiler-bindir=/usr/bin/gcc-4.3
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.
sudo ln -sf /usr/lib/nvidia-current/libcuda.so /usr/lib/
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.
Update: those useful (though a little dated) links are…