0

for a lab we're suppose to work on I need to set up Cuda with Visual Studio 2012 and run some tests. What I've done:

  • Install Cuda 5.5 + Edit build configurations.
  • Visual Studio 2012 is installed.
  • In the project, right click -> Build Configurations and choose Cuda 5.5
  • Project -> Properties -> VC++ directories: Set include/lib directories from Cuda directory.

Now, I was under the impression that after doing all this I should have no need to put "#include cudafiles" in my classes, they should be automatically imported, no?

I'm not getting the following as undefined:

  • cudaFree
  • cudaError
  • HANDLE_NULL

The following as 'device is not a type name'

__device__

And __global__ has no storage class or identifier.

I've spent hours and hours and hours trying to get this to work, following tutorials online, but I just can't get it to run properly. The code I'm using can be found here:

https://bitbucket.org/mrfright/cuda_by_example/src/bd759a6527ffa1b88420fc09acbc52f88c0587d2/appendix_a/?at=default

You can see in those files only 'lock.h' and 'book.h' are being included. I am including both of those.

Also, I am very new to C and VS so I may be leaving out a lot of important info.. please advice me to anything you may need to help assess this!! Thanks!

einpoklum
  • 118,144
  • 57
  • 340
  • 684
Jordan H
  • 181
  • 1
  • 2
  • 11
  • did you follow the instructions in the [getting started guide](http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-microsoft-windows/index.html) ? If so, were you able to [build any of the sample projects](http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-microsoft-windows/index.html#compiling-sample-projects) successfully? Did you install Visual Studio *before* installing CUDA 5.5? Also, don't be fooled by the red underlines in Visual Studio. That is an intellisense error but may not actually constitute a problem in compiling or running codes. – Robert Crovella Feb 26 '14 at 02:37
  • I did follow that exact one actually. VS was installed before Cuda, could that be an issue. Also, if I run the sample Cuda program I get a ton of 'Cannot find or open the PDB file' even though I am obtaining symbols from the microsoft server. – Jordan H Feb 26 '14 at 02:42
  • To run a sample project, you have to open one of the sample projects in visual studio. Did you read the getting started guide? It suggests opening the `bandwidthTest` project. Is that the project you tried to compile or run? – Robert Crovella Feb 26 '14 at 02:49
  • I reinstalled VS. I can run the bandwidthTest. It runs in the console but VS is still littered with 'cant find or open pdb file'. Also, if I go to build a new project now there is no Nvidia option. – Jordan H Feb 26 '14 at 03:02
  • There is no CUDA option now, because you should install CUDA 5.5 *after* installing VS. CUDA 5.5 modifies your existing VS install so that you can make new CUDA projects. But if you reinstall VS, you lose those changes. Follow the directions in the getting started guide. You should have VS already installed before you start installing CUDA 5.5. Then, before creating your own projects, you should try building one of the sample projects. The can't open PDB thing sounds like some of your projects were renamed or moved incorrectly, or didn't install correctly. – Robert Crovella Feb 26 '14 at 03:07
  • I've been given an existing directory, full of cu / header files. What is the best way for me to modify and run individual files from that directory in visual studio. It seems like every file needs a 'project' to be built in order to run. – Jordan H Feb 26 '14 at 05:03
  • Yes, in visual studio you have to create projects to build code. You can either modify an existing CUDA project (which is why I was asking if you could compile and run any of the sample projects) or create a new CUDA project. – Robert Crovella Feb 26 '14 at 05:57
  • Ok, I'm starting to get it. Now I am getting 'atomicCAS' and 'atomicEXch' are undefined. As well as error MSB3721 – Jordan H Feb 26 '14 at 06:02
  • most [atomics](http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#atomic-functions) require a certain compute capability level to be specified when compiling. You can change this in the project settings. If you don't specify a higher compute capability when compiling, these will be undefined. – Robert Crovella Feb 26 '14 at 06:09
  • So.. I can't run the code? I'm using an nvidia 9800 GT. I can run the sample codes, but as soon as I start using any of the 'Cuda By Example' code, I can't get it to run. – Jordan H Feb 26 '14 at 06:26
  • [9800GT is compute capability 1.0](https://developer.nvidia.com/cuda-gpus), so you won't be able to use any atomics. And there are any number of other GPU computing features that may require a compute capability higher than 1.0. I can't say anything specific about the "CUDA By Example" codes, as I have not looked at them recently. But if they use atomics, for example, you'll need some other GPU to run them on. – Robert Crovella Feb 26 '14 at 06:40
  • Ah, crap. Well thank you anyways, I appreciate the help. – Jordan H Feb 26 '14 at 06:50

1 Answers1

2

a few key points extracted from the discussion in the comments:

  • when installing CUDA on windows, make sure VS is installed first. The CUDA toolkit install modifies VS to make compiling CUDA code easier. If VS is not installed or you install/reinstall later, you won't get these modifications.
  • follow the instructions in the getting started guide including the running of sample projects followed by the building of sample projects. The first point at which you have trouble will be instructive as to what the actual problem is. If you just jump to the end (i.e. trying to create/build/run your own project), it won't be clear where the problem is.
  • You can build your own CUDA project either by opening an existing project and modifying it, or else creating a new project using the wizard. When just starting out, it may be easier for new users to try modifying an existing project first.
  • Be aware that various CUDA programs may require a specific compute capability. This means both that your device must support that compute capability, and that you are compiling correctly for that compute capability. You can determine the compute capability of your device by running the deviceQuery sample. You can change the compute capability that you are compiling for in the VS project CUDA settings.
  • when writing your own CUDA code, and definitely if you are having trouble, you should always do proper cuda error checking
  • Also be aware that asking questions about how to get drivers loaded, etc. and sorting out machine configuration issues, will very often be considered off-topic for stack overflow. Many questions like this get close votes for this reason.
Community
  • 1
  • 1
Robert Crovella
  • 143,785
  • 11
  • 213
  • 257