NVCC not working with CLion

After hours, I've finally managed to get NVCC working from console.

And by this I mean that if I just open windows console and type "nvcc main.cu", it works and I'm getting output file.

To do this I had to download VC2015 (14.0) and set environment variable pointing to cl.exe file.

Ok, but now I would like to compile my CUDA code with CMake. So I changed the line:

project(cuda_ts0)

to:

project(cuda_ts0 LANGUAGES CXX CUDA)

But now I get CMake sync errors:

 

"C:\Program Files\IDE\CLion_2018.1.2\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\c++\cuda_ts0
-- The CXX compiler identification is GNU 7.2.0
-- The CUDA compiler identification is NVIDIA 9.1.85
-- Check for working CXX compiler: C:/mingw/mingw64/bin/g++.exe
-- Check for working CXX compiler: C:/mingw/mingw64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin/nvcc.exe
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin/nvcc.exe -- broken
CMake Error at C:/Program Files/IDE/CLion_2018.1.2/bin/cmake/share/cmake-3.10/Modules/CMakeTestCUDACompiler.cmake:46 (message):
  The CUDA compiler

    "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/bin/nvcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/c++/cuda_ts0/cmake-build-debug/CMakeFiles/CMakeTmp
   
    Run Build Command:"C:/mingw/mingw64/bin/mingw32-make.exe" "cmTC_6a6fd/fast"
    C:/mingw/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_6a6fd.dir\build.make CMakeFiles/cmTC_6a6fd.dir/build
    mingw32-make.exe[1]: Entering directory 'C:/c++/cuda_ts0/cmake-build-debug/CMakeFiles/CMakeTmp'
    Building CUDA object CMakeFiles/cmTC_6a6fd.dir/main.cu.obj
    C:\PROGRA~1\NVIDIA~2\CUDA\v9.1\bin\nvcc.exe    -D_WINDOWS -Xcompiler="/W3 /GR /EHsc"  -Xcompiler="-MDd -Zi -Ob0 -Od /RTC1"   -x cu -c C:\c++\cuda_ts0\cmake-build-debug\CMakeFiles\CMakeTmp\main.cu -o CMakeFiles\cmTC_6a6fd.dir\main.cu.obj -Xcompiler=-FdCMakeFiles\cmTC_6a6fd.dir/,-FS
    main.cu
    Linking CUDA device code CMakeFiles\cmTC_6a6fd.dir\cmake_device_link.obj
    "C:\Program Files\IDE\CLion_2018.1.2\bin\cmake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_6a6fd.dir\dlink.txt --verbose=1
    C:\PROGRA~1\NVIDIA~2\CUDA\v9.1\bin\nvcc.exe -D_WINDOWS -Xcompiler="/W3 /GR /EHsc"  -Xcompiler="-MDd -Zi -Ob0 -Od /RTC1"  -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/cmTC_6a6fd.dir/main.cu.obj -o CMakeFiles\cmTC_6a6fd.dir\cmake_device_link.obj kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib  -Xcompiler=-FdC:\c++\cuda_ts0\cmake-build-debug\CMakeFiles\CMakeTmp\CMakeFiles\cmTC_6a6fd.dir\,-FS
    main.cu.obj
    kernel32.lib
    user32.lib
    gdi32.lib
    winspool.lib
    shell32.lib
    ole32.lib
    oleaut32.lib
    uuid.lib
    comdlg32.lib
    advapi32.lib
    Linking CUDA executable cmTC_6a6fd.exe
    "C:\Program Files\IDE\CLion_2018.1.2\bin\cmake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_6a6fd.dir\link.txt --verbose=1
    "C:\Program Files\IDE\CLion_2018.1.2\bin\cmake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_6a6fd.dir --manifests  -- link /nologo CMakeFiles/cmTC_6a6fd.dir/main.cu.obj CMakeFiles\cmTC_6a6fd.dir\cmake_device_link.obj  /out:cmTC_6a6fd.exe /implib:cmTC_6a6fd.lib /pdb:C:\c++\cuda_ts0\cmake-build-debug\CMakeFiles\CMakeTmp\cmTC_6a6fd.pdb /version:0.0    /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib  -LIBPATH:"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/lib/x64" "cudadevrt.lib" "cudart_static.lib"
    RC Pass 1: command "rc /foCMakeFiles\cmTC_6a6fd.dir/manifest.res CMakeFiles\cmTC_6a6fd.dir/manifest.rc" failed (exit code 0) with the following output:
    The system cannot find the file specifiedmingw32-make.exe[1]: *** [CMakeFiles\cmTC_6a6fd.dir\build.make:116: cmTC_6a6fd.exe] Error -1
    mingw32-make.exe[1]: Leaving directory 'C:/c++/cuda_ts0/cmake-build-debug/CMakeFiles/CMakeTmp'
    mingw32-make.exe: *** [Makefile:125: cmTC_6a6fd/fast] Error 2
   

 

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)
 
The complete CMake script is:
 
cmake_minimum_required(VERSION 3.10)
project(cuda_ts0 LANGUAGES CXX CUDA)

include_directories("C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.1/include")

set(CMAKE_CXX_STANDARD 11)

add_executable(cuda_ts0 main.cu)
4

Please sign in to leave a comment.