Process NvBuffer in CUDA without EGLDisplay


How do I process an NvBuffer in CUDA without a display manager active?

The process to get a CUDA memory pointer used in nvidia examples:

EGLImageKHR egl_image = NvEGLImageFromFd(NULL, dmabuf);
    if (egl_image == NULL)
      fprintf(stderr, "Error while mapping dmabuf fd (0x%X) to EGLImage\n", 0);

    CUresult status;
    CUeglFrame eglFrame;
    CUgraphicsResource pResource = NULL;

    if (cuGraphicsEGLRegisterImage(&pResource, egl_image, CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE) != CUDA_SUCCESS)
      fprintf(stderr, "cuGraphicsEGLRegisterImage failed: %d, cuda process stop\n", status);

    if (cuGraphicsResourceGetMappedEglFrame(&eglFrame, pResource, 0, 0) != CUDA_SUCCESS)
      fprintf(stderr, "cuGraphicsSubResourceGetMappedArray failed\n");

    if (cuCtxSynchronize() != CUDA_SUCCESS)
      fprintf(stderr, "cuCtxSynchronize failed");

    assert(eglFrame.frameType == CU_EGL_FRAME_TYPE_PITCH);


    if (cuCtxSynchronize() != CUDA_SUCCESS)
      fprintf(stderr, "cuCtxSynchronize failed after memcpy");

    if (cuGraphicsUnregisterResource(pResource) != CUDA_SUCCESS)
      fprintf(stderr, "cuGraphicsEGLUnRegisterResource failed");

    NvDestroyEGLImage(NULL, egl_image);

fails with: NvEGLImageFromFd: No EGLDisplay to create EGLImage

1 Like

This looks to be duplicate. Let’s continue in
NvBuffer -> CUDA -> DRM - #2 by DaneLLL