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 contextctxwill 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 usingctxwhilecuCtxDestroy()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 typesCUmodule,CUfunction,CUstream,CUevent,CUarray,CUmipmappedArray,CUtexObject,CUsurfObject,CUtexref,CUsurfref,CUgraphicsResource,CUlinkState,CUexternalMemoryandCUexternalSemaphore. These resources also include memory allocations bycuMemAlloc(),cuMemAllocHost(),mem_alloc_managed()andcuMemAllocPitch(). Ifctxis current to the calling thread thenctxwill also be popped from the current thread’s context stack (as thoughcuCtxPopCurrent()were called). Ifctxis current to other threads, thenctxwill remain current to those threads, and attempting to accessctxfrom those threads will result in the errorCUDA_ERROR_CONTEXT_IS_DESTROYED.- Parameters:
ctx (intptr_t) – Context to destroy.
Note
cuCtxDestroy()will not destroy memory allocations bymem_create(),mem_alloc_async()andmem_alloc_from_pool_async(). These memory allocations are not associated with any CUDA context and need to be destroyed explicitly.See also
cuCtxDestroy_v2