prenc
prenc

Reputation: 151

The CUDA compiler is not able to compile a simple test program

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:

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

Upvotes: 1

Views: 3530

Answers (1)

prenc
prenc

Reputation: 151

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

Upvotes: 2

Related Questions