【发布时间】:2020-08-01 18:32:04
【问题描述】:
我正在尝试使用 CMake 使用 cuda 编译库。
我希望 cuda 是可选的,即如果系统上没有 nvcc,我希望我的库能够编译。
这是我检查 CMake 中是否提供 cuda 的方法:
include(CheckLanguage)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
enable_language(CUDA)
else()
message(WARNING "CUDA not found: GPU features won't be available.")
endif ()
这里是我设置的环境变量:
$> env | grep CXX
CUDAHOSTCXX=/usr/bin/g++-6
CUDACXX=/usr/bin/nvcc
CXX=/usr/bin/g++
这是 cmake 命令的输出:
$> cmake ..
-- The CXX compiler identification is GNU 7.4.0
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for a CUDA compiler
-- Looking for a CUDA compiler - /usr/bin/nvcc
-- The CUDA compiler identification is NVIDIA 9.1.85
-- Check for working CUDA compiler: /usr/bin/nvcc
-- Check for working CUDA compiler: /usr/bin/nvcc -- works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Configuring done
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_CUDA_COMPILE_WHOLE_COMPILATION
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
我没有找到任何有用的关于 CMAKE_CUDA_COMPILE_WHOLE_COMPILATION 的东西。
我怎样才能使这个 cmake 工作?我错过了什么?
【问题讨论】: