gpt4 book ai didi

cmake - 缺少的变量是 : CMAKE_CUDA_COMPILE_WHOLE_COMPILATION

转载 作者:行者123 更新时间:2023-12-04 10:11:48 29 4
gpt4 key购买 nike

我正在尝试使用 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 工作?我错过了什么?

最佳答案

我只是弄清楚问题是什么......

我正在调用一个函数

function(enable_cuda_if_available)
# Here CUDA is properly found and variable are correctly set
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 ()
endfunction()

enable_cuda_if_available()
# Here CUDA's variables have not been forwarded to the parent scope and leading to an error

我仍然不知道如何将 enable_cuda_if_available 设置的所有变量自动转发到父作用域

关于cmake - 缺少的变量是 : CMAKE_CUDA_COMPILE_WHOLE_COMPILATION,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61302415/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com