NVIDIA / cuda-samples

Samples for CUDA Developers which demonstrates features in CUDA Toolkit
Other
6.2k stars 1.78k forks source link

sample 1_Utilities build error #226

Open sdivens opened 1 year ago

sdivens commented 1 year ago

I got a compilation error when building bandwidthTest_vs2022.sln in 1_Utilities using vs studio 2022. The nvcc -V output in cmd.exe is:

nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Tue_Aug_15_22:09:35_Pacific_Daylight_Time_2023 Cuda compilation tools, release 12.2, V12.2.140 Build cuda_12.2.r12.2/compiler.33191640_0

os: win10 22H2 19045.3324

The exception shown in vs studio is:

1>E:\software\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.2.targets(799,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin\nvcc.exe" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" -gencode=arch=compute_60,code=\"sm_60,compute_60\" -gencode=arch=compute_61,code=\"sm_61,compute_61\" -gencode=arch=compute_70,code=\"sm_70,compute_70\" -gencode=arch=compute_75,code=\"sm_75,compute_75\" -gencode=arch=compute_80,code=\"sm_80,compute_80\" -gencode=arch=compute_86,code=\"sm_86,compute_86\" -gencode=arch=compute_89,code=\"sm_89,compute_89\" -gencode=arch=compute_90,code=\"sm_90,compute_90\" --use-local-env -ccbin "E:\software\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX64\x64" -x cu -I./ -I../../../Common -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\/include" -I../../../Common -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\include" --keep-dir x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -Xcompiler "/wd 4819" --threads 0 -DWIN32 -DWIN32 -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /FS /MT " -Xcompiler "/Fdx64/Release/vc143.pdb" -o E:\vsstudio_project\cuda-samples-master\Samples\1_Utilities\bandwidthTest\x64\Release\bandwidthTest.cu.obj "E:\vsstudio_project\cuda-samples-master\Samples\1_Utilities\bandwidthTest\bandwidthTest.cu"”已退出,返回代码为 1。

But when I execute the command in cmd.exe, there is no output at all until execution ends.

I have also tried cleaning and rebuilding the solution, as well as deleting temporary files, but the error persists. Please let me know if any other information is needed to diagnose the problem.

jingooo5 commented 9 months ago

I had the same problem when building the projects with vs2022 and CUDA 12.3. I found that the path of include parameter has wrong slash. In my case, it is -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\/include"

I'm not good at VS and cpp, so I don't know how to change this options while VS build the project. If you have solved the problem, can you tell me how to do it?