check_error

paddle.cuda. check_error ( res ) [源代码]

检查给定的 CUDA 运行时返回的状态码,当 res 是错误码时,抛出对应的 CUDA 错误异常。

参数

  • res (int) - CUDA 运行时返回的状态码。

代码示例

>>> from paddle.cuda import check_error
>>> check_error(0) # check for cuda success code # will not raise Error
>>> # check_error(1) # check for cuda error code 1(invalid argument), will raise Error
>>> # check_error(2) # check for cuda error code 2(out of memory), will raise Error