Home > front end >  Command Prompt results in fatal error while MSVS 2019 builds CUDA example successfully
Command Prompt results in fatal error while MSVS 2019 builds CUDA example successfully

Time:10-13

I can successfully build and run the CUDA example in C:\ProgramData\NVIDIA Corporation\CUDA Samples\v11.4\0_Simple\matrixMul in MSVS 2019 Community:

C:\ProgramData\NVIDIA Corporation\CUDA Samples\v11.4\0_Simple\matrixMul>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin\nvcc.exe" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -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\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64" -x cu -I./ -I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static --threads 0 -g -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Fdx64/Debug/vc142.pdb /FS /Zi /RTC1 /MTd " -o x64/Debug/matrixMul.cu.obj "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v11.4\0_Simple\matrixMul\matrixMul.cu" ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

However, if I open a Command Prompt, copy and paste the exact command in gray, and then run it, it results in enter image description here

which does not make sense: (i) the same command is executed successfully in VS, (ii) the path to cl.exe is clearly given to the compiler.

I can always add that path to the environment variable and retry it, but before doing that, why is this happening? Has anyone else encountered this problem? I want to have the insight so to be more aware when issuing compile instructions to the Command Prompt.

CodePudding user response:

Remove --use-local-env. VS hid something. A bare minimum command to build the code:

nvcc -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -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\" -Wno-deprecated-gpu-targets -ccbin "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64" -cudart static --m64 --threads 0 -maxrregcount=0 -o matrixMul -x cu matrixMul.cpp

  • Related