2017-09-20 1 views
0

C++ 및 CUDA 소스 파일로 라이브러리를 컴파일하려고합니다. 나는 CMake로 GNU make를 사용하고있다. CUDA는 gcc를 버전 5까지만 지원하고 데비안 9는 gcc 6을 가장 오래된 버전으로 사용하고 데비안 9 또는 10 저장소에서 제공하는 소프트웨어를 사용해야하므로 선택의 여지가있는 컴파일러는 불만입니다.CMake는 CUDA 인수를 전달하지 않습니까?

CMake 버전은 3.9.0 연타 버전이 올바르게 또한 올바른 파일을 링크하는과 연타 ++ 연타하는 링크는/usr/bin에 3.8.1

CC와 C++입니다.

유감스럽게도 Cake의 초기 검사는 실패했지만, 모든 내용은 올바르게 볼 수 있습니다. 인수가 CUDA 컴파일러에 올바르게 전달되지 않은 것 같습니다.

내 프로젝트의 주요 CMake 파일의 일부입니다

cmake_minimum_required (VERSION 3.9.0 FATAL_ERROR) 

project (dev) 

find_package(CUDA REQUIRED) 

set(CUDA_HOST_COMPILATION_CPP ON) 
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Wno-deprecated-gpu-targets -ccbin clang-3.8") 

도서관의 CMake 파일은 다음과 같다 :

-- The C compiler identification is Clang 3.8.1 
-- The CXX compiler identification is Clang 3.8.1 
-- Check for working C compiler: /usr/bin/cc 
-- Check for working C compiler: /usr/bin/cc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Detecting C compile features 
-- Detecting C compile features - done 
-- Check for working CXX compiler: /usr/bin/c++ 
-- Check for working CXX compiler: /usr/bin/c++ -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- Detecting CXX compile features 
-- Detecting CXX compile features - done 
-- Looking for pthread.h 
-- Looking for pthread.h - found 
-- Looking for pthread_create 
-- Looking for pthread_create - not found 
-- Looking for pthread_create in pthreads 
-- Looking for pthread_create in pthreads - not found 
-- Looking for pthread_create in pthread 
-- Looking for pthread_create in pthread - found 
-- Found Threads: TRUE 
-- Found CUDA: /usr (found version "8.0") 
-- The CUDA compiler identification is unknown 
-- Check for working CUDA compiler: /usr/bin/nvcc 
-- Check for working CUDA compiler: /usr/bin/nvcc -- broken 
:이 CMake의 출력

cmake_minimum_required(VERSION 3.9.0 FATAL_ERROR) 

project (libname LANGUAGES CXX CUDA) 

file(GLOB SOURCES "*.cu" "*.cpp") 

add_library(libname ${SOURCES}) 

set_target_properties(libname PROPERTIES CUDA_SEPARABLE_COMPILATION ON) 
set_target_properties(libname PROPERTIES POSITION_INDEPENDENT_CODE ON) 

CMake의 CUDA/nvcc 테스트가 다음 오류로 인해 실패합니다.

Change Dir: /home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp 



    Run Build Command:"/usr/bin/make" "cmTC_6d1a9/fast" 

    /usr/bin/make -f CMakeFiles/cmTC_6d1a9.dir/build.make 
    CMakeFiles/cmTC_6d1a9.dir/build 

    make[1]: Entering directory 
    '/home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp' 


    Building CUDA object CMakeFiles/cmTC_6d1a9.dir/main.cu.o 

    /usr/bin/nvcc -x cu -c 
    /home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp/main.cu 
    -o CMakeFiles/cmTC_6d1a9.dir/main.cu.o 

    nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are 
    deprecated, and may be removed in a future release (Use 
    -Wno-deprecated-gpu-targets to suppress warning). 

    ERROR: No supported gcc/g++ host compiler found, but clang-3.8 is 
    available. 

     Use 'nvcc -ccbin clang-3.8' to use that instead. 

    CMakeFiles/cmTC_6d1a9.dir/build.make:65: recipe for target 
    'CMakeFiles/cmTC_6d1a9.dir/main.cu.o' failed 

    make[1]: *** [CMakeFiles/cmTC_6d1a9.dir/main.cu.o] Error 1 

    make[1]: Leaving directory 
    '/home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp' 


    Makefile:126: recipe for target 'cmTC_6d1a9/fast' failed 

    make: *** [cmTC_6d1a9/fast] Error 2 





    CMake will not be able to correctly generate this project. 
Call Stack (most recent call first): 
    hic_iplibrary/source/ciccommon/CMakeLists.txt:7 (project) 

답변

2

CMake의 CUDA NVCC 플래그는 세미콜론으로 구분하고 공백으로 구분하지 않아야합니다.

를 사용하도록 CMakeLists.txt에 플래그를 변경

:

set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Wno-deprecated-gpu-targets;-ccbin=clang-3.8")

그것은 CMake가 NVCC에 플래그를 전달할 수 있도록해야한다.

관련 문제