Nvbufsurface: mapping of memory type (0) not supported

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) :T4
• DeepStream Version:5.0
• TensorRT Version:7.0.1
• NVIDIA GPU Driver Version (valid for GPU only):440.64

I have achieved save image in dsexample plugin, but I think it is a waste for doing only this thing, meanwhile it would get segmentation fault for a long time.

So I want to save image via osd sink/src pad prob in deepstream-app just like Access video frame and use opencv to draw on it in pad probe callback.

However I get error of nvbufsurface: mapping of memory type (0) not supported. Below is my probe code.

static GstPadProbeReturn
osd_bin_src_pad_prob (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
GstBuffer *buf = (GstBuffer *) info->data;
GstMapInfo in_map_info;
NvBufSurface *surface = NULL;
NvDsBatchMeta *batch_meta = NULL;
NvDsMetaList *l_frame = NULL;
NvDsFrameMeta *frame_meta = NULL;
memset (&in_map_info, 0, sizeof (in_map_info));
if (gst_buffer_map (buf, &in_map_info, GST_MAP_READWRITE))
surface = (NvBufSurface *) in_map_info.data;
NvBufSurfaceMap(surface, -1, -1, NVBUF_MAP_READ_WRITE);
NvBufSurfaceSyncForCpu(surface, -1, -1);
batch_meta = gst_buffer_get_nvds_batch_meta(buf);
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
l_frame = l_frame->next)
frame_meta = (NvDsFrameMeta *)(l_frame->data);
gint frame_width = (gint)surface->surfaceList[frame_meta->batch_id].width;
gint frame_height = (gint)surface->surfaceList[frame_meta->batch_id].height;
void *frame_data = surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0];
size_t frame_step = surface->surfaceList[frame_meta->batch_id].pitch;
// cv::Mat frame = cv::Mat(frame_height, frame_width, CV_8UC4, frame_data, frame_step);
NvBufSurfaceUnMap(surface, -1, -1);
gst_buffer_unmap (buf, &in_map_info);

Please give me some advices for this problems, and which way is better to save image.

Please check the information of NvBufSurface:

typedef struct NvBufSurface {
  /** Holds a GPU ID. Valid only for a multi-GPU system. */
  uint32_t gpuId;
  /** Holds the batch size. */
  uint32_t batchSize;
  /** Holds the number valid and filled buffers. Initialized to zero when
   an instance of the structure is created. */
  uint32_t numFilled;
  /** Holds an "is contiguous" flag. If set, memory allocated for the batch
   is contiguous. */
  bool isContiguous;
  /** Holds type of memory for buffers in the batch. */
  NvBufSurfaceMemType memType;
  /** Holds a pointer to an array of batched buffers. */
  NvBufSurfaceParams *surfaceList;

  void * _reserved[STRUCTURE_PADDING];
} NvBufSurface;

More information should help on clarifying the issue.

This might help:

May need to configure nvbuf_memory-type in some plugins.

Hi, @DaneLLL
Thanks for your anwser. I’ll have a try to set plugins nvbuf_memory_type.

But there is no same error when I use dsexample plugin, so I wonder the difference between probe function and plugin method in order to save images, and which way is recommanded from you.


The default code in gstdsexample.cpp shoudl work fine. Do you hit the error in running the default code?