0

My CUDA project already has few kernels that work properly, but I just can't get thrust to work. I tried running some trivial examples I've found on the net but nothing works. I always get an exception from this fragment of CUDA's code

  inline void checked_cudaMemcpyAsync(void *dst, const void *src, size_t count, enum cudaMemcpyKind kind, cudaStream_t stream)
  {
  cudaError_t error = cudaMemcpyAsync(dst,src,count,kind,stream);
  if(error)
  {
    throw thrust::system_error(error, thrust::cuda_category());
  } // end error
  } // end checked_cudaMemcpy()

Value of error is cudaErrorInvalidValue

Example code I tried running:

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

int main()
{
    thrust::host_vector<int> h_vec(1 << 10);
    thrust::generate(h_vec.begin(), h_vec.end(), rand);
    thrust::device_vector<int> d_vec = h_vec;
    thrust::sort(d_vec.begin(), d_vec.end());
    thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());

    return 0;
}
user3608068
  • 424
  • 2
  • 13
  • which CUDA version? which thrust version? which GPU? which driver? – m.s. Jan 02 '16 at 13:56
  • sm_30, GTX 770, win 8.1, driver 358.91, cuda 7.5.17, THRUST_VERSION 100802 – user3608068 Jan 02 '16 at 13:58
  • 3
    Are you sure you are building a 64 bit project in release mode? – talonmies Jan 02 '16 at 14:30
  • 3
    this may be a duplicate of [this](http://stackoverflow.com/questions/34460690/thrustcopy-doesnt-work-for-device-vectors) and [this](http://stackoverflow.com/questions/34000054/cuda-thrustremove-if-throws-thrustsystemsystem-error-for-device-vector), in particular building a win32 VS project vs. building a x64 VS project. – Robert Crovella Jan 02 '16 at 16:13
  • Yes, that was it, thank you. Also had to remove -G flag. Do you perhaps know why is there a problem with x86 executables? And why does it allow to be compiled in 32 bit when it is not supposed to work like that? – user3608068 Jan 02 '16 at 16:55
  • 2
    I don't have a great answer for you. If you read the linked questions, answers and comments, you'll discover that there is evidence that support for 32-bit in CUDA is gradually being removed. One comment even suggested an issue with ordinary (non-thrust) CUDA code in 32-bit. Thus my suggestion to compile a x64 app. You're welcome to file thrust issues or bugs at developer.nvidia.com. – Robert Crovella Jan 02 '16 at 17:25
  • 3
    I would generally consider this and the other two linked questions to be duplicates of thrust [issue #715](https://github.com/thrust/thrust/issues/715), which is currently recorded as a bug in thrust. But I don't know root cause, nor do I have much understanding of the issue anyway. Personally I couldn't rule out the possibility that there is an underlying CUDA issue, but it may be limited to thrust. – Robert Crovella Jan 02 '16 at 17:27
  • 2
    with respect to the `-G` compiler switch, that has been a [documented concern with thrust](https://github.com/thrust/thrust/wiki/Debugging) for some time. – Robert Crovella Jan 02 '16 at 17:37

0 Answers0