CUDA 4.0 + VS 2010 error MSB3721 ..... exited with code 2.

Hi guys,

I am trying to compile my own kernel into my app with VS2010 and I am getting this erro:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 4.0.targets(267,3): error MSB3721: The command ““C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v4.0\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 (x86)\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include” -G0 --keep-dir “Debug” -maxrregcount=32 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler “/EHsc /nologo /Od /Zi /MDd " -o “Debug\MyKernel.cu.obj” “C:\PittpattDetection-4.2.2_CUDA_Reconocimiento\PittpattDetection\MyKernel.cu”” exited with code 2.

I really don´t have any idea on how to solve it, so little info give…, has any of you dealed with this error at any time?

Thank you very very much!

This was the only error? Normally when nvcc exit there’s some kind of error displayed

No error was displayed :(

I can confirm I am getting the same rather uninformative error and would welcome some suggestions.

Hi guys

We have a reproducible for this issue and have logged a bug internally for this.

The compiler team is already taking a look at this and looking into it.

Thanks for the feedback and we have put in a fix for this.

The nvcc command line has --keep-dir “Debug” and so intermediate files are dumped in the “Debug” directory.

However the commands are ran in the current directory, so the MyKernel.cudafe1.stub.c file was not found by the preprocessor phase and was causing the error.

Suggested workaround for now:

  1. Remove
--keep-dir "Debug"

from nvcc command line. This would cause intermediate files to be created in current directory.

  1. Add
"-I."

to the nvcc command line.

  1. If the path specified in
--keep-dir "path"

is given the absolute path instead of the relative path, i.e. C:\PittpattDetection-4.2.2_CUDA_Reconocimiento\ PittpattDetection\Debug , the compilation should work correctly.

Similar error for me, but exit code is 1

I modified Daniel @ NV’s workaround in the following way:
instead of removing --keep-dir “Debug” I put $(SolutionDir)$(CudaIntDir) into Keep Directory option, so it expands to the full path.
Error is still here.

I put all this long command line into cmd.exe shell and nvcc said it can’t find cl.exe in $PATH. It’s strange because command line contains
-ccbin “D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64”. So why does it look into $PATH?
When I run vcvarsx86_amd64.bat in this command line then again invoke nvcc, it works.

When I remove --use-local-env switch, it makes attempt to compile but fails with finding windows.h

All this was done with NVidia bandwidthTest example from 4.0 RC2

VS2005 and 2008 work fine but switching to an older one than VS2010 is not a good idea for me because this will force me to abandon using AVX commands

I have similar problem, but with exited code 1:

I use VS2010, Win7x64 and GeForce310M.

Hi all, a have exactly problem:

Error 5 error MSB3721: quit from command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\bin\nvcc.exe” -gencode=arch=compute_10,code="sm_10,compute_10" --use-local-env --cl-version 2010 -ccbin “c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include” -G0 --keep-dir “Debug” -maxrregcount=0 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler “/EHsc /nologo /Od /Zi /MDd " -o “Debug\kernel.cu.obj” “C:\Users\d1\Documents\Visual Studio 2010\Projects\CudaExample2\kernel.cu”” с кодом “2”. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 4.0.targets 357 10 CudaExample2

Thank for the reply:

But, please, explain in details, how make changes to the nvcc command line?

Has anyone found a workaround for this issue yet?

I have just installed VS2010 and converted all my old projects.
They all used to work fine in VS2008, but I get exactly this same ‘MSB3721’ error when trying to compile a new (or just converted) CUDA project.

This also happens even when creating a new project from scratch, using Visual Studio’s wizard (File->New->Project->Nvidia->CUDA->CUDA 4.0 Runtime).

The only CUDA projects I managed to compile are the samples provided with the SDK.

Does anybody have any thoughts about it? I tried all suggestions on this topic and none worked for me.
Also, this seems to be the only thread regarding this issue.

Thanks.

Did you manage to try out the above suggested solution?

  1. Right-click on your project and then select Properties. After that navigate to the CUDA C/C++ tab on the tree and click on “Common”.

From there, you should see a field named “Keep Directory”. Delete any value that might be in this field.

  1. Under CUDA C/C++ tab → Command Line, please key in -I. under Additional Options box. (Note: the value to be keyed in is -I. , please don’t forget the . behind -I )

I was able to fix it with these steps you just described! Indeed I was not including the command line ‘-I.’ correctly.

However, the funny thing is that there was something else causing the error too.

What I noticed is that when I applied your suggestion, it fixed only some of the solutions that were not working.

Than I realized that the others that did not get fixed had white spaces in some of the sub-folders’ names they were kept and renaming them or moving the solution to another folder without white spaces fixed the problem.

If I either remove your suggestion or add white space to the folders names, the error starts again.

The interesting thing is that in vs2008 with CUDA 4.0 I did not have problems with the folders’ names.

Anyway, I’m glad this problem is finally over!

Many thanks for your help!

Late, but better than never:)

I’ve got same problem with “exited code 1”. No described solution worked.

Here my solution:

Run VS2010 as administrator (Win7 - 64 bit), that’s it g

First approach was to compile under DOS => copy the nvcc command to a cmd-session. Here I had to add first some include paths (e.g. for windows.h) and had to change the ObjBase.h as described in The Official NVIDIA Forums | NVIDIA . Unlike in VS2010 here I’ve got error-messages (and warnings:). Do somebody know how I can get this warnings (and errors) in VS2010 too.

Strange 1: the cmd-session was NOT started as administrator!

Strange 2: in VS2010 I did not had to make any changes to the settings (include paths or anything else, even the IUnknown error in ObjBase.h was not there)

Hello Guys,
I am running VS10 with win7 and CUDA 5.0. I have been trying all the above for a week now and keep getting the same error back. I am student working on a final year project. It is a realtime Kinect sensor application which is why i was advised to use cuda to speed up the processes. I am however very new to cuda.

Could anyone help me debug this error. I can setup team viewer on my computer so that perhaps someone more experienced can offer to remotely access my computer and help me debug this one? Please let me know.

I found the cause of this problem.

http://stackoverflow.com/a/17670936

So I resolve this problem adding some cpp file for my project and compile this single file. Further you can compile full project.