Cuda 推力::设备_矢量不工作

Cuda 推力::设备_矢量不工作,cuda,thrust,Cuda,Thrust,我已经用推力写了一段代码。我正在粘贴下面的代码及其输出。奇怪的是,当执行过程中到达设备矢量线时,屏幕就挂起,不再有输出。它在早上工作。请帮帮我 #include <thrust/host_vector.h> #include <thrust/device_vector.h> #include <iostream> int main(void) { // H has storage for 4 integers thrust::host_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(4);
//初始化单个元素
H[0]=14;
H[1]=20;
H[2]=38;
H[3]=46;
//H.size()返回向量H的大小

std::cout运行设备查询。我确信,如果代码在早上运行,问题是由于图形卡造成的。

如果代码在早上运行,请查看您在计算机中所做的更改。该示例与我预期的一样有效。您是否更新了驱动程序?CUDA工具包?还有其他问题吗?。可能是的,是的真正的原因是卡停止响应。