我正在使用具有2.1计算能力的Nvidia卡上的Thrust运行蒙特卡罗模拟。如果我尝试立即transform_reduce整个device_vector,我会收到以下错误。这不是在设备上耗尽内存的问题,因为矢量很大(~1-10mb)。我知道我的代码是正确的,因为如果我使用openmp进行编译并仅在主机上运行它是有效的。什么可能导致这个问题?
mccva.exe中0x776e15de处的未处理异常:Microsoft C ++异常:在内存位置0x0014cb28处的thrust :: 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);
}
答案 0 :(得分:2)
当我忘记将项目的Properties
调整为我的CUDA卡计算能力时,我遇到了那种错误
Configuration Properties > CUDA C\C++ > Device > Code Generation
将compute_10,sm_10
更改为您的GPU计算能力
对于具有2.1计算能力的Nvidia卡,它将是compute_20,sm_21