thrust::min_element(...) crash on old GPU

I want to use my laptop for a Cuda project but the program crashes when I use “thrust::min_element”.

I get the following unhandled exception:

Unhandled exception at at 0x75EAC42D in MinElement.exe: Microsoft C++ exception: thrust::system::system_error at memory location 0x003EF2C0.

Example code:

#include <thrust/device_vector.h>
#include <thrust/extrema.h>

int main(void)
  thrust::device_vector<int> vec;
  for (int i(0); i < 1000; ++i) {

  thrust::min_element(vec.begin(), vec.end());

The exception seems to be thrown in this code block of synchronize.inl:

void synchronize(const char *message)
  cudaError_t error = cudaThreadSynchronize();
    throw thrust::system_error(error, thrust::cuda_category(), std::string("synchronize: ") + message);
  } // end if
} // end synchronize()

I am using compute_11/sm_11.
My system has the following specs:

  • GPU: NVidia GeForce GTX 280M (according to GPU Caps Viewer with compute capability 1.1)
  • CPU: Intel i7 Q720
  • OS: Windows 7, 64bit
  • CUDA Version 6.0 (also tested 6.5)

I want to use the laptop for development only. The target machine is newer. Performance is not an issue. I am new to CUDA development and don’t have much experience in low(er)-level coding. Is there maybe a way to have a second - working - execution path (maybe by using CUDA_ARCH). How would I go about implementing a replacement kernel/function?

I appreciate all inputs on how to solve this problem (except for “buy new hardware” ;) ).

Are you compiling a debug project in visual studio? If so, try compiling/running it as a release project.

Have you made the necessary project settings to compile for a cc1.1 target?

Thanks for your quick answer. Yes I am using Visual Studio. I did compile the test project as a release project now and indeed it worked. Problem is I seem to have yet another error in my “real” project code because that one crashes even in the Release build. Is there a way to build a DEBUG version that works like the RELEASE build? It would be very helpful for debugging the other problem.

I think the project settings should be right but I just browsed through a working sample project and manually adapted the changes from there. That means that besides setting the necessary file paths etc. I set “compute_11,sm_11” in “Configuration Properties->CUDA C/C+±>Device” and I chose “CUDA C/C++” in the Item Type properties of my file.

If you were only planning to debug host code, build your debug project without the -G switch. You’ll have to manually modify settings to do this. There are no project presets to do this.

If you were planning on debugging device thrust code, that’s going to be pretty involved.

If you need to debug other device code but no thrust device code, then separate your project into separate files, put the thrust code that you don’t want to debug in one file, and compile that file without -G. Put the other code that you want to debug in a separate file, and leave the debug settings as normal for that file (-G -g)

You may want to read this as well:

Thanks a lot! I’ll give it a try. Although I have to say that the project I am working on is someone else’s code and splitting it into multiple files will generate some trouble. But that is only my concern. ;)