【问题标题】:Visual Studio 2017 with CUDA cannot open include file 'cuda.h'带有 CUDA 的 Visual Studio 2017 无法打开包含文件“cuda.h”
【发布时间】:2018-10-04 04:17:22
【问题描述】:

我正在使用 Visual Studio 开发 Nvidia SDK,每当我尝试从 Nvidia 编译示例时都会遇到此错误:

严重性代码描述项目文件行抑制状态 错误 C1083 无法打开包含文件:'cuda.h':没有这样的文件或 目录 AppDecPerf
c:\users\administrator\desktop\video_codec_sdk_8.1.24\samples\appdecode\appdecperf\appdecperf.cpp 12

我的计算机上确实安装了 CUDA,看起来我必须以某种方式将其与 IDE 链接,但我无法在任何地方找到“cuda.h”文件。

感谢任何帮助。谢谢!

【问题讨论】:

  • 也许您应该只使用 Windows 查找文件实用程序在您的计算机上查找 cuda.h。然后,您必须将该文件的路径添加到您的项目中,包括路径设置。

标签: c++ visual-studio cuda


【解决方案1】:

使用 vcpkg.exe 在 vc++ 2017 中为 Windows 安装 cuda 库(静态或动态)。使用.\vcpkg integrate install 自动将项目链接到您的解决方案。

使用.\vcpkg install cuda:x64-windows-static进行安装。

【讨论】:

  • '.\vcpkg' 不是内部或外部命令、可运行程序或批处理文件。
  • 使用强力外壳。如果路径未注册,则将目录更改为 vcpkg.exe 的位置。
  • vcpkg 是您从 github 克隆并构建的东西,不是吗?
  • @DeanSchulze:是的
【解决方案2】:

右键单击您的项目,选择Build Dependencies,然后选择Build Customizations。从这里您可以选择您想要使用的 CUDA 工具包的版本(除其他外,它会将$(CudaToolkitDir) 变量和一个新的CUDA C/C++ 选项卡添加到项目属性中)。来自 NVIDIA 的示例应该已经以这种方式配置,但我注意到升级 SDK 时它们可能会损坏。

更多详情请点击此处: https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html#build-customizations-for-existing-projects

【讨论】:

    猜你喜欢
    • 2017-10-28
    • 1970-01-01
    • 2016-07-02
    • 1970-01-01
    • 2013-10-25
    • 2013-04-30
    • 1970-01-01
    • 2022-07-02
    • 2012-06-23
    相关资源
    最近更新 更多