Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kernel_tuner/utils/nvcuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@

def cuda_error_check(error):
"""Checking the status of CUDA calls using the NVIDIA cuda-python backend."""
# cuda-python always returns a tuple, also for calls that only return a status, e.g. (CUresult,)
if isinstance(error, tuple) and len(error) == 1:
error = error[0]
if isinstance(error, driver.CUresult):
if error != driver.CUresult.CUDA_SUCCESS:
_, name = driver.cuGetErrorName(error)
Expand All @@ -60,6 +63,8 @@ def cuda_error_check(error):
if error != nvrtc.nvrtcResult.NVRTC_SUCCESS:
_, desc = nvrtc.nvrtcGetErrorString(error)
raise RuntimeError(f"NVRTC error: {desc.decode()}")
else:
raise TypeError(f"Unable to check CUDA status of unexpected type {type(error).__name__}: {error!r}")


def _check(call_result):
Expand Down
Loading