diff --git a/cuda_core/cuda/core/_utils/cuda_utils.pyx b/cuda_core/cuda/core/_utils/cuda_utils.pyx index 867d066ce2c..1bcfa524884 100644 --- a/cuda_core/cuda/core/_utils/cuda_utils.pyx +++ b/cuda_core/cuda/core/_utils/cuda_utils.pyx @@ -171,10 +171,9 @@ cpdef inline int _check_driver_error(cydriver.CUresult error) except?-1 nogil: cpdef inline int _check_runtime_error(error) except?-1: if error == _RUNTIME_SUCCESS: return 0 - name_err, name = runtime.cudaGetErrorName(error) - if name_err != _RUNTIME_SUCCESS: - raise CUDAError(f"UNEXPECTED ERROR CODE: {error}") - name = name.decode() + # `_check_error()` reaches this path only for `runtime.cudaError_t` values. + # Use the enum name directly because Windows hybrid cudart can lag that table. + name = error.name expl = RUNTIME_CUDA_ERROR_EXPLANATIONS.get(int(error)) if expl is not None: raise CUDAError(f"{name}: {expl}") diff --git a/cuda_core/tests/test_cuda_utils.py b/cuda_core/tests/test_cuda_utils.py index be22e57998b..32ea504248d 100644 --- a/cuda_core/tests/test_cuda_utils.py +++ b/cuda_core/tests/test_cuda_utils.py @@ -48,7 +48,6 @@ def test_check_driver_error(): def test_check_runtime_error(): - num_unexpected = 0 for error in runtime.cudaError_t: if error == runtime.cudaError_t.cudaSuccess: assert cuda_utils._check_runtime_error(error) == 0 @@ -56,14 +55,7 @@ def test_check_runtime_error(): with pytest.raises(cuda_utils.CUDAError) as e: cuda_utils._check_runtime_error(error) msg = str(e) - if "UNEXPECTED ERROR CODE" in msg: - num_unexpected += 1 - else: - # Example repr(error): - enum_name = repr(error).split(".", 1)[1].split(":", 1)[0] - assert enum_name in msg - # Smoke test: We don't want most to be unexpected. - assert num_unexpected < len(driver.CUresult) * 0.5 + assert error.name in msg def test_driver_error_enum_has_non_empty_docstring():