NvBufSurfTransform failed with error -3 while converting buffer

Hello,

I do save crop image with opencv; when trying NvBufSurfTransform get error while converting buffer, this error happen when I set engine gpu with the second one (gpu-id = 1), It worked with the first gpu (gpu-id = 0). Maybe I do set parameter wrong so please help me check it out.

{
NvBufSurfTransform_Error err;

NvBufSurfTransformParams transform_params;
NvBufSurfTransformRect src_rect;
NvBufSurfTransformRect dst_rect;

src_rect = {(guint)src_top, (guint)src_left, (guint)src_width, (guint)src_height};
dst_rect = {0, 0, (guint)dest_width, (guint)dest_height};

// Set the transform parameters
transform_params.src_rect = &src_rect;
transform_params.dst_rect = &dst_rect;
transform_params.transform_flag =
  NVBUFSURF_TRANSFORM_FILTER | NVBUFSURF_TRANSFORM_CROP_SRC |
    NVBUFSURF_TRANSFORM_CROP_DST;
transform_params.transform_filter = NvBufSurfTransformInter_Default;

//Memset the memory
NvBufSurfaceMemSet (nvinfer->inter_buf, 0, 0, 0);
GST_DEBUG_OBJECT (nvinfer, "Crop input buffer\n");
// Transformation scaling+format conversion if any.
err = NvBufSurfTransform (src_surf, nvinfer->inter_buf, &transform_params);
if (err != NvBufSurfTransformError_Success) {
GST_ELEMENT_ERROR (nvinfer, STREAM, FAILED,
    ("NvBufSurfTransform failed with error %d while converting buffer gpu src %d to gpu dest %d", err, src_surf->gpuId, nvinfer->inter_buf->gpuId),
    (NULL));
  goto error;
}
// Map the buffer so that it can be accessed by CPU
//int   NvBufSurfaceMap (NvBufSurface *surf, int index, int plane, NvBufSurfaceMemMapFlags type)
int e = NvBufSurfaceMap (nvinfer->inter_buf, 0, 0, NVBUF_MAP_READ);
if (e != 0){
  GST_ELEMENT_ERROR (nvinfer, STREAM, FAILED,
    ("Map the buffer %d so that it can be accessed by CPU", e),
    (NULL));
  goto error;
}

// Cache the mapped data for CPU access
//int   NvBufSurfaceSyncForCpu (NvBufSurface *surf, int index, int plane)
NvBufSurfaceSyncForCpu (nvinfer->inter_buf, 0, 0);

cv::Mat in_mat = cv::Mat (nvinfer->network_height, nvinfer->network_width,
  CV_8UC4, nvinfer->inter_buf->surfaceList[0].mappedAddr.addr[0],
  nvinfer->inter_buf->surfaceList[0].pitch);

char * name = g_strdup_printf("./debug/gie-%d-%d-%d-%d-%d.jpg", nvinfer->unique_id, (guint)src_top, (guint)src_left, (guint)src_width, (guint)src_height);

cv::cvtColor (in_mat, in_mat, CV_RGBA2BGR);

cv::imwrite(name, in_mat);

g_free(name);

//int   NvBufSurfaceUnMap (NvBufSurface *surf, int index, int plane)
if (NvBufSurfaceUnMap (nvinfer->inter_buf, 0, 0)){
  goto error;
}

}

Note that: source NvBufSurface and dest NvBufSurface have same gpuId is 1

Hi,
If you use Jetson platforms, it should always be gpu-id=0. Please share information about your platform.

hi DaneLLL,

I’m using 2 card. GeForce GTX 1080 Ti

Hi,
If you have other NVIDIA plugins in the pipeline, please set gpu-id=1 to the plugins. Or set cudadec-memtype =2(memtype_unified) in nvv4l2decoder, nvbuf-memory-type=3(nvbuf-mem-cuda-unified) in nvstreammux.

I did but got error:

[source0]
#using RTSP
gpu-id=1
cuda-memory-type=2
..

[streammux]
gpu-id=1
nvbuf-memory-type=3
..

[osd]
gpu-id=1
nvbuf-memory-type=3
..

[primary-gie]
gpu-id=1
nvbuf-memory-type=3
..

[secondary-gie0]
gpu-id=1
nvbuf-memory-type=3
..

Cuda failure: status=700
Cuda failure: status=700
nvbufsurface: NvBufSurfaceMemSet: failed to set memory
Cuda failure: status=700
0:00:12.433070932 27802 0x55ac0e4a3050 ERROR nvinfer gstnvinfer.cpp:526:gst_nvinfer_logger:<primary_gie_classifier> NvDsInferContext[UID 1]:queueInputBatch(): Failed to make stream wait on event(cudaErrorIllegalAddress)
0:00:12.433096592 27802 0x55ac0e4a3050 WARN nvinfer gstnvinfer.cpp:1232:gst_nvinfer_input_queue_loop:<primary_gie_classifier> error: Failed to queue input batch for inferencing
Cuda failure: status=700
KLT Tracker Init
Cuda failure: status=700
0:00:12.433882873 27802 0x55ac0e4a3050 ERROR nvinfer gstnvinfer.cpp:526:gst_nvinfer_logger:<primary_gie_classifier> NvDsInferContext[UID 1]:queueInputBatch(): Failed to make stream wait on event(cudaErrorIllegalAddress)
0:00:12.433898494 27802 0x55ac0e4a3050 WARN nvinfer gstnvinfer.cpp:1232:gst_nvinfer_input_queue_loop:<primary_gie_classifier> error: Failed to queue input batch for inferencing
Cuda failure: status=700
DS ERROR [1] from primary_gie_classifier: Failed to queue input batch for inferencing
DS Debug info: gstnvinfer.cpp(1232): gst_nvinfer_input_queue_loop (): /GstPipeline:pipeline/GstBin:primary_gie_bin/GstNvInfer:primary_gie_classifier
Cuda failure: status=700
Error(-1) in buffer allocation

Hi,
Please share a complete config file so that we can try to reproduce the failure. Thanks.

hello @DaneLLL
i got the same problem after using gstreamer deepstream + triton inferencer server.

nvbufsurftransform:cuInit failed : 3

what is this? and could i using gstreamer deepstream + triton inferencer server?

my gstreamer deepstream
https://gist.github.com/ThiagoMateo/bb304ce8960742f2e14d6bbba34b55c9

my triton init code
https://gist.github.com/ThiagoMateo/344149483c9fd05cef453843d13505fe

what i mean is that
If I run separately, deepstream gstreamer and trtiton inference server work sucessfully.
But if i combine deepstream gstreamer with trtiton inference server (deepstream gstreamer to get frame,trtiton inference server to predict object in image), these is an error

nvbufsurftransform:cuInit failed : 3

i am solved

@Robert_Hoang Can you please explain how did you solve your problem?