Possible memory leak using nvresize

Hello,
I have successfully compiled ffmpeg with support of nvresize.

ffmpeg version 3.0 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
  configuration: --enable-gpl --enable-runtime-cpudetect --enable-nonfree --enable-nvenc --enable-nvresize --extra-cflags=-I../cudautils --extra-ldflags=-L../cudautils --enable-gpl --enable-libx264 --enable-libvpx --enable-libx265

Here is the command that I’m using to encode live stream to rtmp:

/usr/local/bin/ffmpeg  -nostats -re -i "udp://INPUTIP:INPUTPORT?fifo_size=1000000&overrun_nonfatal=1" -map 0:v:0 -vcodec nvenc_h264 -preset medium -profile:v high -r 25 -g 50 -qmin 1 -qmax 50 \
         -vf "yadif=0:-1:0,nvresize=1:s=pal:readback=0" -b:v 1500k -minrate:v 1000k -maxrate:v 1800k -bufsize:v 2500k -map 0:a:0 -acodec aac -ac 2 -b:a 128k \
                        -async 0 -strict -2 -f flv -metadata service_provider="ENCODER" -metadata service_name="PROGRAM" "rtmp://127.0.0.1:1935/live/program"

Everything is working as supposed except that after a few hours the machine runs out of memory.
Not using nvresize has far less memory consumption and stability. Have checked with cuda-memleak but doesn’t find anything…Is there anyone having the same issue?
Thanks

Does the ffmpeg memory leak affect GPU memory or system memory? Since this is posted in the CUDA programming subforum, how is this issue related to CUDA? The flag --enable-nvenc specified for ffmpeg suggests that NVENC is being used, but that has nothing to do with CUDA best I know.

Hi,
It’s not nvenc that is eating the memory its actually nvresize which uses cuda libraries to scale the output.
Using

nvresize=1:s=pal:readback=0

enables the memory issues. Dropping caches doesn’t help much it only slows down the problem.
Using

scale=720:576

doesn’t affect memory much it’s still going up but much much slower.
Let’s say I have 64G of memory and using ffmpeg command for let’s say…30 encoding processes.
At first it uses 12G of memory…after 12 hours these 12G become 30G and so on… Using scale without nvresize from 12G for 12 hours it goes to 13G.
I myself cannot investigate much into that so I’m asking if anyone has experienced that kind of issues using nvresize.
Thank you.

I do not recognize nvresize as an NVIDIA-provided software that ships with CUDA, and searching my CUDA 7.5 installation, I cannot find a file of that (or similar) name. Which CUDA-based libraries does nvresize use? What evidence is there that the memory leak is due to these libraries, rather than the nvresize application itself?

I would think your best course of action is to contact the authors of nvresize.

Hello


Here is from where nvresize comes from.
It is a patch for ffmpeg provided by NVIDIA and written in their own manual. As I said it uses CUDA to resize the video output. Not using nvresize as an option causes higher CPU usage but much less memory usage.

I am reading and grepping the document you pointed to, and while I see instructions on how to use nvresize, I do not see nvresize described as an NVIDIA product, and I have not found anything yet that says nvresize uses CUDA (obviously, the fact that the document does not specifically mention it does not mean it does not use CUDA).

Lets assume that nvresize is software provided by NVIDIA, and that is does use CUDA in some way. Unless the root causes of bugs in nvresize are shown to be caused by bugs in either CUDA itself or libraries that ship with CUDA, I do not see how the participants of this CUDA programming forum can assist in resolving your application-specific issue.

The authors of the nvresize software, whoever they are, need to address bugs in their software. In case there is an open source repository with the sources for nvresize, you may find information there stating who programmed this software and whom to contact to report bugs. If there are forums dedicated to ffmpeg or nvresize, you may want to ask about your observations there.

[Later:] I downloaded the NVIDIA patch file for ffmpeg mentioned in the PDF documentation, and from that I can see that the nvresize feature uses CUDA. Specifically, it seems to be using PTX kernels that presumably are used to perform the resizing computation. There is quite a bit of high-level code, presumably responsible for interfacing this kernel to the ffmepg framework. It would seem to me that potential memory leaks are most likely to originate in this interface layer, and that the author(s) of the nvresize patch would need to debug and address such issues. Based on the copyright notices in several of the files, the author(s) of the relevant code would appear to be employees of NVIDIA.

Exactly!
Thank you for the time spent on this issue.
I am looking forward to receive any feedback from the people(employees) responsible for writing this patch and assist me and others that use this feature with further bugfixes regarding memory leaks and stability(for now it’s stable).

My guess is the authors of nvresize are not reading this forum, otherwise they would have already spoken up in this thread.

To avoid misunderstandings: These forums are intended as a community resource for CUDA programmers (“users helping users”), their are not designed as an official NVIDIA bug reporting channel. I do not have the faintest clue where nvresize bugs should be reported. CUDA bugs can be reported using the bug reporting form linked from the CUDA registered developer website.