问题描述
我目前在VS 2013下使用CUDA 7.5。
今天我需要从 device_vector
中删除一些元素,因此决定使用 remove_if
。但是我修改代码,程序只是编译好,但在运行时抛出thrust :: system :: system_error。
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.
首先我尝试了自己的代码: / p>
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>());
}
但它引发 thrust :: system :: system_error
。但是,如果我使用两个 host_vector
,即 AA
和 SS
执行 remove_if
,一切正常。
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.
然后,我尝试了,在Robert Crovella的答案中的代码似乎工作得很好,但在我的机器上,它仍然抛出 thrust :: system :: system_error
。
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
.
新版本的推力修改了什么吗?或者我应该尝试一些其他的方式?我使用cmake来组织代码,有什么特别的吗?
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?
推荐答案
问题似乎是OP正在构建32位项目。切换到64位项目时,问题得以解决。
The problem appears to be that OP was building a 32-bit project. The issue was resolved when switching to a 64-bit project.
我对CUDA 7.5及更高版本的建议是只使用64位项目。如果您在和
Purely as a matter of conjecture, this issue may be related to thrust issue #715
这篇关于cuda thrust :: remove_if throws“thrust :: system :: system_error” for device_vector?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!