# Reset CUDA error when using driver API cuXXX functions keep returning the same error code

**URL:** <https://forums.developer.nvidia.com/t/reset-cuda-error-when-using-driver-api-cuxxx-functions-keep-returning-the-same-error-code/17551>\
**Category:** CUDA Programming and Performance\
**Created:** [July 7, 2010, 7:32am UTC](https://forums.developer.nvidia.com/t/reset-cuda-error-when-using-driver-api-cuxxx-functions-keep-returning-the-same-error-code/17551 "2010-07-07T07:32:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![timchist](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@timchist](https://forums.developer.nvidia.com/u/timchist)\
**Post date:** [July 7, 2010, 7:32am UTC](https://forums.developer.nvidia.com/t/reset-cuda-error-when-using-driver-api-cuxxx-functions-keep-returning-the-same-error-code/17551/1 "2010-07-07T07:32:09Z")

</div>

If a kernel launch fails (for example, due to attempts to address out-of-bounds GPU memory), CUDA\_ERROR\_LAUNCH\_FAILED is returned from subsequent cuCtxSynchronize() call. When, however, I try to call any other cuXXX function after that (for example, cuMemFree(), cuCtxDestroy(), or cuModuleUnload()), they also return CUDA\_ERROR\_LAUNCH\_FAILED (but the functions themselves seem to work correctly despite non-zero return code).

The same problem seems to exist with the CUDA\_ERROR\_OUT\_OF\_MEMORY error: subsequent cuXXX calls also return CUDA\_ERROR\_OUT\_OF\_MEMORY.

Is it really the case or I’m doing something wrong? Maybe I should call something to reset the last error code? When working with runtime API, I can use cudaGetLastError() for this purpose (didn’t check whether it helps however, since it would require to rewrite all my code which currently uses driver API), but I don’t see any similar function among driver API.

I use CUDA Toolkit 3.1, GTX 470, and 257.21 developer driver.
