2017-12-21 7 views
1

데비안 GNU/리눅스 시스템에서 CUDA 툴킷으로 컴파일하려고하지만 아주 단순한 프로그램에서도 C++ 11 지원이 분명히 있습니다. 부서진.CUDA nvcc 컴파일러가 C++ 11을 사용하면 실패합니다. (Linux; clang 3.8)

  • 리눅스 커널 : 4.13.0
  • CUDA 툴킷 : 8.0.61
  • 연타 :

    첫째, 여기에 관련 소프트웨어 버전의 목록입니다 3.8.1

  • 의 libc : 2.25
  • 된 libstdC++ : 정말 기본적인 테스트 파일을 사용하여 7.2.0

,아래는 :

__global__ void testfunc(float *a, float *b, int N) 
{ 
    for (int i = 0; i < N; ++i) { 
     b[i] += a[i]; 
    } 
} 

그리고 명령을 사용하여 컴파일 :

nvcc -ccbin clang-3.8 -std c++11 -o test test.cu 

나는 declaration conflicts with target of using declaration already in scope 오류의 긴 목록을 가져옵니다. 아래에 두 가지를 보여 드리겠습니다. 자동으로 20으로 자릅니다.

/usr/include/math_functions.h:8925:41: error: declaration conflicts with target of using declaration already in scope 
__attribute((always_inline)) inline int signbit(float x); 
             ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/cmath:668:16: note: target of using declaration 
constexpr bool signbit(float __x) 
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/math.h:68:12: note: using declaration 
using std::signbit; 
     ^
/usr/include/math_functions.h:8929:41: error: declaration conflicts with target of using declaration already in scope 
__attribute((always_inline)) inline int signbit(double x); 
             ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/cmath:672:16: note: target of using declaration 
constexpr bool signbit(double __x) 
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/math.h:68:12: note: using declaration 
using std::signbit; 
     ^

CUDA와 호환되지 않는 컴파일러/라이브러리 버전을 사용하고 있습니까? 특히 데비안이 Nvidia에서 공식적으로 지원하지 않기 때문에이 정보를 찾는 것이 어려워 보입니다. 데비안 저장소가 배포 한 패키지 만 사용하고 있습니다 (테스트 배포 중입니다).

+2

아마도 지원되는 배포판에서 시도해야합니다. clang을 사용하려고하기 때문에, 이것은 올바르게 보이지 않습니다.'..lib/gcc/..'[here] (https://stackoverflow.com/questions/24342312/clang-seems-to-use)를보십시오. -the-gcc-libraries) –

+0

고맙습니다 @RobertCrovella, libC++을 설치하고 clang에 gcc 라이브러리 (CUDA 8.0에 너무 새로 추가되었습니다)를 사용하는 대신'--compiler-options -stdlib = libC++' 지원). 나는 대답을 쓸 것이다. – Archimaredes

답변

1

설치 과정에서 뭔가 잘못되었거나 사용중인 데비안 버전이 작동하지 않는 지원되는 플랫폼에서 충분히 벗어났습니다.

내가 CUDA 8 우분투 14.04에 예제를 컴파일하면 나는이 얻을 :이 정말 지원 작업을 수행하기 때문에

$ cat clangtest.cu 
__global__ void testfunc(float *a, float *b, int N) 
{ 
    for (int i = 0; i < N; ++i) { 
     b[i] += a[i]; 
    } 
} 

$ nvcc -arch=sm_52 -std=c++11 -c clangtest.cu 
$ nvcc -ccbin=/usr/bin/clang-3.8 -std=c++11 -arch=sm_52 -c clangtest.cu 
$ nvcc --version 
nvcc: NVIDIA (R) Cuda compiler driver 
Copyright (c) 2005-2016 NVIDIA Corporation 
Built on Sun_Sep__4_22:14:01_CDT_2016 
Cuda compilation tools, release 8.0, V8.0.44 

$ g++ --version 
g++ (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 
Copyright (C) 2015 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions. There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

$ clang-3.8 --version 
clang version 3.8.0-2ubuntu3~trusty5 (tags/RELEASE_380/final) 
Target: x86_64-unknown-linux-gnu 
Thread model: posix 
InstalledDir: /usr/bin 

는 그래서 하나가, 당신의 연타 설치를 수정 또는 지원되는 배포판을 사용할 필요가 .

+0

내 clang 설치가 손상되지 않았지만 gcc C++ 표준 라이브러리를 사용하고있었습니다.이 라이브러리는 버전 7.2.0에서 CUDA 8.0에 비해 너무 새롭습니다. clang의 libC++를 사용하면 수동으로 작동합니다. – Archimaredes

1

CUDA 8.0은 최대 gcc-5 만 지원합니다. 데비안 9에서는이 기능을 사용할 수 없으므로 대신 clang-3.8을 사용했습니다. 그러나 기본적으로 clang은 gcc C++ 표준 라이브러리를 사용하며 버전 7.2.0을 사용하려고했습니다. CUDA 8은 gcc-7을 지원하지 않기 때문에, 그것은 파괴되었습니다.

libC++ (clang 작성자가 대체 C++ 라이브러리를 구현)를 설치하고이를 사용하여 수동으로 문제를 해결합니다. 명령은 다음과 같습니다.

nvcc -ccbin clang++-3.8 -std=c++11 --compiler-options -stdlib=libc++ -o test test.cu 
관련 문제