2012-10-24 33 views
0

我已經使用Thrust編寫了一個代碼。我正在粘貼下面的代碼和輸出。奇怪的是,當執行期間到達device_vector行時,屏幕掛起,不再有輸出。它在早上工作。請幫幫我。thrust :: device_vector不工作

#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; 
} 

的輸出是: H具有大小爲4 H [0] = 14 H [1] = 20 H [2] = 38 H [3] = 46 H現在用於具有大小2

*這個沒什麼之後發生

+0

如果它在早上檢查您的計算機中所做的更改。這個例子符合我的預期。你有沒有更新驅動程序? CUDA工具包?還要別的嗎?。 – pQB

+0

[deviceQuery not responding]可能重複(http://stackoverflow.com/questions/13047047/devicequery-not-responding) – talonmies

+0

是的,真正的原因是卡停止響應。 – user1439690

回答

1

運行設備查詢。我相信,如果代碼在早上工作,問題是由於顯卡。

相關問題