MCPcopy Index your code
hub / github.com/Project-MONAI/MONAI / cuassert

Function cuassert

monai/networks/trt_compiler.py:84–106  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

82
83
84def 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
109class ShapeError(Exception):

Callers 1

inferMethod · 0.85

Calls 2

get_loggerFunction · 0.90
debugMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…