问题
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