How to use NvEncoder with cuda runtime api(with out driver api)


My code used CUDA with runtime api for some image process.
Now I need use NvEncoder to encode the image after processed.

So I should create encoder and create session,and I must pass a CUContext as argument in nvEncOpenEncodeSessionEx func.
but I used cuda runtime api,I have no CUContext,

A:What can I do to create NvEncoder without CUContext.
or B: Can I use the driver api func—‘cuCtxGetCurrent(&primaryCtx)’ to get primaryCtx(create by runtime api).then use the
primaryCtx to open encode session?


I faced with the same issue trying to get Encoder working. We’re using Cuda runtime api everywhere, should I really deal with Cuda Driver API just for this?

I have the same question. Is there a way to use NvEncoder through runtime api?