0
votes

I have written a code using Thrust. I am pasting the code and its output below. Strangely, when the device_vector line is reached during exectution the screen just hangs and no more output comes. It was working in the morning. Please help me.

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

#include <iostream>

int main(void)
{
// H has storage for 4 integers
thrust::host_vector<int> H(4);

// initialize individual elements
H[0] = 14;
H[1] = 20;
H[2] = 38;
H[3] = 46;

// H.size() returns the size of vector H
std::cout << "H has size " << H.size() << std::endl;

// print contents of H
for(size_t i = 0; i < H.size(); i++)
    std::cout << "H[" << i << "] = " << H[i] << std::endl;

// resize H
H.resize(2);

std::cout << "H now has size " << H.size() << std::endl;

// Copy host_vector H to device_vector D
thrust::device_vector<int> D = H;

// elements of D can be modified
D[0] = 99;
D[1] = 88;

// print contents of D
for(size_t i = 0; i < D.size(); i++)
    std::cout << "D[" << i << "] = " << D[i] << std::endl;

// H and D are automatically deleted when the function returns
return 0;
}

The output is : H has size 4 H[0] = 14 H[1] = 20 H[2] = 38 H[3] = 46 H now has size 2

* After this nothing happens

1
If it was working in the morning review what changed you have made in your computer. The example works as expected for me. Did you update the driver? the CUDA toolkit? anything else?. - pQB
possible duplicate of deviceQuery not responding - talonmies
Yes, the real reason was that the card stopped responding. - user1439690

1 Answers

1
votes

Run Device Query. I am confident that if the code was working in the morning, the problem is due to the graphics card.