Hardware encoding throwing errors after update to R36.3.0

Hi!

We started having issues with the hardware encoder after updating to the Jetpack 6.0 GA (R36.3.0).
We have noticed that whenever we encode raw YUV (V4L2_PIX_FMT_YUV420M) to h264, we see a lot of error messages on the journal:

Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory for NvVIC 11
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory, handle already pinned as read-only
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory for NvVIC 13
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory, no such handle being tracked
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory for NvVIC 11
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory, handle already pinned as read-only
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory for NvVIC 13
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory, no such handle being tracked
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory for NvVIC 11
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory, handle already pinned as read-only
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory for NvVIC 13
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory, no such handle being tracked
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory for NvVIC 11
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory, handle already pinned as read-only
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory for NvVIC 13
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory, no such handle being tracked
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory for NvVIC 11
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory, handle already pinned as read-only
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to pin memory for NvVIC 13
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory, no such handle being tracked
Jul 04 11:02:01 orin-devkit video_cuda_enc[10413]: Module_id 56 Severity 2 : failed to unpin memory for NvVIC 11

The final encoded file seems to be correct, but the journal gets completely flooded with the above errors.
The same problem doesn’t happen if we try to encode V4L2_PIX_FMT_NV12M (instead of YUV420M) to h264.
We also haven’t had this issue before updating to the 6.0 GA.
The error can be reproduced through the following steps:

1. Install the multimedia API

    $ sudo apt install nvidia-l4t-jetson-multimedia-api

2. Build the video_cuda_enc sample

    $ cd /usr/src/jetson_multimedia_api/samples/03_video_cuda_enc
    $ sudo make

3. Try to encode yuv420 to h264

    $ ./video_cuda_enc /tmp/test.yuv 1920 1080 H264 /tmp/test.h264 

4. Check logs on journal

Please advise on any fix that we could try or identifying what is causing the issue. Thanks!

Hi,
Please also try the samples:

/usr/src/jetson_multimedia_api/samples/01_video_encode
/usr/src/jetson_multimedia_api/samples/unittest_samples/encoder_unit_sample/

Would like to confirm if the prints occur only when running 03 sample. Please help give it a try.

Hi @DaneLLL

I have just tried both the 01_video_encode and the encoder_unit_sample, and both led to the same errors being printed on the journal.

The encoder_unit_sample also printed some extra errors on the terminal:

nvidia@localhost:/usr/src/jetson_multimedia_api/samples/unittest_samples/encoder_unit_sample$ ./encode_sample /tmp/test.yuv 1920 1080 /tmp/test.h264 
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 4 
===== NvVideo: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
H264: Profile = 66 Level = 0 
NVMEDIA: Need to set EMC bandwidth : 846000 
NvVideo: bBlitMode is set to TRUE 
Could not read complete frame from input file
File read complete.
Got 0 size buffer in capture
Cannot Unmap Buffer 1116351031. Only mapped MMAP buffer can be unmapped
Cannot Unmap Buffer 2170862448. Only mapped MMAP buffer can be unmapped
free(): double free detected in tcache 2
Aborted (core dumped)

HI @DaneLLL

Any update on this?

Hi,
We will set up developer kit and check it. As a quick solution, please set format to V4L2_PIX_FMT_NV12M.