0

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?

Robert Crovella
  • 143,785
  • 11
  • 213
  • 257
Grisha Kirilin
  • 282
  • 2
  • 12
  • The code your have posted compiles and runs without error for me using the same compiler and CUDA version as you say you are using. – talonmies Dec 25 '15 at 07:59
  • @talonmies I tried my laptop (VS2013, QuadroK1000M) and the program still crashes. Here is full VS solutions https://goo.gl/FFs1cD or https://goo.gl/pFss5E – Grisha Kirilin Dec 25 '15 at 08:43
  • 1
    what happens if you put a `cudaDeviceSynchronize();` immediately before the `return 0;` statement? Does that fix the issue? – Robert Crovella Dec 25 '15 at 15:25
  • @RobertCrovella Unfortunately, it doesn't. cudaGetLastError() shows nothing. However I tried Amazon cloud service and the code runs fine! It seems that it is only Windows problem. – Grisha Kirilin Dec 26 '15 at 06:40
  • 3
    OK my guess is you are building a win32 project. Switch to building an x64 (release) project instead, and I think the problem will go away. Note that when you switch to x64, VS puts the executable in a different path, so don't run the same executable that was built by your win32 project. Support for 32-bit on windows is disappearing from CUDA. – Robert Crovella Dec 26 '15 at 16:58
  • @RobertCrovella Thank you, thank you, thank you, thank you, thank you, thank you, thank you! It works! Could you copy your comment as an answer so that I can accept it? – Grisha Kirilin Dec 27 '15 at 06:14
  • @RobertCrovella I found that it was not a problem of Thrust at all. In another project I tried to use constant memory and use cudaMemcpyToSymbol() to copy from the device memory. It resulted in crash too. Switching to x64 has also fixed the problem. – Grisha Kirilin Dec 27 '15 at 10:29

1 Answers1

0

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

Community
  • 1
  • 1
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256