thrust::copy doesn't work for device_vectors [duplicate]

☆樱花仙子☆ 提交于 2019-12-12 05:38:57

问题


I copied this code from the Thrust documentation:

#include <thrust/copy.h>
#include <thrust/device_vector.h>
#include <thrust/host_vector.h>

int main()
{
  thrust::device_vector<int> vec0(100);
  thrust::device_vector<int> vec1(100);
  thrust::copy(vec0.begin(), vec0.end(), vec1.begin());

  return 0;
}

When I run this in Debug mode (VS2012), my program crashes and I get the error Debug Error! ... R6010 - abort() has been called. When I run this in Release mode, it still crashes and I get the message .exe has stopped working.

However copying from host-to-device works correctly:

  thrust::host_vector<int> vec0(100);
  thrust::device_vector<int> vec1(100);
  thrust::copy(vec0.begin(), vec0.end(), vec1.begin());

I use GeForce GTX 970, CUDA driver version/runtime version is 7.5, deviceQuery runs without any problem. Host runtime library is in Multi-threaded (/MT) mode. Does anybody have an idea what might cause this problem?


回答1:


There are a few similar questions e.g. here

To quote a comment :

"Thrust is known to not compile and run correctly when built for debugging"

And from the docs:

"nvcc does not support device debugging Thrust code. Thrust functions compiled with (e.g., nvcc -G, nvcc --device-debug 0, etc.) will likely crash."



来源:https://stackoverflow.com/questions/34460690/thrustcopy-doesnt-work-for-device-vectors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!