且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

一旦cudaMalloc返回内存不足,每个cuda API调用都会返回失败

更新时间:2023-02-16 19:55:31

一旦CUDA遇到错误,所有API调用都会返回该错误.如果错误破坏了CUDA上下文,除了重置设备(cudaDeviceReset)之外,您无需执行其他任何操作.如果CUDA上下文未损坏,则状态可以为重置调用cudaGetLastError()cudaSuccess.

Once CUDA encounters an error, all API calls will return that error. If the error corrupts the CUDA context, there's not much to do except reset the device (cudaDeviceReset). If the CUDA context has not been corrupted then the state can be reset to cudaSuccess by calling cudaGetLastError().

根据罗伯特·克罗维拉(Robert Crovella)的

As per Robert Crovella's comment, a failed cudaMalloc probably does not corrupt the CUDA context and therefore you should be able to recover. This is not necessarily true of other causes of an error, and each case may be different.