Cannot run nvjpeg encoder on child process

When run nvjpeg encoder on child process message shows ‘Tegra Acceleration failed’ and fails.

To reproduce modify tegra_multimedia_api/samples/05_jpeg_encode/jpeg_encode_main.cpp

Rename main function to _main
and add

main(int argc, char *argv[])
{
#if 0
    return _main(argc, argv);
#else
    int status;
    pid_t pid;

    if ((pid = fork()) < 0)
    {
        cout << "Failed fork" << endl;
        exit(-1);
    }
    else if (pid == 0)
    {
        // run child
        int res = _main(argc, argv);
        cout << "Done child" << endl;
        exit(res);                            // exit process
    }

    if (wait(&status) == -1)
    {
        cout << "wait error in main" << endl;
    }
    else if (WIFEXITED(status))
    {
        int res = WEXITSTATUS(status);  // child result
        cout << "Child result " << res << endl;
    }
    else
    {
        cout << "Child not exited normally" << endl;
    }
    return 0;
#endif
}

Run this program shows

nvidia@tegra-ubuntu:~/tegra_multimedia_api/samples/_05_jpeg_encode$ ./jpeg_encode a.raw 1920 1080 x.jpg
Failed to query video capabilities: Inappropriate ioctl for device
libv4l2_nvvidconv (0):(792) (INFO) : Allocating (1) OUTPUT PLANE BUFFERS Layout=0
libv4l2_nvvidconv (0):(808) (INFO) : Allocating (1) CAPTURE PLANE BUFFERS Layout=1
Tegra Acceleration failed
Child result 1

When run on parent process

nvidia@tegra-ubuntu:~/tegra_multimedia_api/samples/_05_jpeg_encode$ ./jpeg_encode a.raw 1920 1080 x.jpg
Failed to query video capabilities: Inappropriate ioctl for device
libv4l2_nvvidconv (0):(792) (INFO) : Allocating (1) OUTPUT PLANE BUFFERS Layout=0
libv4l2_nvvidconv (0):(808) (INFO) : Allocating (1) CAPTURE PLANE BUFFERS Layout=1
nvbuf_utils: dmabuf_fd 2097153031 mapped entry NOT found
App run was successful

Hi Nobutaka,
[s]Can it be reproduced with

tegra_multimedia_api/data/Picture/nvidia-logo.jpg

[/s]

My bad. This is jpeg encoding, not decoding. So are you on r28.2.1?

Not sure for Tegra Version but I am using JetPack3.3 on Jetson TX2.

We can observe the issue. Will check and update.

Hi Nobutaka,
This is not a case supported by default. It is more like a feature request and we will need some time to check and evaluate.

For our reference, could you share the reason of runnning jpeg encoding in child process?

Thank you for investigating.
I was using parent process to watch illegal end of child process or shutdown to restart or want to shutdown.
This is the reason.

DaneLLL, can we get some clarification about what case is not supported? As you know all processes in linux are typically children of some other process, so I guess that’s not the issue by itself… What exactly is the scenario that’s not supported?

As it happens, I have a process that launches a child which does JPEG encoding. It seems to work 99% of the time, but sometimes, for no reason that I can determine, I get the “Tegra Acceleration failed” crash. Any pointers in the right direction would be appreciated…

Hi logidelic,
Our developer team is still checking this request.

Running NVJpegEncoder on child process works ok on BSP 28.1.0 but is definitely broken on BSP 28.2.1.
Issue is 100 % repeatable on 28.2.1, but never fails on 28.1.0.

On this light, I bit curious of your statement that “This case is not supported by default” as it was supported on 28.1.0 and on 28.2.1 it has regressed.

Hi,
Our test cases run default 05_jpeg_encode. For your usecase of running jpeg encoding in child process, you have to modify the sample code, so it is neither verified on r28.1, nor on r28.2.1.

If you would like to prioritize this issue, please contact NVIDIA salesperson to have further cooperation with us. Thanks.

[quote=“DaneLLL”]

This effectively blocks BSP upgrades and this is way I am interested in this.

I’ll need to discuss this issue with my colleagues and see what other options there might be as this seems to be unsupported feature.

Please try attachment.
libnvrm_graphics_r28_2_1.zip (28 KB)

Thanks DaneLLL. I don’t suppose you can give a little hint as to the changes in this lib update? Is it safe for production? Just bug fixes? Thanks!

Hi,

It only fixes this issue. Shall be safe for production.