cuda.bindings._v2.driver.ctx_from_green_ctx#

cuda.bindings._v2.driver.ctx_from_green_ctx(intptr_t h_ctx) → intptr_t#

Returns a CUcontext handle for a green context.

This API returns in p_context a CUcontext handle that represents the specified green context h_ctx. The returned handle can be passed to CUDA APIs that accept a CUcontext and will be treated as if it were a primary context, while still honoring the resources and configuration associated with h_ctx as applicable. Applications that wish to use a green context with CUDA APIs that require a CUcontext must use this API to obtain a handle to a CUcontext representing the green context. Otherwise, passing a green context to such APIs will fail with CUDA_ERROR_INVALID_CONTEXT. The CUcontext returned by cuCtxFromGreenCtx may be passed to CUDA Driver APIs that accept a CUcontext.

  • For APIs whose semantics are independent of green context resources, the operation is performed identically to how it would perform with a primary context.

  • For APIs whose behavior depends on green context resources (for example, kernel launch), the operation is performed using the resources and configuration of the specified green context h_ctx.

This call does not create a new independent context and does not change the underlying context lifetime. The validity of the returned p_context is tied to h_ctx, and no additional destruction or release is required beyond correctly managing h_ctx with the green context APIs. Destroying p_context via cuCtxDestroy is undefined behavior.

Parameters:

h_ctx (intptr_t) – Green context to convert.

Returns:

Returned CUcontext with green context resources.

Return type:

intptr_t

See also

cuCtxFromGreenCtx