【问题标题】:Wrong compiler used in the target offload process in CLion during CUDA compilation在 CUDA 编译期间,CLion 的目标卸载过程中使用了错误的编译器
【发布时间】:2020-04-26 18:42:27
【问题描述】:

我正在尝试在 CLion 2020.1 中配置一个非常简单的 CUDA 项目。

我在 Fedora 31 上(默认 gcc 为 9.3),但从源代码编译 gcc 8.2 以将其与 Cuda Toolkit 10.2 一起使用。

Cuda 示例使用提供的 make 编译和运行良好,因此编译器可以很好地与 nvcc 配合使用。

在 CLion 中,我用柯南下载了 googletest。 Conan 配置文件指定 8.2 作为要使用的 gcc 版本。

CMakeOutput.log 中对 GCC 的所有引用均指向正确的 bin 文件。 然而,由于使用了错误的版本,我不断收到编译器错误。

在我的 CMakeLists.txt 中,我有:

set(gcc82 /usr/local/gcc82/bin)
set(CMAKE_C_COMPILER ${gcc82}/gcc82)
set(CMAKE_CXX_COMPILER ${gcc82}/g++82)
set(CMAKE_CUDA_HOST_COMPILER ${gcc82}/g++82)

project(RBF-Interpolation-Tests CUDA CXX)

CMake 配置步骤似乎也很愉快:

/opt/clion-2018.3.4/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/local/gcc82/bin/gcc82 -DCMAKE_CXX_COMPILER=/usr/local/gcc82/bin/g++82 -G "CodeBlocks - Unix Makefiles" /home/rafael/Projects/bitbucket/RBF-Interpolation-Tests
-- The CUDA compiler identification is NVIDIA 10.2.89
-- The CXX compiler identification is GNU 8.2.0
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc -- works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CXX compiler: /usr/local/gcc82/bin/g++82
-- Check for working CXX compiler: /usr/local/gcc82/bin/g++82 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /home/rafael/Projects/bitbucket/RBF-Interpolation-Tests/build
-- Conan: Compiler GCC>=5, checking major version 8.2
-- Conan: Checking correct version: 8.2
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rafael/Projects/bitbucket/RBF-Interpolation-Tests/build

尽管我的机器上有 CLion 的路径,但版本是最新的:

CLion 2020.1
Build #CL-201.6668.126, built on April 9, 2020
Runtime version: 11.0.6+8-b765.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.5.17-200.fc31.x86_64
GC: ParNew, ConcurrentMarkSweep
Memory: 10227M
Cores: 12
Registry: run.processes.with.pty=TRUE
Non-Bundled Plugins: GLSL, com.jfrog.conan.clion, lermitage.intellij.extra.icons
Current Desktop: GNOME

我总是得到的错误是:

Cannot get compiler information:
    Compiler exited with error code 1: gcc -xc++ -D__CUDA_ARCH__=300 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ -I/home/rafael/.conan/data/gtest/1.10.0/_/_/package/65eda67f91bbd445d66656724e8acbe2afb564b0/include -I/usr/local/cuda/bin/../targets/x86_64-linux/include -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=2 -D__CUDACC_VER_BUILD__=89 -include cuda_runtime.h -m64 -g -gdwarf-2 -fpch-preprocess -v -dD -E
    Using built-in specs.
    COLLECT_GCC=gcc
    OFFLOAD_TARGET_NAMES=nvptx-none
    OFFLOAD_TARGET_DEFAULT=1
    Target: x86_64-redhat-linux
    Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
    Thread model: posix
    gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) 
    COLLECT_GCC_OPTIONS='-D' '__CUDA_ARCH__=300' '-E' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-D' '__CUDACC__' '-D' '__NVCC__' '-I' '/home/rafael/.conan/data/gtest/1.10.0/_/_/package/65eda67f91bbd445d66656724e8acbe2afb564b0/include' '-I' '/usr/local/cuda/bin/../targets/x86_64-linux/include' '-D' '__CUDACC_VER_MAJOR__=10' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_BUILD__=89' '-include' 'cuda_runtime.h' '-m64' '-g' '-gdwarf-2' '-fpch-preprocess' '-v' '-dD' '-E' '-D' '___CIDR_DEFINITIONS_END' '-mtune=generic' '-march=x86-64'

这绝对是错误的 GCC 版本。

我尝试在 Settings -> Cmake -> Environment 中使用 CC=/usr/local/gcc82/bin;CXX=/usr/local/gcc82/bin/g++82 指定 GCC 版本, 也可以在 Settings -> Toolchains -> C and C++ Compiler 中,结果是一样的。

我不知道为什么目标卸载过程没有选择指定的 gcc 版本。有什么想法吗?

【问题讨论】:

  • 这是一个 CLion bug。希望尽快修复。
  • @MaximBanaev 感谢您指出这一点 - 不知道。

标签: gcc cmake clion


【解决方案1】:

所以,我就这个问题向 CLion 提交了一个错误 - @MaximBanaev 指出的那个:

CPP-19089: Can't get CLion to use a non-default C++ compiler with CUDA

CLion 在其工具链机制中根本没有正确考虑到这个问题。问题甚至不仅仅是环境 - 除了 CLion 在出现相关设置时注意到相关设置之外,还需要适当的 UI 来为 CUDA 设置“支持”C++ 编译器。

这不是我在尝试将 CLion 用于 CUDA 项目时遇到的唯一“基本”错误。恕我直言,支持仍然是半生不熟的。我希望他们做对了,因为我想推出这个 IDE,但现在我做不到。

【讨论】:

  • 它仍在发生。 2020.1.1还有人遇到这种情况吗?问题页面说它已修复。
  • @DanielCheung:据说有一个蹩脚的解决方法 - 阅读错误页面的顶部。
猜你喜欢
  • 1970-01-01
  • 2016-03-20
  • 1970-01-01
  • 2016-12-16
  • 1970-01-01
  • 1970-01-01
  • 2017-06-06
  • 2011-02-21
  • 1970-01-01
相关资源
最近更新 更多