/// Parallel Panorama ///

April 24, 2008

Getting started with CUDA

Filed under: GPU — Tags: — llpanorama @ 9:34 am

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.)

I downloaded and installed the free Visual C++ 2005 Express Edition to use with CUDA. Then I downloaded three things from the CUDA website:

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.

Display Properties window

Then I re-ran the deviceQuery program and I got the following result:

Results of deviceQuery

Success!

So now I’m ready to begin using CUDA.

14 Comments »

  1. btw, you will get a similar “Cuda error in file ‘deviceQuery.cu’ in line 53 : initialization error.” message if you try to remote desktop to a machine setup for CUDA and try to run the samples – I guess that has something to do with the way windows treats remote displays – quite annoying though…

    Comment by Darren — June 6, 2009 @ 4:55 pm

  2. I cant run the very same project solution in Debug mode, with my Vista 32 and VS 2005. However i can when i compile with Release mode. When i try it in debug mode VS gives error msgs like : 1>—— Build started: Project: deviceQuery, Configuration: Debug Win32 ——
    1>deviceQuery : warning PRJ0009 : Build log could not be opened for writing.
    1>Make sure that the file is not open by another process and is not write-protected.
    1>deviceQuery : error PRJ0006 : Could not open the temporary file ‘c:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\projects\deviceQuery\Debug\BAT00000241244988.bat’. Make sure the file exists and that the directory is not write-protected.
    1>deviceQuery : error PRJ0004 : Could not generate command line for the ‘VCCustomBuildTool’ tool.
    1>Build log was saved at “file://c:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\projects\deviceQuery\Debug\BuildLog.htm”
    1>deviceQuery – 2 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    do you have any idea about how to come over this problem.

    Comment by yigit — February 25, 2009 @ 12:44 pm

  3. [...] CUDA and unleashing the power of your graphics card for everyday processing tasks head over to the first tutorial. Social [...]

    Pingback by CUDA: One of the Ways Forward | Computer System Reviews — January 26, 2009 @ 12:05 pm

  4. Hello,I selected the emuDebug configuration, built it and ran deviceQuery.sln without problem, but the SobelFilter but there was an error.
    Do you any way to read an image using teh emuDebug?
    Thanks in advance.

    Comment by Sidney Lima — December 10, 2008 @ 11:52 pm

  5. You never actually mention what interaction you set up or observed between the stuff installed by NVidia and the stuff installed by Microsoft.

    Comment by Andrew — November 24, 2008 @ 12:05 am

  6. I get all the same messages (in a slightly different order) except for the first-chance exception caused by cudaError at memory location 0×0012fc74. It appears that you are getting an error indication from the CUDA API. I’m not sure why if you are running histogram256 without modification.

    One thing I did notice is that you installed the CUDA SDK within the histogram256 directory. You might re-install the CUDA SDK in its default directory and see if this affects your results.

    Comment by llpanorama — June 10, 2008 @ 6:49 am

  7. Now after i adjust the directories for the includes and lib and so on in the visula studio 2005
    i tried to run the sample code example histogram256

    the out put was as the following
    ‘histogram256.exe’: Loaded ‘C:\Documents and Settings\Josef\Desktop\histogram256\NVIDIA CUDA SDK\bin\win32\Debug\histogram256.exe’, Symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\ntdll.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\kernel32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\CUDA\bin\cudart.dll’, Binary was not built with debug information.
    ‘histogram256.exe’: Loaded ‘C:\Documents and Settings\Josef\Desktop\histogram256\NVIDIA CUDA SDK\bin\win32\Debug\cutil32D.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\nvcuda.dll’, Binary was not built with debug information.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\user32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\gdi32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\opengl32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\msvcrt.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\advapi32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\rpcrt4.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\glu32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\ddraw.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\dciman32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\lpk.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\usp10.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\nvapi.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\ole32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\oleaut32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\shlwapi.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\shell32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\setupapi.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll’, No symbols loaded.
    ‘histogram256.exe’: Loaded ‘C:\WINDOWS\system32\comctl32.dll’, No symbols loaded.
    First-chance exception at 0×7c812a5b in histogram256.exe: Microsoft C++ exception: cudaError_enum at memory location 0×0012fc24..
    First-chance exception at 0×7c812a5b in histogram256.exe: Microsoft C++ exception: cudaError at memory location 0×0012fc74..
    The program ‘[1520] histogram256.exe: Native’ has exited with code 1 (0×1).

    can you give me any advice of what iam doing wrong ?

    Comment by Eng_Olfat — June 10, 2008 @ 2:34 am

  8. Which version of Visual C++ Express did you install? If it is the latest version (2008), then it won’t work with CUDA. For CUDA, you need Visual C++ 2003 or 2005.

    You should be able to run CUDA if you use your Visual Studio 2005.

    Comment by llpanorama — June 9, 2008 @ 8:25 am

  9. Hello iam trying to work with COda undr windows XP 64x
    i installled Microsoft visual studio 2005
    and also visual c++ express edition

    i installed :
    NVIDIA_CUDA_toolkit_beta20a_XPVista64.exe
    NVIDIA_CUDA_sdk_beta20b_XPVista64.exe
    NVIDIADisplayWin2KAMD64(174_55)Int0414.exe
    also i installed Nvidia Driver v. 169.61

    i tried to run some samples using nvcc but it gives me the following error :

    nvcc fatal : nvcc cannot find a supported cl version. Only MSVC 7.1 and MSVC 8
    .0 are supported

    i was wondering if you can help me knowing that i have NVidia Quadro 4400

    thanks

    Comment by Eng_Olfat — June 9, 2008 @ 7:02 am

  10. Great article / blog here. This released some of the questions I myself had entertained so far.

    Comment by john — June 4, 2008 @ 5:34 am

  11. Thanks Dave. Your article is most informative. I will try it today itself.

    Comment by Ankan — May 31, 2008 @ 9:57 am

  12. Ankan:

    Yes, you can develop CUDA programs without having a GPU installed on your PC. See my blog post “My first CUDA program!” for details on how to setup a CUDA program under MS Visual C++ and how to enable the CUDA emulator.

    Comment by llpanorama — May 31, 2008 @ 9:54 am

  13. Hi, Can I develop a CUDA program without having a GPU? I mean just the development work. Does the emulator work without the GPU?

    Comment by Ankan — May 31, 2008 @ 9:16 am

  14. [...] — llpanorama @ 9:04 am I got CUDA setup and running with Visual C++ 2005 Express Edition in my previous post. Now I’ll write my first CUDA program. It’s a modification of an example program from a [...]

    Pingback by My first CUDA program! « /// Parallel Panorama /// — May 21, 2008 @ 9:04 am


RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.