Hello,
I recently installed CUDA V11.0.221 on Windows 10 and just wanted to use the thrust library. Cuda works (I checked that) but thrust kept throwing the same exceptions once I started using device_vectors. So I just made a new project, copied the example code from the website (see below) and hit run. Well, I still get following exception error once I copy data into a device_vector :
Run-Time Check Failure #3 - The variable ‘result’ is being used without being initialized.
This is caused in file allocator_traits.inl line 251
This is caused whenever I try to copy anything into a device vector. I tried multiple examples, all fail!
This was tested with and without Microsoft Visual Studio. I did not alter the example code in any way!
I have no idea why or how thrust breaks. If someone could help me or tell me how to debug this, I would be very grateful.
#include <thrust/host_vector.h>
#include <thrust/device_vector.h>
#include <thrust/generate.h>
#include <thrust/sort.h>
#include <thrust/copy.h>
#include <algorithm>
#include <cstdlib>
int main(void)
{
// generate 32M random numbers serially
thrust::host_vector<int> h_vec(32 << 20);
std::generate(h_vec.begin(), h_vec.end(), rand);
// transfer data to the device
thrust::device_vector<int> d_vec = h_vec; //<- THIS IS WHERE EVERYTHING BREAKS !
// sort data on the device (846M keys per second on GeForce GTX 480)
thrust::sort(d_vec.begin(), d_vec.end());
// transfer data back to host
thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());
return 0;
}