0

我正在使用 Thrust 在具有 2.1 计算能力的 Nvidia 卡上运行蒙特卡罗模拟。如果我尝试一次 transform_reduce 整个 device_vector,我会收到以下错误。这不是用完设备上的内存的问题,因为向量那么大(~1-10mb)。我知道我的代码是正确的,因为如果我使用 openmp 编译并仅在主机上运行,​​它就可以工作。什么可能导致这个问题?

mccva.exe 中 0x776e15de 处未处理的异常:Microsoft C++ 异常:内存位置 0x0014cb28 处的推力::system::system_error。

但是,如果我以块的形式执行 transform_reduce,它可以正常工作,直到我缩放模拟中的时间步数,然后它会给出相同的错误。

//run the Monte Carlo simulation
zpath * norm_ptr = thrust::raw_pointer_cast(&z[0]);
cout << "initialized raw pointer" << endl;
thrust::device_vector<ctrparty> devctrp = ctrp;
assert(devctrp.size()==ctrp.size());
cout << "Initialized device vector" << endl;
cout << "copied host vec to device vec" << endl;

float cva = 0;
for(unsigned int i=0; i<5; i++)
{
    if(i<4)
        cva += (1-R) * thrust::transform_reduce(devctrp.begin()+i*2000, devctrp.begin() + (i+1)*2000 - 1, calc(norm_ptr, dt, r, sims, N), 0.0f, sum());
    else
        cva += (1-R) * thrust::transform_reduce(devctrp.begin()+i*2000, devctrp.begin() + (i+1)*2000, calc(norm_ptr, dt, r, sims, N), 0.0f, sum());
}  

尝试此操作时出现错误:

float cva = 0.0f;
try
{
    cva = thrust::transform_reduce(devctrp.begin(), devctrp.end(), calc(norm_ptr, dt, r, sims, N), 0.0f, sum()); //get the simulated CVA
}
catch(thrust::system_error e)
{
    printf(e.what());
}

我正在使用 VS2010,当它出现错误时,它指向 dbgheap.c 文件中的以下内容。

__finally {
    /* unlock the heap
     */
    _munlock(_HEAP_LOCK);
}
4

1 回答 1

2

当我忘记将Properties项目调整为我的 CUDA 卡计算能力时,我遇到了这种推力错误

Configuration Properties > CUDA C\C++ > Device > Code Generation更改compute_10,sm_10您的 GPU 计算能力

对于具有 2.1 计算能力的 Nvidia 卡,它将是compute_20,sm_21

于 2013-05-27T13:58:22.000 回答