首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >致命错误: cub/cub.cuh:没有这样的文件或目录

致命错误: cub/cub.cuh:没有这样的文件或目录
EN

Stack Overflow用户
提问于 2017-08-29 19:22:11
回答 1查看 4.8K关注 0票数 1

我是CUDA和CUB的新手。我找到了下面的代码并试图编译它,但是我有以下错误:致命错误: cub/cub.cuh:没有这样的文件或目录。

CUDA的版本是7.0.27,我如何修正这个错误?

谢谢!

代码语言:javascript
复制
#include <cuda.h>
#include <cub/cub.cuh>
#include <stdio.h>

int main(){

  // Declare, allocate, and initialize device pointers for input and output
  int num_items = 7;
  int *d_in;
  int h_in[]  = {8, 6, 7, 5, 3, 0, 9};
  int sz = sizeof(h_in)/sizeof(h_in[0]);
  int *d_out; // e.g., [ , , , , , , ]
  cudaMalloc(&d_in,  sz*sizeof(h_in[0]));
  cudaMalloc(&d_out, sz*sizeof(h_in[0]));
  cudaMemcpy(d_in, h_in, sz*sizeof(h_in[0]), cudaMemcpyHostToDevice);
  printf("\nInput:\n");
  for (int i = 0; i < sz; i++) printf("%d ", h_in[i]);
  // Determine temporary device storage requirements
  void *d_temp_storage = NULL;
  size_t temp_storage_bytes = 0;
  cub::DeviceScan::InclusiveSum(d_temp_storage, temp_storage_bytes, d_in, d_out, num_items);
  // Allocate temporary storage
  cudaMalloc(&d_temp_storage, temp_storage_bytes);
  // Run inclusive prefix sum
  cub::DeviceScan::InclusiveSum(d_temp_storage, temp_storage_bytes, d_in, d_out, num_items);
// d_out s<-- [8, 14, 21, 26, 29, 29, 38]
  cudaMemcpy(h_in, d_out, sz*sizeof(h_in[0]), cudaMemcpyDeviceToHost);
  printf("\nOutput:\n");
  for (int i = 0; i < sz; i++) printf("%d ", h_in[i]);
  printf("\n");
  return 0;
}
EN

回答 1

Stack Overflow用户

发布于 2017-08-30 02:38:45

首先,您应该升级到cuda 8。这个错误致命错误: cub/cub.cuh,因为编译器找不到这个文件。如果使用cmake,则必须通过命令include_directories添加cub目录,如果使用IDE或其他什么,请尝试将cub目录添加到项目中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45946858

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档