gpt4 book ai didi

c++ - transform_reduce 中的 thrust::system::system_error

转载 作者:行者123 更新时间:2023-11-28 03:21:33 27 4
gpt4 key购买 nike

我在具有 2.1 计算能力的 Nvidia 卡上使用 Thrust 运行蒙特卡洛模拟。如果我尝试一次 transform_reduce 整个 device_vector,我会收到以下错误。这不是耗尽设备内存的问题,因为 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);
}

最佳答案

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

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

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

关于c++ - transform_reduce 中的 thrust::system::system_error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15289030/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com