CUDA 内核导致"display driver not responding",增加了 4 行
CUDA kernel causing causing "display driver not responding" with the addition of 4 lines
基本问题如下:
当我用N个线程运行下面的内核时,不包括4行来实例化和填充ScaledLLA变量工作良好。
当我用N个线程运行下面的内核时,do包括4用于实例化和填充GPU锁定的ScaledLLA变量的行打开,Windows抛出"显示驱动程序未响应"错误。
如果我通过减小网格大小来减少运行的线程数一切都很顺利。
我是CUDA的新手,一直在逐步构建一些GIS功能。
我的主机代码在内核调用时看起来是这样的。
MapperKernel << <g_CUDAControl->aGetGridSize(), g_CUDAControl->aGetBlockSize() >> >(g_Deltas.lat, g_Deltas.lon, 32.2,
g_DataReader->aGetMapper().aGetRPCBoundingBox()[0], g_DataReader->aGetMapper().aGetRPCBoundingBox()[1],
g_CUDAControl->aGetBlockSize().x,
g_CUDAControl->aGetThreadPitch(),
LLA_Offset,
LLA_ScaleFactor,
RPC_XN,RPC_XD,RPC_YN,RPC_YD,
Pixel_Offset, Pixel_ScaleFactor,
device_array);
cudaDeviceSynchronize(); //code crashes here
host_array = (point3D*)malloc(num_bytes);
cudaMemcpy(host_array, device_array, num_bytes, cudaMemcpyDeviceToHost);
被调用的内核看起来像这样:
__global__ void MapperKernel(double deltaLat, double deltaLon, double passedAlt,
double minLat, double minLon,
int threadsperblock,
int threadPitch,
point3D LLA_Offset,
point3D LLA_ScaleFactor,
double * RPC_XN, double * RPC_XD, double * RPC_YN, double * RPC_YD,
point2D pixelOffset, point2D pixelScaleFactor,
point3D * rValue)
{
//calculate thread's LLA
int latindex = threadIdx.x + blockIdx.x*threadsperblock;
int lonindex = threadIdx.y + blockIdx.y*threadsperblock;
point3D LLA;
LLA.lat = ((double)(latindex))*deltaLat + minLat;
LLA.lon = ((double)(lonindex))*deltaLon + minLon;
LLA.alt = passedAlt;
//scale threads LLA - adding these four lines is what causes the problem
point3D ScaledLLA;
ScaledLLA.lat = (LLA.lat - LLA_Offset.lat) * LLA_ScaleFactor.lat;
ScaledLLA.lon = (LLA.lon - LLA_Offset.lon) * LLA_ScaleFactor.lon;
ScaledLLA.alt = (LLA.alt - LLA_Offset.alt) * LLA_ScaleFactor.alt;
rValue[lonindex*threadPitch + latindex] = ScaledLLA; //if I assign LLA without calculating ScaledLLA everything works fine
}
如果我将LLA分配给rValue,那么一切都会快速执行,并且我得到了预期的行为;然而,当我为ScaledLLA添加这四行并试图将其分配给rValue时,CUDA在cudaDeviceSynchronize((调用中花费了太长时间,而我得到了"显示驱动程序未响应"错误,然后继续重置GPU。环顾四周,错误似乎是windows认为GPU没有响应时发生的事情。我确信内核正在运行并执行正确的计算,因为我已经使用NSIGHT调试器进行了调试。
有人能很好地解释为什么在内核中添加这三行会导致执行时间激增吗?
我正在运行Win7 VS 2013,并安装了nsight 4.5。
对于那些稍后通过搜索引擎到达这里的人。原来问题出在卡的内存不足。
这可能是最需要考虑的事情之一,因为问题是在添加实例化之后才出现的。
卡只有这么多内存(~2GB(,我的右值缓冲区占用了大部分内存(~1.5GB(。每个线程都试图实例化自己的point3D变量,卡的内存就用完了。
对于那些感兴趣的人,NSight的探查器说这是一个cudaUknownError。
修复方法是减少运行内核的线程数量
相关文章:
- 数组索引的值没有增加
- 为什么我的代码在输出中增加了93天
- 有效地使用std::unordered_map来插入或增加键的值
- C++ 动态数组每次添加时将大小增加 1 - 错误
- 为什么要增加导致崩溃的指针
- 增加传递地址的值
- 如何增加以前由新运算符分配的 C++ std::list 数组的大小?
- 为什么"i"在循环的每次迭代中都没有增加?(C++)
- std::thread 增加 DLL 引用计数,从而防止卸载 DLL
- 如何在C++中为增加但记住删除先前对象的对象分配唯一标识符
- 将一对插入地图并增加计数?
- 整数类型应该显式转换(例如"int"到"无符号")还是只会增加混乱?
- 我的 c++ 应用程序中的运行时间从 0 增加到 60 太快了(例如一毫秒或一微秒)
- 为什么当通过 TCP 发送的消息速率增加时,请求-响应消息对的延迟会降低?
- 琐碎并发代码的吞吐量不会随着线程数量的增加而增加
- C++:功能在输出前自动使用50减/增加输入数
- 追加位以增加字符的大小
- 为什么在C++中增加指针后打印了一个值而不是 NULL/0?
- 内存增加和字符串流?
- CUDA 内核导致"display driver not responding",增加了 4 行