Video Codec SDK: cuvidMapVideoFrame followed by cudaMemcpy2D

The sample does this

  1. cuvidMapVideoFrame

  2. Create destination frames using cuMemAlloc (Driver API)

  3. cuMemcpy2DAsync (Driver API) (copy mapped frame to allocated frame)

Can this instead be done:

  1. cuvidMapVideoFrame

  2. Create destination frames using cudaMalloc (Runtime API)

  3. cudaMemcpy2DAsync (Runtime API) (copy mapped frame to allocated frame)

The reason why we want to do this is that the destination frames are sent to a video processing pipeline which also creates device frames but using the Runtime API (cudaMalloc).

We prefer not to have to distinguish between frames that we have to release using cuMemFree and those that we have to release using cudaFree.

Hi frederickkl77n1,

It should be okay to use CUDA runtime API instead of CUDA driver API. You may have to explicitly take care of thread’s current context based on how you implement the code.

I recommend you to have a look at CUDA Toolkit Documentation as well.
https://docs.nvidia.com/cuda/cuda-driver-api/driver-vs-runtime-api.html#driver-vs-runtime-api

Thanks.