gpt4 book ai didi

cmake - 在最新的 CMAKE 中找不到 CUDA_INCLUDE_DIRS

转载 作者:行者123 更新时间:2023-12-04 12:13:33 33 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Listing include_directories in CMake

(3 个回答)


2年前关闭。




由于在 CMAKE 3.10 中,默认情况下支持 CUDA 宏( https://cmake.org/cmake/help/latest/module/FindCUDA.html )。

但我找不到变量 CUDA_INCLUDE_DIRS

cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(cmake_and_cuda LANGUAGES CXX CUDA)

message(${CUDA_INCLUDE_DIRS})

错误是
-- The CXX compiler identification is GNU 5.4.0
-- The CUDA compiler identification is NVIDIA 10.0.130
-- 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
-- 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
CMake Error at CMakeLists.txt:7 (message):
message called with incorrect number of arguments


-- Configuring incomplete, errors occurred!
See also "/home/tumh/code-samples/posts/cmake/build/CMakeFiles/CMakeOutput.log".

任何的想法?

最佳答案

只需使用 ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} .

在所有 .cu src 文件中,无需手动添加

include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}),

因为 CMake 会为你做这件事。

但是对于 .cpp src 文件,如果您需要 include <cuda_runtime.h> ,必须手动添加
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) 

在您的 CMakeLists.txt 中。

关于cmake - 在最新的 CMAKE 中找不到 CUDA_INCLUDE_DIRS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55741286/

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