cuda.core 1.3.0 Release Notes#

New features#

  • Added CUDAWarning, the warning category cuda.core uses for CUDA errors that cannot be raised, such as a failed driver call while a resource is released by the garbage collector. Filter on it with warnings.filterwarnings("error", category=cuda.core.CUDAWarning) to make such failures loud. The new error handling page documents what an exception from cuda.core guarantees, how failures that cannot be raised are reported, and how context restoration failures and sticky CUDA errors are handled.

Fixes and enhancements#

  • Cleanup failures are now reported as CUDAWarning instead of being written to stderr with print or fprintf, so they can be filtered, captured with warnings.catch_warnings(), and escalated. Failures of cuStreamDestroy, cuEventDestroy, cuMemFree, cuMemFreeAsync, cuMemFreeHost, cuMemPoolDestroy, cuGreenCtxDestroy, cuGraphDestroy, cuGraphExecDestroy, cuGraphicsUnregisterResource, cuLinkDestroy, cuArrayDestroy, cuMipmappedArrayDestroy, cuTexObjectDestroy, cuSurfObjectDestroy, user-object releases and the NVRTC, NVVM and nvJitLink destroy calls made from destructors were previously discarded; they are now reported. CUDA_ERROR_DEINITIALIZED (the driver is shutting down) is not reported. Test code that matched the old stderr text uses pytest.warns(CUDAWarning) instead.

  • When a Device method has to run in the device’s context and the caller’s context cannot be restored afterwards, the created resource is destroyed and the raised CUDAError now states that the caller’s context could not be restored and which context is current. Previously the error named only the driver status of the failed cuCtxSetCurrent call. A restoration failure during resource cleanup is reported as CUDAWarning.

  • Updating a memcpy or memset graph node whose context differs from the current one no longer risks a dangling node parameter when the caller’s context cannot be restored after the update: the resources referenced by the new parameters are now retained before the restoration failure is raised.

  • Device.set_current() with an explicit Context now switches contexts with a single driver call, so a failure leaves the previous context current instead of leaving the thread with no context. It also works when no context is current, returning None.

  • Failed rollbacks of a partially embedded child graph node and failed cuStreamEndCapture calls made when a still-building GraphBuilder is garbage collected are now reported as CUDAWarning; both were silent.

  • Stream.device and related queries on a stream whose context is not current now restore the caller’s context even when the device query fails.