简单的 CUDA 推力程序错误 [英] Simple CUDA Thrust Program Error
本文介绍了简单的 CUDA 推力程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是写了一个简单的 CUDA Thrust 程序,但是当我运行它时.我收到了这个错误:thrust::system::system_error at position 0x0037f99c .
I just write an simple CUDA Thrust program, but when I run it. I got this error: thrust::system::system_error at position 0x0037f99c .
谁能帮我弄清楚为什么会这样?
Can someone help me to figure out why this happen?
#include<thrusthost_vector.h>
#include<thrustdevice_vector.h>
#include<iostream>
using namespace std;
using namespace thrust;
int main()
{
thrust::host_vector<int> h_vec(3);
h_vec[0]=1;h_vec[1]=2;h_vec[2]=3;
thrust::device_vector<int> d_vec(3) ;
d_vec= h_vec;
int h_sum = thrust::reduce(h_vec.begin(), h_vec.end());
int d_sum = thrust::reduce(d_vec.begin(), d_vec.end());
return 0;
}
推荐答案
Thrust 的一些建议:
A few suggestions with Thrust:
- 如果您在使用
-G
编译代码时遇到问题,请尝试不使用-G
进行编译 - 您可以捕获推力引发的错误,以获取更多信息.
- 始终建议针对您使用的 GPU 架构编译代码.因此,如果您使用的是 cc2.0 GPU,请使用
-arch=sm_20
进行编译.如果您使用的是 cc3.0 GPU,请使用-arch=sm_30
等进行编译. - 最后,建议构建一个 64 位项目.在 Windows 上,您将选择一个 release/x64 项目.
- If you are compiling your code with
-G
and having trouble, try compiling without-G
- You can catch the errors that thrust throws, to get more information.
- It's always recommended to compile your code for the architecture of the GPU you are using. So if you are on a cc2.0 GPU, compile with
-arch=sm_20
. If you are on a cc3.0 GPU, compile with-arch=sm_30
etc. - Finally, it's recommended to build a 64-bit project. On windows you would select a release/x64 project.
这篇关于简单的 CUDA 推力程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文