1
votes

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
Could you explain your problem a little better? Is the code you have posted working for you or not? When you say " However, if I use two host_vector, i.e. AA and SS to perform remove_if, everything goes fine" what does that mean relative to the code you have posted?talonmies
I don't have any trouble with what you have posted. Here is my test case. You might have a problem with your machine setup or CUDA install.Robert Crovella
If you add precise thrust error checking like this, then it's likely you'll get more information about why the system error is occurring. For example, if I compile that code for compute_30,sm_30 but run on my cc2.0 device, I get the following: "thrust system error: cudaFuncGetAttributes in function_attributes: invalid device function" and the "invalid device function" message is a good indicator that I have compiled for an incorrect GPU type.Robert Crovella
I opened your project file. Are you building a Win32 project? You should be building a x64 release project. Anyway, I don't have any trouble building and running your project on my machine if I build an x64 release project. Yes, if you build a win32 project it will not work.Robert Crovella
Official support for 32-bit is disappearing in newer CUDA versions. In CUDA 7.5 it is almost gone.Robert Crovella

1 Answers

2
votes

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