cuda.bindings._v2.driver.ctx_destroy_v2#

cuda.bindings._v2.driver.ctx_destroy_v2(intptr_t ctx)#

Destroy a CUDA context.

Destroys the CUDA context specified by ctx. The context ctx will be destroyed regardless of how many threads it is current to. It is the responsibility of the calling function to ensure that no API call issues using ctx while cuCtxDestroy() is executing. Destroys and cleans up all resources associated with the context. It is the caller’s responsibility to ensure that the context or its resources are not accessed or passed in subsequent API calls and doing so will result in undefined behavior. These resources include CUDA types CUmodule, CUfunction, CUstream, CUevent, CUarray, CUmipmappedArray, CUtexObject, CUsurfObject, CUtexref, CUsurfref, CUgraphicsResource, CUlinkState, CUexternalMemory and CUexternalSemaphore. These resources also include memory allocations by cuMemAlloc(), cuMemAllocHost(), mem_alloc_managed() and cuMemAllocPitch(). If ctx is current to the calling thread then ctx will also be popped from the current thread’s context stack (as though cuCtxPopCurrent() were called). If ctx is current to other threads, then ctx will remain current to those threads, and attempting to access ctx from those threads will result in the error CUDA_ERROR_CONTEXT_IS_DESTROYED.

Parameters:

ctx (intptr_t) – Context to destroy.

Note

cuCtxDestroy() will not destroy memory allocations by mem_create(), mem_alloc_async() and mem_alloc_from_pool_async(). These memory allocations are not associated with any CUDA context and need to be destroyed explicitly.

See also

cuCtxDestroy_v2