c++ - CUDA 5.0 头文件

标签 c++ cuda

我正在为某人写得非常糟糕的项目而苦苦挣扎,我正试图尽快编译它……(最好的方法是正确地做到这一点,但时间是个问题)……不管怎样,他们似乎已经写了这个使用较旧的 API,其中 #include <cuda.h>允许您访问 api 函数。

API 函数似乎已移至其他 header 和 #include <cuda.h>已经不够了。我该怎么办:

  1. 包含cuda_runtime_api.h等头文件
  2. 用 nvcc 编译这个 cpp(没有内核函数调用)?

TIA

最佳答案

例如:

#include <cstdlib>
#include <stdio.h>

// includes CUDA Runtime
#include <cuda_runtime.h>

// maybe you need also helpers
#include <helper_cuda.h>
#include <helper_functions.h> // helper utility functions 

你需要添加

/usr/local/cuda-5.0/bin/nvcc

作为 C++ Compiler -> Tool还。适用于 g++ 4.4

在你的.cu然后你需要的文件 #include <curand_kernel.h>如果您使用 CURAND library

正如罗伯特·克罗维拉所说:

You should not need to explicitly include cuda.h if you are only using the cuda runtime API to access CUDA functionality. If you are using the driver API, things are different.

关于c++ - CUDA 5.0 头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16592738/

相关文章:

c++ - C++中的base32转换

windows - CUDA NSight 没有在 Windows 8 上安装 CUDA 5.0 安装文件?

c - 为 CUDA 编译 Hello world 程序时出错

c++ - 将 std::string 写入可比较的 *time* 解析器,这可能会失败

c++ - 这段代码中如何使用 map<string, set<string>>?

C++::toupper 不允许相等比较?

cuda - 我可以在编译时通过 #define 获得 CUDA 计算能力(版本)吗?

c++ - CUDA 似乎无法编译

cuda - 如何使tensorflow在具有2.x功能的GPU上运行?

c++ - C++ 中采用引用的 Void 函数与返回值的函数