(CUDA)nvcc can't parse the toolkit path properly in my project, while in a sample project it can
I have been trying to add a .cu file into my own(dll) win32 project and compile it, using VS2008 on Windows7. I was able to compile a .cu in the cppIntegration sample project, but in my project I was having issues.
At first, I got the error "Don't know what to do with "Toolkit...". It seems nvcc was having issues with the fact that the toolkit has spaces in it's path. When renaming the NVIDIA tool kit folder to have no spaces, I got the same error but now it said the same starting from "Files", which is part of the "Program files" folder which also have a space.
Do notice that in the cppIntegration it worked properly, eventhough it had the exact same path. So I SymbLink the toolkit path, and now I开发者_如何学运维 got a different error when compiling the .cu file in my project(but not in cppIntegration). "Could not find the specified path". I assume this refers to the same path I just SymbLinked.
I believe I need to change something in the project properties. Maybe the fact I am building a dll is causing the problem. Maybe it has to do something with a 64bit version of CUDA while I do win32 in 32 bit(perhaps?).
Thank you.
Update
This is the output when I compile in VS2008.
Compiling with CUDA Build Rule... 1>"\MyCUDA\CUDA\v3.2\\bin\nvcc.exe"
-gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --machine 32 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"\MyCUDA\CUDA\v3.2\include" -maxrregcount=32 --compile -o ".\Intermediate\Release/Decoder.cu.obj" Decoder.cu
1>The system cannot find the path specified.
1>Project : error PRJ0019: A tool returned an error code from "Compiling with CUDA Build Rule..."
This is the compilation for cppIntegration:
"\MyCUDA\CUDA\v3.2\bin\nvcc.exe"
-gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --machine 32 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"\MyCUDA\CUDA\v3.2\include" -maxrregcount=32 --compile -o "Release/cppIntegration.cu.obj" cppIntegration.cu
I solved my issue. The thing is, my environment variable CUDA_PATH had \MyCUDA in it. This worked for cppIntegration because it was on C:, but not for my project because it was on E:. So I had to add C:\MyCUDA. It still doesn't explain why nvcc didn't like the spaces in the path though.
Hope someone will find this useful.
I experienced this problem with VS2008 when I specified an include path that ended with "\".
For example, I set the Configuration Property CUDA RuntimeAPI/General/Additional Include Directories to c:\projects\cuda_by_example. The tool generated an nvcc command line that included this:
... -I"c:\projects\cuda_by_example\" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\include" ...
I think the final backslash of the first parameter acted to escape the double quote and nvcc treated the start of the next parameter as part of the include path. Parsing of the next parameter then generated the "Don't know what do with Toolkit..." message.
By removing the final backslash on the directory specification, the issue was solved.
How about specifying all problematic paths in quotation marks? In most cases it solves the problem.
Otherwise, I think you have to provide us exactly what you are doing (exact command lines, etc.). Usually the general idea is OK and the problem lies in the details.
精彩评论