All posts tagged CUDA

Late last year, my thesis was approved by Virginia Tech. Fortunately, that meant I could graduate. Unfortunately, it probably means that my thesis will be socked in a (virtual) drawer somewhere to gather (virtual) dust. I had the option to produce a vanity publication through some shady German-owned publication house, but I opted out. I decided that I would publish my thesis to the Internet for anyone who was interested in such research. It can be found here:

I looked at Hidden Markov Models (HMMs) as a method to enhance functionality in cognitive radios. HMMs have been used previously for pattern recognition, such as handwriting and speech analysis, but they have seen limited use in the wireless world for things like spectrum sensing and analysis.

CPUs (especially the really small ones found in modern wireless devices like radios and cell phones) have trouble keeping up with the demands of most HMM implementations. Therefore, I created both C and CUDA implementations of such HMM algorithms in order to compare their executions times. From what I found, graphics cards (GPUs) can surpass CPUs only when many states or many models are used at the same time. If you’re interested in the results, check out my thesis. If you’re interested in trying out the code or replicating my results, you can find my code hosted here:

With the advent of CUDA (well, at least as long as I’ve been looking at it), I keep getting the question: “Can I use CUDA with MATLAB?” The short answer: yes! The long answer: yes…and you can do it for free or pay some money for extra features. If you’re interested in spending a little extra for the most optimized, feature-rich tool set, check out MATLAB’s Parallel Computing Toolbox.

For those (like myself) who are a little tight on money, I recommend GP-you’s GPUmat MATLAB library, which can be found on their site: http://gp-you.org/. And for fun, I’ll walk you through installation and a basic GPU-enabled script!

Well, since my old Dell Inspiron 1200 started having some odd hardware problems (the usual…battery lasts 20 min, can’t find the CD-ROM drive, Windows “delayed write” errors, etc.), I decided to demote it to my main interface to the USRP. However, this presented an opportunity to invest in a slick, new laptop. I needed something small and portable, but it also had to support CUDA. After some research, I grabbed an Alienware m11x R1 off eBay for $590. Not bad (although at the time of this writing, you can get a new m11x R1 from Dell starting at $600, and R2’s starting at $800). The computer I received had already been upgraded to 8GB of RAM, and I decided to spend some extra money on an SSD (I’m really tired of having to treat most mechanical drives in laptops like glass).

CPU: Intel Core 2 Duo SU7300 (1.3 GHz)

RAM: 8GB

HDD :120GB SSD

GPU: NVIDIA GT335M switchable graphics

Screen: 11.6-inch screen with 1280 x 720 display resolution

Battery: Reported up to 6 1/2 hours

Initial Thoughts: It’s a sweet little machine with some wicked power for a 12-inch “netbook.” Haven’t tried gaming on it, but it’s supposed to handle a number of modern games. I don’t like having to manually switch graphics, but supposedly the R2 has NVIDIA’s “Optimus” automatic switching. From what I’ve read, however, the Optimus doesn’t work well in Linux, which is why I specifically chose the R1 model. It has VGA, HDMI, and DisplayPort outputs, but no DVI (important if you need it for some monitors). Additionally, only 2 usable USB ports makes connecting multiple peripherals quite difficult. Since I’m using a wireless mouse and keyboard for my work setup, one USB port is always populated by a Logitech “Unifying Receiver.” Note for those who might be interested: there is no CD/DVD drive in the laptop (hence the small size), so you will have to get an external drive if you want to re-install operating systems.

At my desk in our lab, I setup a 23″ ASUS VH232H monitor with a combination of Logitech wireless keyboard and mouse. Additionally, I’m rocking my old set of Audio-Technica ATH-A500 headphones (5 years ago, they were the best damn closed headphones for under $200 – I don’t know what’s available these days).

For those crazy enough to dive into the world of GPGPU, one option is NVIDIA’s CUDA. For this walkthrough, I will give you a tutorial on how to set up the CUDA SDK on Linux (specifically, Ubuntu). I recommend going here as a starting place:

Then click on “Downloads” under “GPU Computing” on the quick links. This will take you to NVIDIA’s main download page for all things CUDA. Scroll down to the “Linux” section and open the “Linux Getting Started Guide.” This is the manual for installing the SDK. For those of you who are too lazy to read the manual or those who run into problems with the install (Let’s face it: it’s Linux. There are always problems with the install), I’ve created a step-by-step guide on getting CUDA running in Ubuntu. Note that in a couple weeks, Ubuntu or CUDA might change, and these steps will no longer apply. I hope it works as a good starting place, though.

Pre-requisites

1) CUDA-enabled graphics card (I’m using a GTX 470)

2) A supported Linux distribution (I’m using Ubuntu 10.04 LTS 32-bit)

3) GCC installed. If it is not installed, call the following:

$ sudo apt-get install gcc build-essential

4) You can check the version of gcc with:

$ gcc –version

5) For this post, I installed gcc 4.4.3

Download

From the “Downloads” page on NVIDIA’s “GPU Computing” site, navigate to the Linux section and download the following files:

Developer Drivers for Linux (32-bit)

CUDA Toolkit for Ubuntu Linux 10.04 (32-bit)

GPU Computing SDK code samples

Save them to some directory on your computer. ~/Downloads sounds nice.

Install the Driver

1) Exit the GUI by pressing Ctrl+Alt+F1

2) Log in using username/password

3) Kill the X server by issuing:

$ sudo /etc/init.d/gdm stop

4) Assuming you only have the 3 NVIDIA files in your ~/Downloads directory, give them all execution permission:

6) If you get an error about the script failing, say “OK” to continue anyway.

7) Say “No” if asked to run the nvidia-xconfig utility.

8) Restart the GUI with:

$ sudo /etc/init.d/gdm start

OR reboot the system:

$ sudo shutdown –r now

9) Login and make sure that the correct version of the driver was installed: System -> Administration -> NVIDIA X Server Settings. Check the “NVIDIA Driver Version” field in “X Server Information.” It should match the file version you just installed (260.19.26 in this case).

Install the CUDA Toolkit and SDK

1) If, for some reason, you have used the CUDA SDK previously, remove all the files from /usr/local/cuda and ~/NVIDIA_GPU_Computing_SDK.

2) Install the toolkit:

$ sudo ./cudatoolkit_3.2.16_linux_32_ubuntu10.04.run

3) Define PATH variables to include the new directory (note: change lib to lib64 for 64-bit installations):

4) Optional: You many notice that you have to re-type the export lines every time you restart the computer. This can quickly become a real pain. If you want to have Ubuntu (or any Linux variant with Bash) call them on startup, use your favorite editor to open ~/.bashrc and add the following lines (I put them at the end):

Granted this is a bit dated, but I figured I would post the specs of my “new” computer. I built it back in June – mostly with the intention of gaming and research. However, it’s been mostly used for research. I chose an NVIDIA graphics card for CUDA (it apparently has a bit more support than ATI’s Stream).