views:

128

answers:

3

How to Compile CUDA App is Visual Studio 2010 ?

Here are my steps: 1. Create Empty C++ project without precompiled headers 2. Add main.cpp

int main()
{
 return 0;
}
  1. Add kernels.cu

    I referred to sample project MAtrixMul and copied its settings step by step. it can be complied now

#include "cuda.h"

__global__ void VecAdd(float* A, float* B, float* C)
{
 int i = threadId.x;
 C[i] = A[i] + B[i];
}
  1. Right-Click on project -> Build customizations -> Check cuda 3.2
  2. kernels.cu -> properties ->Compile with CUDA C/C++
  3. TRY Compiling: I get error:

Error 37 error : This version of the CUDA Toolkit does not support the v100 compiler. Please verify that the Platform Toolset property is set to v90 under the General node of the project properties. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 3.1.targets 157 4 dfdfs

  1. Change Platform ToolSet to v90
  2. TRY Compiling: I get errors:

Error 38 error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.1\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2008 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.1\include" -G0 --keep-dir "Debug\" -maxrregcount=32 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\kernels.obj" "E:\Projects!Probing\dfdfs\kernels.cu"" exited with code 2. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 3.1.targets 272 4 dfdfs

Error 37 error : identifier "threadId" is undefined E:\Projects!Probing\dfdfs\kernels.cu 5 1 dfdfs

Please healp me out.

Thanks, Ilya

+1  A: 

I found this post on the cuda forums at nVidia. One of the moderators says (Nov 09: We don't support VS2010 yet).

This may not be the case any longer, but that your error message states that the CUDA toolkit version you're using doesn't support the V100 compiler, would suggest that you may need to upgrade your CUDA toolkit.

If you've got the latest version, check and see if the CUDA toolkit supports VS2010 yet.

v90 is a way of referring to the compiler that comes with VS2008, so I'd assume that VS2010 is compiler v100.

Maybe you've got an MSDN subscription and can fall back to VS2008.

This SO post would also seem to suggest that CUDA doesn't support VS2010 compiler (yet!)

freefallr
you are wrong, it IS supported now
portland
I didn't say it wasn't supported, I said that I'd found a number of old posts that said it wasn't _yet_ supported.
freefallr
they are about rc. I've fixed the problem(see my answer).
portland
great stuff. the error message you'd reported prompted checking for latest version.
freefallr
Any cuda stuff I've done has been on VS2008, I haven't had a chance to give it a go with VS2010 yet ...
freefallr
+1  A: 

Visual Studio 2010 is definitely supported -- be sure to use the recently released nSight 1.5 (not the beta). I haven't updated the question I asked, but @portland, you've followed all of the correct steps. You simply have a typo in your kernel.

You've referenced threadId.x instead of threadIdx.x -- note the x.

M. Tibbits
i've fixed that, and still was getting exited with code 2.Anyhow, i referred to sample project MAtrixMul and copied its settings step by step. it worked!
portland
This path: `"E:\Projects!Probing\dfdfs\kernels.cu"` appears suspicious with an exclamation point in it.
M. Tibbits
@M. Tibbits,thanks, but it doesn't matter. i've figured out what's the problem. i just cant close the discussion now.
portland
A: 

i referred to sample project MAtrixMul and copied its settings step by step. it can be complied now, but doesnt process any calculations. The problem is described here at SO in details

You can view my project with all it needs from my post at nvidia forums (2.7 kb)

Thanks, Ilya

portland