cuda thrust::remove_if throws “thrust::system::system_error” for device_vector?

浪尽此生 提交于 2019-11-27 08:35:47

问题


I am currently using CUDA 7.5 under VS 2013. Today I needed to remove some of the elements from a device_vector, thus decided to use remove_if. But however I modify the code, the program just compiles well but throws "thrust::system::system_error" at run time.

Firstly I tried my own code:

int main()
{
    thrust::host_vector<int> AA(10, 1);
    thrust::sequence(AA.begin(), AA.end());
    thrust::host_vector<bool> SS(10,false);
    thrust::fill(SS.begin(), SS.begin() + 5, true);
    thrust::device_vector<int> devAA=AA;
    thrust::device_vector<bool> devSS = SS;
    thrust::device_vector<int>::iterator new_end = thrust::remove_if(thrust::device,
    devAA.begin(), devAA.end(), devSS.begin(), thrust::identity<int>());
}

But it throws thrust::system::system_error at run time. However, if I use two host_vector, i.e. AA and SS to perform remove_if, everything goes fine.

Then, I tried the code I found on stackoverflow here, the code in Robert Crovella's answer seemed work fine, but on my machine, it still throws thrust::system::system_error.

Did new version of thrust modify anything? Or I should try some other way? I am using cmake to organise the code, is there any thing special?


回答1:


The problem appears to be that OP was building a 32-bit project. The issue was resolved when switching to a 64-bit project.

My recommendation for CUDA 7.5 and beyond is to only use 64-bit projects. If you review the current state of 32-bit support on windows and linux you'll find it's quite limited.

Purely as a matter of conjecture, this issue may be related to thrust issue #715



来源:https://stackoverflow.com/questions/34000054/cuda-thrustremove-if-throws-thrustsystemsystem-error-for-device-vector

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!