【问题标题】:Cmake can't find the cuda.h fileCmake 找不到 cuda.h 文件
【发布时间】:2018-11-14 18:03:19
【问题描述】:

我的项目只有扩展名为 *.cpp 或 *.h 的源文件。但其中一些调用 cuda 主机函数并使用 cublas 库。使用enable_language(CUDA)后,cmake可以在配置阶段找到nvcc:

-- The CUDA compiler identification is NVIDIA 8.0.61
-- Check for working CUDA compiler: /gpfs/share/software/cuda/cuda-8.0/bin/nvcc
-- Check for working CUDA compiler: /gpfs/share/software/cuda/cuda-8.0/bin/nvcc -- works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done

但是,在编译这些源文件时,我得到了这个错误:

fatal error: cuda.h: No such file or directory

而且cmake选择的编译器还是/usr/bin/c++不是nvcc。如何处理这个错误?我必须将这些源文件重命名为.cu.cuh吗?

【问题讨论】:

    标签: c++ cmake cuda


    【解决方案1】:

    不,您需要在 include_directories() 中包含 CUDA 标头。应该来自CUDA_INCLUDE_DIRS 变量。

    让 C++ 文件使用 CUDA 头文件非常好,但您需要像添加任何其他库一样添加包含。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-05
      • 1970-01-01
      相关资源
      最近更新 更多