CUDA编译期间,CLion的目标卸载过程中使用了错误的编译器 [英] Wrong compiler used in the target offload process in CLion during CUDA compilation

查看:272
本文介绍了CUDA编译期间,CLion的目标卸载过程中使用了错误的编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to configure a very simple CUDA project in CLion 2020.1.

我在Fedora 31上(默认gcc为9.3),但编译为gcc 8.2

I'm on Fedora 31 (default gcc is 9.3), but compiled gcc 8.2 from source to use it with Cuda Toolkit 10.2.

Cuda示例使用提供的make编译并运行良好,因此编译器可以很好地在nvcc上正常工作。

The Cuda samples compile and run fine using the provided make, so the compiler is working and playing nicely with nvcc.

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

In CLion, I have googletest downloaded with Conan. The Conan profile specifies 8.2 as the gcc version to be used.

CMakeOutput.log中对GCC的所有引用均指向正确的bin文件。
但是,由于使用了错误的版本,我一直遇到编译器错误。

All references to GCC in CMakeOutput.log are to the correct bin file. And yet, I keep getting the compiler error because the wrong version is being used.

在我的CMakeLists.txt中,我有:

In my CMakeLists.txt, I have:

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配置步骤似乎也很令人满意:

The CMake configuration step seems to be happy too:

/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,但该版本是最新版本:

Despite the path to CLion on my machine, the version is the most recent:

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版本。

which is definitely the wrong GCC version.

我尝试在 CC = / usr / local的设置-> Cmake->环境中指定GCC版本/ gcc82 / bin; CXX = / usr / local / gcc82 / bin / g ++ 82
以及设置->工具链-> C和C ++编译器中,结果为

I've tried specifying the GCC version in Settings -> Cmake -> Environment with CC=/usr/local/gcc82/bin;CXX=/usr/local/gcc82/bin/g++82, and also in Settings -> Toolchains -> C and C++ Compiler, and the result is the same.

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

I have no idea why the target offloading process is not picking up the specified gcc version. Any ideas?

推荐答案

因此,我针对此问题针对CLion提出了一个错误-一个@MaximBanaev指出:

So, I filed a bug against CLion about this issue - the one @MaximBanaev pointed out:

CPP-19089:无法获取CLion在CUDA中使用非默认C ++编译器

CLion只是在其工具链机制中没有适当考虑到此问题。问题不仅仅在于环境-除了CLion会在出现时注意相关设置之外,还需要适当的UI来为CUDA设置支持 C ++编译器。

CLion has simply not properly taken this issue into account in its toolchain mechanism. The issue is not even just the environment - there needs to be proper UI to set the "backing" C++ compiler for CUDA, in addition to CLion noticing the relevant settings when it comes up.

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

This isn't the only "fundamental" bug I've encountered trying to use CLion with CUDA projects. The support is still rather half-baked IMHO. I wish they get it right, because I would like to this IDE out and for now, I can't.

这篇关于CUDA编译期间,CLion的目标卸载过程中使用了错误的编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