Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
602 views
in Technique[技术] by (71.8m points)

cuda thrust::remove_if throws "thrust::system::system_error" for device_vector?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...