1

I created a template Clion project in CUDA and it does not seem to work at all.

Clion new projct creation

The only thing which I changed is this line in CMakeLists.txt:

set(CMAKE_CUDA_COMPILER "/usr/local/cuda-10.1/bin/nvcc")

So it looks like this:

cmake_minimum_required(VERSION 3.17)

set(CMAKE_CUDA_COMPILER "/usr/local/cuda-10.1/bin/nvcc")
project(test CUDA)

set(CMAKE_CUDA_STANDARD 14)

add_executable(test main.cu)

set_target_properties(
        test
        PROPERTIES
        CUDA_SEPARABLE_COMPILATION ON)

It does not matter if I try to build the program from Clion or terminal, I always get:

CMake Error at /snap/clion/129/bin/cmake/linux/share/cmake-3.17/Modules/CMakeTestCUDACompiler.cmake:46 (message):
  The CUDA compiler

    "/usr/local/cuda-10.1/bin/nvcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/user/CLionProjects/test/cmake-build-debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make cmTC_bafff/fast && /usr/bin/make  -f CMakeFiles/cmTC_bafff.dir/build.make CMakeFiles/cmTC_bafff.dir/build
    make[1]: Entering directory '/home/user/CLionProjects/test/cmake-build-debug/CMakeFiles/CMakeTmp'
    Building CUDA object CMakeFiles/cmTC_bafff.dir/main.cu.o
    /usr/local/cuda-10.1/bin/nvcc     -x cu -c /home/user/CLionProjects/test/cmake-build-debug/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_bafff.dir/main.cu.o
    In file included from /usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/cuda_runtime.h:83,
                     from <command-line>:
    /usr/local/cuda-10.1/bin/../targets/x86_64-linux/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
          |  ^~~~~
    make[1]: *** [CMakeFiles/cmTC_bafff.dir/build.make:86: CMakeFiles/cmTC_bafff.dir/main.cu.o] Error 1
    make[1]: Leaving directory '/home/user/CLionProjects/test/cmake-build-debug/CMakeFiles/CMakeTmp'
    make: *** [Makefile:141: cmTC_bafff/fast] Error 2
        

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


-- Configuring incomplete, errors occurred!
See also "/home/user/CLionProjects/test/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/home/user/CLionProjects/test/cmake-build-debug/CMakeFiles/CMakeError.log".

I use Ubuntu 20, Clion (2020.2.4) is from the newest snap. I also tried to run it with different versions of gcc and g++ (7, 8 and 9) and CMake (3.17 (snap), 3.18 and 3.19). Additionally:

  • Nvidia driver version: 455.23.0
  • CUDA Version: 11.1

The path /usr/local/cuda-10.1/bin/nvcc is correct.

prenc
  • 151
  • 2
  • 13
  • You claim to be using CUDA 11.1 but your CMake is locating CUDA 10.1 for this test that is failing. CUDA 11.1 would not be located at `/usr/local/cuda-10.1...` – Robert Crovella Oct 21 '20 at 19:11
  • @RobertCrovella Yes, that is strange, `nvidia-smi` shows cuda 11.1 but I have cuda 10.1 installed. I must have made real mess. How is it even possible? – prenc Oct 21 '20 at 21:28
  • https://stackoverflow.com/questions/53422407/different-cuda-versions-shown-by-nvcc-and-nvidia-smi/53504578#53504578 – Robert Crovella Oct 21 '20 at 21:32

1 Answers1

2

It started working when I changed the default system gcc alternative from version 9 to 8. (Ubuntu 20 default gcc version is 9)

sudo update-alternatives --config gcc
prenc
  • 151
  • 2
  • 13