VPI Internal Error

Hey there,

when using VPI, we stumbled get the following error:

terminate called after throwing an instance of 'std::runtime_error' what(): [VPI ERROR]VPI_ERROR_INTERNAL | Failed to create an NvMediaVPI handle

The exception is thrown by a wrapper for VPI function calls like this, which also generates the message above. It basically pretty prints VPI error statuses and throws.

void check_vpi(const VPIStatus &vpi_status, const std::string &message) {
    if (vpi_status != VPI_SUCCESS) {
        char buffer[VPI_MAX_STATUS_MESSAGE_LENGTH];
        vpiGetLastStatusMessage(buffer, sizeof(buffer));
        std::ostringstream ss;
        ss << "[VPI ERROR]" << vpiStatusGetName(vpi_status) << " | " << buffer << ": " << message;
        throw std::runtime_error(ss.str());

This would be an example usage:


This happens when repeatedly launching our executable. It even happens when there is a minute long pause between launches.

So the sequence is:

  1. Launch executable
  2. Wait for it to finish running
  3. Optionally wait
  4. Repeat

Is there any remedy for this? We did not yet pinpoint the location of the exception, since it is not directly reproducible. It only happens sometimes. I would assume that it does not have to do with the wrapped call per se, but simply fails on the first call because there is no VPI handle.


NvMediaVPI is a backend library related to the image usage.
A possible reason is from vpiImageCreateCUDAMemWrapper.

vpiImageCreateCUDAMemWrapper mainly wrap a pre-allocated GPU buffer.
So you need to make sure the buffer is available during the vpiImageCreate… to vpiImageDestroy.

Could you help to validate it?
If all looks good, would you mind to share a simple source for us to reproduce?