I can not build CUDA project

I am having trouble with build CUDA project in CLion. I am having CLion 2020.1.2 and CUDA 11 installed on Windows 10 2004. After I create A simple CUDA project. I got following error:

With MinGW x64, the error message is like following:

C:\Users\RustedWizard\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\201.7846.88\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\RustedWizard\CLionProjects\untitled2
-- The CUDA compiler identification is unknown
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe -- broken
CMake Error at C:/Users/RustedWizard/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/201.7846.88/bin/cmake/win/share/cmake-3.16/Modules/CMakeTestCUDACompiler.cmake:46 (message):
The CUDA compiler

"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/RustedWizard/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):C:/PROGRA~2/MINGW-~1/I686-8~1.0-P/mingw32/bin/mingw32-make.exe cmTC_d6d77/fast && C:/PROGRA~2/MINGW-~1/I686-8~1.0-P/mingw32/bin/mingw32-make.exe -f CMakeFiles\cmTC_d6d77.dir\build.make CMakeFiles/cmTC_d6d77.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/RustedWizard/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeTmp'
Building CUDA object CMakeFiles/cmTC_d6d77.dir/main.cu.obj
C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe -x cu -c C:\Users\RustedWizard\CLionProjects\untitled2\cmake-build-debug\CMakeFiles\CMakeTmp\main.cu -o CMakeFiles\cmTC_d6d77.dir\main.cu.obj
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
mingw32-make.exe[1]: *** [CMakeFiles\cmTC_d6d77.dir\build.make:65: CMakeFiles/cmTC_d6d77.dir/main.cu.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'C:/Users/RustedWizard/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeTmp'
mingw32-make.exe: *** [Makefile:120: cmTC_d6d77/fast] Error 2

 

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/RustedWizard/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/Users/RustedWizard/CLionProjects/untitled2/cmake-build-debug/CMakeFiles/CMakeError.log".

[Finished]

 

With MSVC 2019 toolchain, the error message is like following:

 

C:\Users\RustedWizard\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\201.7846.88\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" C:\Users\RustedWizard\CLionProjects\untitled3
-- The CUDA compiler identification is unknown
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe -- broken
CMake Error at C:/Users/RustedWizard/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/201.7846.88/bin/cmake/win/share/cmake-3.16/Modules/CMakeTestCUDACompiler.cmake:46 (message):
The CUDA compiler

"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/RustedWizard/CLionProjects/untitled3/cmake-build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):nmake /nologo cmTC_ec123\fast && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\nmake.exe" -f CMakeFiles\cmTC_ec123.dir\build.make /nologo -L CMakeFiles\cmTC_ec123.dir\build
Building CUDA object CMakeFiles/cmTC_ec123.dir/main.cu.obj
C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe -x cu -c C:\Users\RustedWizard\CLionProjects\untitled3\cmake-build-debug\CMakeFiles\CMakeTmp\main.cu -o CMakeFiles\cmTC_ec123.dir\main.cu.obj
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x86/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'
NMAKE : fatal error U1077: 'C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.

 

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/RustedWizard/CLionProjects/untitled3/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/Users/RustedWizard/CLionProjects/untitled3/cmake-build-debug/CMakeFiles/CMakeError.log".

[Finished]

 

Anyone has any ideas?

2
15 comments

Hello!

First of all: On Windows CUDA only works with the Microsoft Visual C++ toolchain - https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html.  

Secondly: you are required to have x64 cl.exe in your PATH. Is this requirement met?

0

I see, I do not have cl.exe in my PATH. However, which cl.exe should I include in my PATH? since in MSVC toolchain, there're few of them, I don't know which to include?

0

Also, I have looked into the CMake error log, it's like following:

Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
Build flags:
Id flags: -v;--keep;--keep-dir;tmp

The output was:
1

C:\test\cmake-build-debug\CMakeFiles\3.16.5\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.2
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'


Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
Build flags:
Id flags: -v;--keep;--keep-dir;tmp

The output was:
1

C:\test\cmake-build-debug\CMakeFiles\3.16.5\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.2
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'


Determining if the CUDA compiler works failed with the following output:
Change Dir: C:/test/cmake-build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):nmake /nologo cmTC_4cc32\fast && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\nmake.exe" -f CMakeFiles\cmTC_4cc32.dir\build.make /nologo -L CMakeFiles\cmTC_4cc32.dir\build
Building CUDA object CMakeFiles/cmTC_4cc32.dir/main.cu.obj
C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe -x cu -c C:\test\cmake-build-debug\CMakeFiles\CMakeTmp\main.cu -o CMakeFiles\cmTC_4cc32.dir\main.cu.obj
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX86/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'
NMAKE : fatal error U1077: 'C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\HostX86\x64\nmake.exe"' : return code '0x2'
Stop.

 

