Nvdc errors when running two instances of gstreamer

Im receiving the following error when trying to launch two instances of Gstreamer:

NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
nvdc: open: Too many open files
nvdc: failed to open '/dev/fb0'.
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
nvdc: open: Too many open files
nvdc: failed to open '/dev/tegra_dc_1'.
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
nvdc: open: Too many open files
nvdc: failed to open '/dev/tegra_dc_1'

The pipeline is very simple:

 std::ostringstream launch_stream;
  launch_stream <<
    "nvarguscamerasrc sensor-id="<<argus_device_idx_offset << 
    " sensor-mode=1 do-timestamp=true wbmode=1 aelock=0 exposuretimerange='11000 6954000'  ee-mode=0 gainrange='1 4' ispdigitalgainrange='1 1' aeantibanding=3 tnr-mode=2 tnr-strength=-0.2 ! "  <<
    "video/x-raw(memory:NVMM),width=" << w << ",height=" << h << ",framerate=" << frame_rate << "/1,format=NV12 ! " <<
    "nvvidconv interpolation-method=4 ! video/x-raw(memory:NVMM), format=NV12, width=960 height=540 ! " <<
    "nvvidconv name=myconv ! " <<
    "video/x-raw(memory:NVMM),format=RGBA ! " <<
    "nvoverlaysink ";

The custom nvvidconv is just getting the frame to perfrom opencv operations:

static GstPadProbeReturn conv_src_pad_buffer_probe(
  GstPad * pad, GstPadProbeInfo * info,
  gpointer u_data)
{
  JUtilsCameraDriver * jcd_ptr = reinterpret_cast<JUtilsCameraDriver *>(u_data);
  GstBuffer * buffer = (GstBuffer *) info->data;
  GstMapInfo map = {0};
  int dmabuf_fd = 0;
  gst_buffer_map(buffer, &map, GST_MAP_READ);
  ExtractFdFromNvBuffer((void *)map.data, &dmabuf_fd);
  //CUDA postprocess
  {
    EGLImageKHR egl_image;
    egl_image = NvEGLImageFromFd(egl_display, dmabuf_fd);
    CUresult status;
    CUeglFrame eglFrame;
    CUgraphicsResource pResource = NULL;
    cudaFree(0);
    status = cuGraphicsEGLRegisterImage(
      &pResource,
      egl_image,
      CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE);
    if (status != CUDA_SUCCESS) {
      printf("cuGraphicsEGLRegisterImage failed: %d \n", status);
    }
    status = cuGraphicsResourceGetMappedEglFrame(&eglFrame, pResource, 0, 0);
    status = cuCtxSynchronize();
    if (create_filter) {
      filter = cv::cuda::createSobelFilter(CV_8UC4, CV_8UC4, 1, 0, 3, 1, cv::BORDER_DEFAULT);
      //filter = cv::cuda::createGaussianFilter(CV_8UC4, CV_8UC4, cv::Size(31,31), 0, 0, cv::BORDER_DEFAULT);
    }

    cv::cuda::GpuMat d_mat_RGBA(h, w, CV_8UC4, eglFrame.frame.pPitch[0]);     //RGBA

    /* Get BGR */
    cv::cuda::GpuMat d_mat_BGR;
    cv::cuda::cvtColor(d_mat_RGBA, d_mat_BGR, cv::COLOR_RGBA2BGR, 3);
    cv::Mat myImageBGR;
    d_mat_BGR.download(myImageBGR);

    ++frame_num;
    status = cuCtxSynchronize();
    status = cuGraphicsUnregisterResource(pResource);
    NvDestroyEGLImage(egl_display, egl_image);
  }
  gst_buffer_unmap(buffer, &map);

  return GST_PAD_PROBE_OK;
}

If a launch more than one instance of the code, there errors appear and the 2nd instance crashes.
What is this error and what could be causing it?

Hi,
Seems like you would like to display multiple windows. For this use-case, please use nv3dsink or nveglglessink.

Thanks for the reply!

Im not looking to display the image. The code inside the conv_src_pad_buffer_probe(){...} was taken from an example for getting a frame out of the Gstreamer pipeline into OpenCV Mat for processing.

I commented out the entire function and left a print statement and Im still seeing the same issue of

NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
nvdc: open: Too many open files
nvdc: failed to open '/dev/fb0'.
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
nvdc: open: Too many open files
nvdc: failed to open '/dev/tegra_dc_1'.
NvxBaseWorkerFunction[2575] comp OMX.Nvidia.std.iv_renderer.overlay.yuv420 Error -2147479552
nvdc: open: Too many open files
nvdc: failed to open '/dev/tegra_dc_1'

Does running a second instance failing have to do with egl_display.

Im open to other solution for getting a frame from the pipeline into OpenCV GPU Mat. This method works and is pretty optimized.
I have already been down the road of using OpenCV to create the pipe and fetch the image, but was looking for a more optimal way that would give me more control over the Gstreamer pipeline itself.

Thanks

I was able to solve my problem. The issue was I was using nvoverlaysink vs just fakesink in the gstreamer pipeline.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.