cudaMalloc代码运行2-3个小时,内存分配失败有什么原因吗?
我正在使用"Process Explorer“程序检查全局内存使用情况。虽然cudaMalloc上的空闲全局内存仍然可用,但突然之间gpu无法分配。
如何检查此失败的主要原因?我正在这样做:
if ( cudaSuccess !=cudaMalloc((void **) &arr, sizeof(int)*100))
printf("Cannot Allocate Mem");有没有更好的方法来打印cuda中失败的实际原因?
发布于 2011-12-25 20:24:05
您可以执行以下操作:
cudaError_t err= cudaMalloc((void **) &arr, sizeof(int)*100);
if(err != cudaSuccess){
printf("The error is %s", cudaGetErrorString(err));
}这将打印出错误的确切原因。例如:无效的设备指针表示您正在访问的指针没有指向任何内容。
https://stackoverflow.com/questions/8629424
复制相似问题