Seems like what it complain about is that the input is too long.

Any solutions?

0

Please attach a screenshot of `File | Settings | Build, Execution, Deployment | Toolchains` (please capture the screenshot after the compiler detection is completed).

0

I think the problem is triggered by the update of the visual studio 16.6.2. Because with toolchain "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/" and "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe", I was able to compile the project. Also, with cmake gui, the nvcc pass the cmake process.

 

My log:

Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
Build flags:
Id flags: -v;--keep;--keep-dir;tmp

The output was:
1
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.6.0+5ff7b0c9e
版权所有(C) Microsoft Corporation。保留所有权利。

生成启动时间为 2020/6/28 13:48:25。
节点 1 上的项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(默认目标)。
PrepareForBuild:
正在创建目录“Debug\”。
正在创建目录“Debug\CompilerIdCUDA.tlog\”。
InitializeBuildStatus:
正在创建“Debug\CompilerIdCUDA.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
AddCudaCompileDeps:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\cl.exe /E /nologo /showIncludes /TP /D__CUDACC__ /D_MBCS /I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" /I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin" /I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" /I. /FIcuda_runtime.h /c C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu
项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(1)正在节点 1 上生成“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(1:2) (CudaBuildCore 个目标)。
CudaBuildCore:
Compiling CUDA source file CMakeCUDACompilerId.cu...
cmd.exe /C "C:\Users\yangy\AppData\Local\Temp\tmpc140474f141541609bc8ec883f938674.cmd"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"

