【问题标题】:cuda - memory allocation crashescuda - 内存分配崩溃
【发布时间】:2016-10-09 08:16:28
【问题描述】:

好的,我正在尝试在 gpu 上分配一个结构数组,但它崩溃了(给出停止工作的消息)。

这是结构:

typedef struct point_t {
int id;
float x, y;
} point;

这是 cuda 代码的一部分:

    cudaError_t d_LoadPoints(point* points, int n , int chunkSize){  
        // Error code to check return values for CUDA calls
        cudaError_t err = cudaSuccess;

         int nBytes = n * sizeof(point);

        // Allocate the device input points array
        point* d_points;
        err = cudaMalloc((void** )&d_points, nBytes);


    if (err != cudaSuccess)
   {
    fprintf(stderr, "Failed to allocate device vector points (error code %s)!\n", cudaGetErrorString(err));
    exit(EXIT_FAILURE);
   }


    cudaMemcpy(d_points,points ,nBytes ,cudaMemcpyHostToDevice);
    puts("memory allocated successfully");

}

我尝试打印 points 数组的第一个元素,以及 nchunksize 并且结果正确。

这就是它似乎崩溃的地方(我禁用了其余部分)。 无论调试打印如何,它都会崩溃。

我唯一能想到的就是尺寸。

n 是 250,000,chunksize 是 64,000,我计划为 125 个块分配 512 个线程。

我不知道这是否是个好主意,但这是一个副话题,因为我什至无法到达内核调用。

【问题讨论】:

    标签: cuda


    【解决方案1】:

    重新启动 Visual Studio 解决了问题

    【讨论】:

      猜你喜欢
      • 2010-11-14
      • 1970-01-01
      • 2011-08-02
      • 1970-01-01
      • 2010-11-17
      • 2016-11-18
      • 1970-01-01
      • 1970-01-01
      • 2021-04-01
      相关资源
      最近更新 更多