thrust::copy doesn't work for device_vectors [

2019-09-02 07:01发布

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?

标签: cuda gpu thrust
1条回答
Root(大扎)
2楼-- · 2019-09-02 07:55

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."

查看更多
登录 后发表回答