【问题标题】:Thrust issue with CUDA 6 managed memoryCUDA 6 托管内存的推力问题
【发布时间】:2014-08-31 04:24:04
【问题描述】:

我遇到了一个问题,即尝试在同一个 CUDA 6 应用程序中使用 cudaMallocManaged() 和推力时,推力失败,即使推力没有使用任何托管内存也是如此。仅仅拥有一个未使用的托管变量就足以导致推力失败。我创建了以下复制器,我正在运行 CUDA 6.0 的 NVIDIA Jetson TK1 上进行测试:

#include "thrust/device_ptr.h"
#include "thrust/sort.h"

__global__ void calculate_hash(uint *hash_values, uint *particle_ids, int length)
{
    int i = blockIdx.x*blockDim.x + threadIdx.x;

    if(i >= length)
        return;

    hash_values[i] =  1;
    particle_ids[i] = i;
}

void hash_particles_gpu(uint *d_hash_values, uint *d_particle_ids, int length)
{
    int block_size = 256;
    int num_blocks = ceil(length/(float)block_size);

    calculate_hash<<<num_blocks, block_size>>>(d_hash_values, d_particle_ids, length);  

    cudaDeviceSynchronize();

    thrust::device_ptr<uint> keys(d_hash_values);
    thrust::device_ptr<uint> values(d_particle_ids);
    thrust::sort_by_key(keys, keys+length, values);
}

int main(int argc, char *argv[])
{
    int length = 15;
    int bytes;

    #ifdef BROKE
    int *m_int;
    cudaMallocManaged((void**)&m_int, sizeof(int));
    #endif

    // Allocate uint hash value array
    bytes = length*sizeof(unsigned int);
    unsigned int * hash_values;
    cudaMalloc((void**)&hash_values, bytes);    

    // Allocate uint particle ID array
    bytes = length*sizeof(unsigned int);
    unsigned int *particle_ids;
    cudaMalloc((void**)&particle_ids, bytes);

    hash_particles_gpu(hash_values, particle_ids, length);
}

当我编译运行时:

$ nvcc -DBROKE -DTHRUST_DEBUG example.cu -o broke.exe
$ nvcc -DTHRUST_DEBUG example.cu -o fixed.exe
$ ./fixed.exe
$ ./broke.exe
terminate called after throwing an instance of 'thrust::system::system_error'
  what():  synchronize: RakingReduction: unknown error
Abort

我已检查以确保在此之前我没有任何错误,并且在我调用 sort_by_key 之前一切似乎都很好。知道发生了什么吗?

【问题讨论】:

  • 如果您对 cudaMallocManaged 调用进行适当的 cuda 错误检查会发生什么。是否报告了任何 API 错误?你在那个 Jetson 平台上运行什么操作系统?
  • 我检查了所有的 cuda 函数和内核启动,在 sort_by_key 之前没有返回任何错误。 TK1 正在运行默认的 Linux For Tegra(L4T)。单独的推力和托管内存似乎可以正常工作。
  • 也许你可以试试 CUDA 6.5RC 看看行为是否有任何不同。除此之外,我没有任何想法,但可以建议您向 NVIDIA 提交错误。
  • 我在 Kepler K20c, c.c. 上试过这个代码。 3.5,我无法重现该问题。你确定你的编译命令吗?你应该指定计算能力吗?
  • 在带有 CUDA 6.0 和 sm_30 设备的 x86_64 linux 平台上,这项工作的所有排列对我来说都很好。这看起来像是某种 ARM 或 L4T 特定问题。我会向 NVIDIA 提出错误报告。

标签: cuda thrust


【解决方案1】:

感谢 cmets。我为 Tegra 刷了最新的 Linux 19.3,它现在可以与 Cuda 6.0 一起使用。看起来 NVIDIA 的 L4T 19.2 存在驱动程序问题。

【讨论】:

    猜你喜欢
    • 2013-07-26
    • 1970-01-01
    • 2012-02-18
    • 1970-01-01
    • 2010-09-22
    • 2017-02-14
    • 2014-07-01
    • 1970-01-01
    • 2011-12-27
    相关资源
    最近更新 更多