views:

4587

answers:

3

This is an incredibly basic question, but how do I start a new CUDA app in visual studio 2008? I have found tons and tons of documentation about CUDA related matters, but nothing about how to start a new project. I am working with Windows 7 x64 Visual Studio 2008 C++. I would really like to find some sort of really really basic Hello World app to just get a basic program compiling and running.

Edit:

I tried your steps Tom. I setup a console app. I then deleted the default .cpp it drops in and copied over the three files from the template project just to have something to compile. When I compile that, template_gold.cpp complained about not having stdafx.h included, so i included that. Now the build fails with this:

1>------ Build started: Project: CUDASandbox, Configuration: Debug x64 ------
1>Compiling...
1>template_gold.cpp
1>Linking...
1>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup
1>D:\Stuff\Programming\Visual Studio 2008\Projects\CUDASandbox\x64\Debug\CUDASandbox.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://d:\Stuff\Programming\Visual Studio 2008\Projects\CUDASandbox\CUDASandbox\x64\Debug\BuildLog.htm"
1>CUDASandbox - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
+2  A: 
  • Install CUDA VS wizard. It will setup VS and add CUDA Project to the "new project" menu.
  • Make sure that you have x64 compiler installed (must be checked during VS install).
  • Check if you have x64 libs, includes, nvcc dir and in the search path.
  • Create new project using CUDA template.
  • Change project type to x64 and CUDA setting to Native (if you have nv cuda-enabled card) or emulation otherwise.
  • The template will create custom build rules that compile .cu files with nvcc and other files with default compiler.
  • if, vs is trying to compile .cu files with C/C++ compiler, click on that file in solution explorer and disable compilation for that files (red dot on file's icon)

Additional info about installing CUDA wizard on VS2008 can be found here and here

[edit]
If you don't want to use wizard you have to setup CUDA lib/include/nvcc paths manually and add custom build rules to each new CUDA program. For additional info how to do it take a look at Tom's Answer.

beermann
How do you do it without the CUDA wizard?
Mr Bell
Thanks for your note about setting the paths, I've added the detail to my answer for completeness.
Tom
+11  A: 
Tom
I tried your setup and had some problems. I edited my original post with the details.
Mr Bell
When you create the new console project, you should choose to create an empty project. It looks like you may have chosen to use precompiled headers, that should be possible but it is simpler to start with an empty project. The link error says that it could not find *main*, is this in the .cpp or the .cu file? It also seems the .cu files are not being built, check that the CUDA Build rule is enabled (has a tick next to it in the *Custom Build Rules* dialog).
Tom
Ok, starting from an empty project seems to have helped. Thank you. I take your point about the cutil not being a good long term solution. However at this point I just want to get my own project compiling so I am using the basic template code that nVidia provided with sdk, and it makes use of the cutil stuff. Right now I am getting the error: indentifer "cutilBankChecker" is undefined
Mr Bell
A lot of the cutil functionality is provided through online functions or macros, but some is provided by the static library cutil32D.lib (or 64, or without D for release mode). Make sure you have built cutil and are linking with the lib. Alternatively, ditch cutil!
Tom
+1  A: 

You may want to take a look at this guide: http://www.programmerfish.com/how-to-run-cuda-on-visual-studio-2008-vs08/

Salman Ul Haq