简单CUDA推力程序错误 [英] Simple CUDA Thrust Program Error

查看:141
本文介绍了简单CUDA推力程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是写了一个简单的CUDA Thrust程序,但是当我运行它。我得到这个错误:thrust :: system :: system_error在位置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<thrust\host_vector.h>
#include<thrust\device_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;
}


推荐答案


  • 如果您正在使用 -G 编译代码并遇到问题,请尝试编译 -G

  • < the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api>捕获推送的错误
    ,以获得更多信息。
  • 始终建议为您正在使用的GPU的体系结构编译代码。所以如果你在一个cc2.0 GPU,编译与 -arch = sm_20 。如果您使用的是cc3.0 GPU,请使用 -arch = sm_30 等编译。

  • 最后,位项目。在Windows上,您将选择一个版本/ 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屋!

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