Getting started with CUDA
April 24, 2008 23 Comments
I’m starting the CUDA portion of my parallel programming investigations.
I started reading about CUDA in early 2007. Sixteen months later, I finally have a CUDA programming environment set up under Windows XP. (A glacial pace, I admit.) I’ll describe the steps that got me there.
I purchased an NX8600GTS graphics card for $130 from newegg.com in November of 2007. (You can get it now for $80.) This card uses the NVIDIA GeForce 8600 GPU that has 32 processing elements. I selected this card because it was a lot cheaper and smaller than a card with a full-blown 128-processor 8800 GPU. Size was important because I had to fit the card into an e-Machines T6412 PC with a small case. It also uses less power and the T6412 has a small 300W power supply. I installed the card in the PC, but I didn’t bother to load any of the packaged drivers because I would be using it as a computational coprocessor without any display attached. (You can use it as a combined coprocessor/display card, but the CUDA release notes say that CUDA-related run times would be limited to less than five seconds. I presume that’s to prevent losing control of your display if you enter an infinite loop.)
- CUDA Toolkit version 1.1 for Windows XP (x86 version)
- CUDA SDK version 1.1 for Windows XP (x86 version)
- NVIDIA Driver for Microsoft Windows XP with CUDA Support (169.21, x86 version)
The CUDA Toolkit has all the programming tools, such as the CUDA compiler (nvcc). The SDK contains a bunch of CUDA example programs. I installed both into their default directories. Then I installed the NVIDIA driver and restarted my PC. I figured that should do it.
The first thing I did with CUDA was to recompile and run the project found at
C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\projects\deviceQuery
This project just queries the system and looks for any CUDA-enabled devices that exist. I double-clicked the deviceQuery.sln project file and the project appeared in my Visual C++ 2005 IDE. I selected the Debug configuration for Win32 and rebuilt it. Then I executed the program in the debugger. A console window appeared that said:
Cuda error in file 'deviceQuery.cu' in line 53 : initialization error.
Well, that’s not good. So I selected the emuDebug configuration, built it and ran it. This configuration uses a software emulation of a CUDA device instead of the actual hardware found on the graphics card. No errors this time and I got a list of the characteristics of the emulated CUDA device, but the first line of the console output was:
There is no device supporting CUDA.
I know the graphics card is in the PC, but maybe the NVIDIA driver is screwed-up. I opened the device manager and it reported that the NVIDIA GeForce 8600 GTS display adapter was working properly. I found some hints on installing the NVIDIA driver, and one of the things I hadn’t done was disable my virus protection during driver installation. So I uninstalled the NVIDIA driver, disabled my virus scanner, reinstalled the driver, restarted my PC, reopened the deviceQuery project, rebuilt the Debug configuration, re-ran it and got exactly the same error.
So I went to the CUDA forum for Windows XP to see if anyone else had experienced this problem. Sure enough, others had reported problems with CUDA not detecting their graphics card when it was not the primary display driver. But these posts were from September of 2007; could things have changed since then? I decided to play with my display and see if there was some software switch I could toggle to make my problems magically disappear. Right-clicking on my desktop, I opened the Display Properties window and noticed that the GeForce 8600 GTS was not attached to any display. What if I attached it, even though there is no physical display connected to the card? I right-clicked on the display icon for the 8600 and selected Attached, after which I clicked on the OK button for the Display Properties window.
Then I re-ran the deviceQuery program and I got the following result:
So now I’m ready to begin using CUDA.