Error reporting method for CUDA calls. Args: cuda_ret: Tuple returned by CUDA runtime calls, where the first element is a cudaError_t enum and subsequent elements are return values. Raises: RuntimeError: If the CUDA call returned an error.
(cuda_ret)
| 82 | |
| 83 | |
| 84 | def cuassert(cuda_ret): |
| 85 | """ |
| 86 | Error reporting method for CUDA calls. |
| 87 | Args: |
| 88 | cuda_ret: Tuple returned by CUDA runtime calls, where the first element |
| 89 | is a cudaError_t enum and subsequent elements are return values. |
| 90 | |
| 91 | Raises: |
| 92 | RuntimeError: If the CUDA call returned an error. |
| 93 | """ |
| 94 | err = cuda_ret[0] |
| 95 | if err.value != 0: |
| 96 | err_msg = f"CUDA ERROR: {err.value}" |
| 97 | try: |
| 98 | _, err_name = cudart.cudaGetErrorName(err) |
| 99 | _, err_str = cudart.cudaGetErrorString(err) |
| 100 | err_msg = f"CUDA ERROR {err.value}: {err_name} — {err_str}" |
| 101 | except Exception as e: |
| 102 | get_logger("monai.networks.trt_compiler").debug(f"Failed to retrieve CUDA error details: {e}") |
| 103 | raise RuntimeError(err_msg) |
| 104 | if len(cuda_ret) > 1: |
| 105 | return cuda_ret[1] |
| 106 | return None |
| 107 | |
| 108 | |
| 109 | class ShapeError(Exception): |
no test coverage detected
searching dependent graphs…