cudathrust::remove_if 抛出“thrust::system::system_error"对于 device_vector? [英] cuda thrust::remove_if throws "thrust::system::system_error" for device_vector?

查看:17
本文介绍了cudathrust::remove_if 抛出“thrust::system::system_error"对于 device_vector?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在 VS 2013 下使用 CUDA 7.5.今天我需要从 device_vector 中删除一些元素,因此决定使用 remove_if.但是无论我修改代码,程序编译得很好,但在运行时抛出thrust::system::system_error".

首先我尝试了自己的代码:

int main(){推力::host_vector<int>AA(10, 1);推力::序列(AA.begin(),AA.end());推力::host_vector<bool>SS(10,假);推力::填充(SS.begin(),SS.begin()+ 5,真);推力::device_vector<int>devAA=AA;推力::device_vector<bool>开发SS = SS;推力::设备向量<int>::迭代器new_end =推力::移除_if(推力::设备,devAA.begin()、devAA.end()、devSS.begin()、thrust::identity<int>());}

但它会在运行时抛出 thrust::system::system_error.但是,如果我使用两个host_vector,即AASS来执行remove_if,一切正常.p>

然后,我尝试了在 stackoverflow here 上找到的代码,Robert Crovella 的答案中的代码似乎工作正常,但是在我的机器上,它仍然抛出 thrust::system::system_error.

新版本的推力修改了什么?还是我应该尝试其他方式?我用cmake整理代码,有什么特别的吗?

解决方案

问题似乎是 OP 正在构建一个 32 位项目.切换到 64 位项目时问题已解决.

我对 CUDA 7.5 及更高版本的建议是仅使用 64 位项目.如果您在 windowslinux 你会发现它非常有限.

纯属推测,此问题可能与thrust issue #715

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?

解决方案

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

这篇关于cudathrust::remove_if 抛出“thrust::system::system_error"对于 device_vector?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