CUDA ERROR OUT OF MEMORY - FFMPEG

Hi guys,

I am using ffmpeg to transcode some live channels, but I’m having a recurring problem.
All the time I get a CUDA out of memory error, even though the video card has nothing to process.
I build my ffmpeg following the NVIDIA FFmpeg Transcoding Guide(https://devblogs.nvidia.com/nvidia-ffmpeg-transcoding-guide/).

I’m using the ffmpeg-python library(https://kkroening.github.io/ffmpeg-python/), but the error happens both by calling the library and using the command line directly, for example:

ffmpeg -hwaccel cuvid -c:v h264_cuvid -i rtmp://… -c:a ac3 -vf scale_npp=1280:720 -c:v h264_nvenc -sc_threshold 0 -g 60 -keyint_min 30 -hls_time 6 -b:v 2800k -maxrate 2800k -bufsize 4200k -b:a 128k -r 30 -f hls pipes/…

I already used the following setups, but in all the error keeps happening.

First Setup:
OS: Ubuntu 18.04.3 LTS 64 bits
kernel: 5.0.0-37-generic
GPU: Quadro P4000
driver: 440.33.01

Second Setup:
OS: CentOS 8.1.1911
kernel: 4.18.0-147.3.1.el8_1.x86_64
GPU: Quadro P4000
driver: 440.33.01

Third Setup:
OS: CentOS 8.1.1911
kernel: 4.18.0-147.3.1.el8_1.x86_64
GPU: Quadro P4000
driver: 435.21 Short Lived

Fourth Setup:
OS: Ubuntu 14.04.6 LTS
kernel: 4.4.0-148-generic
GPU: Quadro P4000
driver: 435.21 Short Lived

According to what I researched this error can be caused by a possible
combination between OS, kernel, gpu and driver. (https://emby.media/community/index.php?/topic74738-42018-nvenc-sometimes-randomly-fails-with-cuda-error-out-of-memory-out-of-memory/)

Can someone help me?
Thanks.

Any update to this? I am facing the same issue with an GTX 1070 with around 6GB memory left when trying to create an cuContext in FFmpeg

Hey folks-

Can you put together a repro that someone WITHOUT LIVE CAPTURE can reproduce this issue? Say ffmpeg with a pre-captured minute or two of video?

Then I can attempt to pass along to the right people internally.

Thanks!

-d