C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.0.targets(770,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"”已退出,返回代码为 1。 [C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj]
已完成生成项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(CudaBuildCore 个目标)的操作 - 失败。
已完成生成项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(默认目标)的操作 - 失败。

生成失败。

“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(默认目标) (1) ->
“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(CudaBuildCore 目标) (1:2) ->
(CudaBuildCore 目标) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.0.targets(770,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"”已退出,返回代码为 1。 [C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj]

0 个警告
1 个错误

已用时间 00:00:01.22


Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
Build flags:
Id flags: -v;--keep;--keep-dir;tmp

The output was:
1
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.6.0+5ff7b0c9e
版权所有(C) Microsoft Corporation。保留所有权利。

生成启动时间为 2020/6/28 13:48:26。
节点 1 上的项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(默认目标)。
PrepareForBuild:
正在创建目录“Debug\”。
正在创建目录“Debug\CompilerIdCUDA.tlog\”。
InitializeBuildStatus:
正在创建“Debug\CompilerIdCUDA.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。
AddCudaCompileDeps:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\cl.exe /E /nologo /showIncludes /TP /D__CUDACC__ /D_MBCS /I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" /I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin" /I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" /I. /FIcuda_runtime.h /c C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu
项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(1)正在节点 1 上生成“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(1:2) (CudaBuildCore 个目标)。
CudaBuildCore:
Compiling CUDA source file CMakeCUDACompilerId.cu...
cmd.exe /C "C:\Users\yangy\AppData\Local\Temp\tmp9fb3b14acc084837983c20d066f1e283.cmd"
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"

C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.0.targets(770,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"”已退出,返回代码为 1。 [C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj]
已完成生成项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(CudaBuildCore 个目标)的操作 - 失败。
已完成生成项目“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(默认目标)的操作 - 失败。

生成失败。

“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(默认目标) (1) ->
“C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj”(CudaBuildCore 目标) (1:2) ->
(CudaBuildCore 目标) ->
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.0.targets(770,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -v -g -D_MBCS -Xcompiler "/EHsc /W0 /nologo /Od /FdDebug\vc142.pdb /FS /Zi /RTC1 /MDd " -o Debug\CMakeCUDACompilerId.cu.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CMakeCUDACompilerId.cu"”已退出,返回代码为 1。 [C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\3.17.0\CompilerIdCUDA\CompilerIdCUDA.vcxproj]

0 个警告
1 个错误

已用时间 00:00:01.24


Determining if the CUDA compiler works failed with the following output:
Change Dir: C:/Users/yangy/Documents/Parallel/CuckooHashing/cmake-build-debug-visual-studio/CMakeFiles/CMakeTmp

Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe cmTC_2b297.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && 用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.6.0+5ff7b0c9e
版权所有(C) Microsoft Corporation。保留所有权利。

Compiling CUDA source file main.cu...

C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\CMakeTmp>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -D"CMAKE_INTDIR=\"Debug\"" -D"CMAKE_INTDIR=\"Debug\"" -D_MBCS -Xcompiler "/EHsc /W1 /nologo /O2 /FdcmTC_2b297.dir\Debug\vc142.pdb /FS /Zi /MD " -o cmTC_2b297.dir\Debug\main.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\CMakeTmp\main.cu"
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\BuildCustomizations\CUDA 11.0.targets(770,9): error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin\nvcc.exe" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include" --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -D"CMAKE_INTDIR=\"Debug\"" -D"CMAKE_INTDIR=\"Debug\"" -D_MBCS -Xcompiler "/EHsc /W1 /nologo /O2 /FdcmTC_2b297.dir\Debug\vc142.pdb /FS /Zi /MD " -o cmTC_2b297.dir\Debug\main.obj "C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\CMakeTmp\main.cu"”已退出,返回代码为 1。 [C:\Users\yangy\Documents\Parallel\CuckooHashing\cmake-build-debug-visual-studio\CMakeFiles\CMakeTmp\cmTC_2b297.vcxproj]

 

 

 

0

Chensike89 victoryang00 please provide the following information:

  1.  A screenshot of `File | Settings | Build, Execution, Deployment | Toolchains` (please capture the screenshot after the compiler detection is completed).
  2. Please run nvcc --dryrun <some_cuda_file> in terminal and attach the output.
  3. CMake output from inside CLion where it says something about why it failed.
0

I can still build a cuda project by visual studio and it can be compiled successfully. But when i use Clion it failed with the same problem.

Can u help me? thanks a lot

.../x64 has already in my path.

 

 

ails with the following output:

Change Dir: E:/Code/CUDA/cuda1/cmake-build-debug/CMakeFiles/CMakeTmp

Run Build Command(s):nmake /nologo cmTC_25808\fast && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.26.28801\bin\HostX64\x64\nmake.exe" -f CMakeFiles\cmTC_25808.dir\build.make /nologo -L CMakeFiles\cmTC_25808.dir\build
Building CUDA object CMakeFiles/cmTC_25808.dir/main.cu.obj
C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe -x cu -c E:\Code\CUDA\cuda1\cmake-build-debug\CMakeFiles\CMakeTmp\main.cu -o CMakeFiles\cmTC_25808.dir\main.cu.obj
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'

0

Having the same problem with CUDA 11.0, MSVC 14.26, and CLion 2020.2 Beta...

I cannot get over it...

0

Hi all!

Unfortunately, we didn't manage to reproduce the issue on our side.

We kindly ask you to do the following:

  1. Update CUDA.
  2. Show your PATH values - both the result of set PATH in cmd.exe and also PATH from systempropertiesadvanced.exe (both user and system variables).
0

Following is my PATH:

User:

System:

 

Result from set PATH

 

I have just download and installed latest CUDA from Nvidia and confirmed that my Nvidia driver is the latest

 

0

Got same error in CMakeError.log:

Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: CMAKE_CUDA_COMPILER-NOTFOUND
Build flags:
Id flags: -v;--keep;--keep-dir;tmp

The output was:
No such file or directory

My OS is Ubuntu 20.04, and CUDA toolkit 11.0. CLion 2020.2.1

Actually, I can use the cmake 3.16.3 in ubuntu to successfully compile my project, but failed when I set it as the project cmake in clion--> setting-> Build.

Definitely I have add nvcc into the OS PATH and add following codes into CMakeList.txt

find_package(CUDA QUIET REQUIRED)
set(CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda-11.0/)
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-11.0/bin/nvcc")

 

2

I'm having the same issue in Windows 10, tested with CUDA 10.1 and 11.1. I get the following error when enabling CUDA in cmake:

The code builds correctly from terminal if I set vcvars64.

 

These are my environment variables:

 

And this is my toolchain configuration:

1

In my case it was caused by the PATH environment variable being too long. The errors were solved after removing some unnecessary lines from PATH.

As your PATH variable is quite long as well, it might be worth considering this.

3

I have the same problem, though the strange thing is that it worked just fine yesterday and I have no idea what has changed. I am using CLion 2020.3, MSVC 2019 14.28.29333 on Windows 10 (version 10.0.19042 Build 19042) and CMake 3.19.2 (but the same problem persists with the bundled cmake). The cmake project builds without issue using powershell but in CLion fails with 

```

D:\cmake\cmake-3.19.2-win64-x64\cmake-3.19.2-win64-x64\bin\cmake.exe -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install-msvc -G "CodeBlocks - NMake Makefiles" D:\CUDATests
-- The CUDA compiler identification is unknown
-- The CXX compiler identification is MSVC 19.28.29335.0
-- The C compiler identification is MSVC 19.28.29335.0
-- Detecting CUDA compiler ABI info
CMake Error in D:/CUDATests/cmake-build-release-visual-studio-x64/CMakeFiles/CMakeTmp/CMakeLists.txt:
CUDA_ARCHITECTURES is empty for target "cmTC_1c198".


CMake Error in D:/CUDATests/cmake-build-release-visual-studio-x64/CMakeFiles/CMakeTmp/CMakeLists.txt:
CUDA_ARCHITECTURES is empty for target "cmTC_1c198".


CMake Error at D:/cmake/cmake-3.19.2-win64-x64/cmake-3.19.2-win64-x64/share/cmake-3.19/Modules/CMakeDetermineCompilerABI.cmake:48 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
D:/cmake/cmake-3.19.2-win64-x64/cmake-3.19.2-win64-x64/share/cmake-3.19/Modules/CMakeTestCUDACompiler.cmake:19 (CMAKE_DETERMINE_COMPILER_ABI)
CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "D:/CUDATests/cmake-build-release-visual-studio-x64/CMakeFiles/CMakeOutput.log".
See also "D:/CUDATests/cmake-build-release-visual-studio-x64/CMakeFiles/CMakeError.log".

[Failed to reload]

```

The CMake error log from the build tree used by CLion is: 

```

Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/bin/nvcc.exe
Build flags:
Id flags: --keep;--keep-dir;tmp -v

The output was:
1

D:\CUDATests\cmake-build-release-visual-studio-x64\CMakeFiles\3.19.2\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.8.3
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'


Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/bin/nvcc.exe
Build flags:
Id flags: -v

The output was:
1

D:\CUDATests\cmake-build-release-visual-studio-x64\CMakeFiles\3.19.2\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.8.3
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'


Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/bin/nvcc.exe
Build flags:
Id flags: --keep;--keep-dir;tmp -v

The output was:
1

D:\CUDATests\cmake-build-release-visual-studio-x64\CMakeFiles\3.19.2\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.8.3
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'


Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.2/bin/nvcc.exe
Build flags:
Id flags: -v

The output was:
1

D:\CUDATests\cmake-build-release-visual-studio-x64\CMakeFiles\3.19.2\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.8.3
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'


Checking whether the CUDA compiler is NVIDIA using "" did not match "nvcc: NVIDIA \(R\) Cuda compiler driver":
nvcc fatal : No input files specified; use option --help for more information
Checking whether the CUDA compiler is Clang using "" did not match "(clang version)":
nvcc fatal : No input files specified; use option --help for more information
Checking whether the CUDA compiler is NVIDIA using "" did not match "nvcc: NVIDIA \(R\) Cuda compiler driver":
nvcc fatal : No input files specified; use option --help for more information
Checking whether the CUDA compiler is Clang using "" did not match "(clang version)":
nvcc fatal : No input files specified; use option --help for more information
```

CLion Toolchains: 

 

 

 

 

 

0

Indeed, I had the same issue and it's resolved by making PATH shorter!

Thanks.

0

Please sign in to leave a comment.