Getting started with CUDA

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 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 '' 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


So now I’m ready to begin using CUDA.


About dave_vandenbout
President of XESS Corp, a manufacturer of FPGA development boards.

25 Responses to Getting started with CUDA

  1. phtevenz says:

    is there a newer version of this? this is still the first result from google but i think it may be outdated though

  2. max says:

    great work, thank you =)
    I didn’t find any cuda tutorial at Nvidia’s homepage, they should give you money for that =)

    • Hosna says:

      Hello, I installed CUDA 7.5 with Visual Studio 2013. I can compile deviceQuery.cpp without error but deviceQuery.exe isn’t generating. Can anyone help me out there?

  3. Manan says:

    Nice work with the tutorial really…
    i hope you can help with this problem.
    i have installed these versions in the following order.
    1)Cudatoolkit version 3.2
    2)MS VS 2008 express
    3)cuda sdk 3.2

    the problem is that when i try to run the sample programs with _vc90.sln extension, MS VS says that that version does not support .vcproj.
    i dont know what to do after this. i havent made any changes to MS VS as yet. if there are any changes to be made, please specify.

  4. abhay srivastava says:

    thank you for such a nice explanation , it helped me a lot

  5. muni says:

    how can start with cuda programming using cuda emulator

  6. sappy says:

    Thank you so much for a nicely explained tutorial. The thing is I hate using VStudios whatnot. So, I was wondering if it is possible to use a MinGW (on Codeblocks or NetBeans or even DevCPP) to compile and run CUDA programs with nvcc. If so, any idea on how I can configure them ?

    Thanks in advance

  7. Pingback: Updating to CUDA 2.3 « /// Parallel Panorama ///

    • anubhav agrawal says:

      i have windows vista home 32 bit in my sony vaio cs24
      i dnt have nvidia graphics card
      where to download the emulator for cuda ?
      how to get started with this ?
      plz help me .

      • llpanorama says:

        The emulator is already included with the rest of CUDA; it is not a separate download.

        If you read the next entry in the blog (“My First CUDA Program”), you will see how to compile and run a CUDA program using both a GPU card and the emulator.

  8. Geovanny Giorgana says:

    Thank you very much for the hints, they were really helpful for me. I have the graphics card GeForce 8600M GT in a laptop Dell Inspiron 1520 and it worked with Cuda 2.2 instead of 2.3 and the nVidia driver 185.85 dowloaded directly from the nVidia website.

  9. Darren says:

    btw, you will get a similar “Cuda error in file ‘’ 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…

  10. yigit says:

    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.

  11. Pingback: CUDA: One of the Ways Forward | Computer System Reviews

  12. Sidney Lima says:

    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.

  13. Andrew says:

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

  14. llpanorama says:

    I get all the same messages (in a slightly different order) except for the first-chance exception caused by cudaError at memory location 0x0012fc74. 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.

  15. Eng_Olfat says:

    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 0x7c812a5b in histogram256.exe: Microsoft C++ exception: cudaError_enum at memory location 0x0012fc24..
    First-chance exception at 0x7c812a5b in histogram256.exe: Microsoft C++ exception: cudaError at memory location 0x0012fc74..
    The program ‘[1520] histogram256.exe: Native’ has exited with code 1 (0x1).

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

  16. llpanorama says:

    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.

  17. Eng_Olfat says:

    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 :
    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


  18. john says:

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

  19. Ankan says:

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

  20. llpanorama says:


    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.

  21. Ankan says:

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

  22. Pingback: My first CUDA program! « /// Parallel Panorama ///

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: