Friday, May 2, 2008

Getting Started with CUDA on Linux

For the last three years, I've been going to school part-time on and off to get my Masters' degree in Computer Science. I'm in my last semester of real classes now, and thankfully it's nearly the end of the semester. However, that means end-of-semester projects...d'oh!

For one of my projects, which I'll explain in more detail later, I am planning to write some CUDA code to simulate chemical reactions. I'm currently running Ubuntu 7.10 with a NVIDIA 8800GT video card. I'm a little bit worried about getting this set up correctly - I've had some issues getting my video card working. In fact, I have to reinstall my video card drivers every time I reboot my computer. Ah, the joys of Linux.

I originally intended to write this a half-assed attempt at a live-blog while getting the CUDA examples to compile and run. However, I had so many problems, it just got too long. Here's the abridged list of problems I had, plus their solutions. I like to think of myself as moderately competent (although not a Linux genius), but this process was still pretty painful. Hopefully this list will make things easier for somebody out there:
  1. Problem: Permission errors building the SDK. Solution: Don't install the SDK as root; it just goes under your home folder, anyway.
  2. Problem: "GL/glu.h: No such file or directory." Solution: `apt-get install libglu1-mesa-dev`
  3. Problem: "gcc: installation problem, cannot exec `cc1plus.'" Solution: make sure that your gcc and g++ compilers are the same version. (WTF?!)
  4. Problem: "cannot find -lglut". Solution: `apt-get install libglut3-dev`
  5. Problem: "error while loading shared libraries:". Solution: Add /usr/local/cuda/lib to /etc/ and run ldconfig

Good luck with CUDA. If you run across different problems or different solutions, post them in the comments!

PS - Wouldn't it be nice if NVIDIA had just released this as a apt-gettable package so I wouldn't have to guess which prerequisite packages I needed?


curran said...

Thanks for the tip about libcudart, I used it to get CUDA working with eclipse after lots of frustration.

If you're interested, the post is here:


Gdrs said...

Extremely useful compilation of fixes. #2 does not work for my Red Hat Enterprise Linux 5.4, however. It owuld be helpful to add in the fix list systems for which they work..

Forma said...

For x64 you might need to add


to /etc/

The Trojan said...

dont blame linux for that reboot thing. Blame UBUNTU... I have used zillions of flavors, openSUSE and Fedora being my best buddies.

Ubuntu is the esiest Linux out there and an exceptional pain in the a$$. Ubuntu ain't Linux, its Windows which behaves like Linux (and even looks like one).

Try your luck with openSUSE or fedora. I had cuda drivers installed without any problems and all test suites ran fine. No experience of my own with cuda dev, but it won't let you down!

xunilresu said...

@The Trojan : Why dude you blame ubuntu, i think you never use and know ubuntu much, ubuntu is universal, it make easier for beginner user, so i think that's good if ubuntu easy to operate it. If you dont like so easy operating system, just try compile it self from kernel, so named with yourname, so make better one first than ubuntu, then you can talk ubuntu is bad, if not please not try use openSUSE or fedora, just use BSD machine if you dare.