6

I'm having a problem with ffmpeg video encoding using GPU (CUDA).

I have 2x nVidia GTX 1050 Ti

The problem comes when i try to do multiple parallel encodings. More than 2 processes and ffmpeg dies like this:

[h264_nvenc @ 0xcc1cc0] OpenEncodeSessionEx failed: out of memory (10)

The problem is nvidia-smi shows there are a lot of resources available on the gpu:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.66                 Driver Version: 384.66                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 105...  Off  | 00000000:41:00.0 Off |                  N/A |
| 40%   37C    P0    42W /  75W |    177MiB /  4038MiB |     30%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 105...  Off  | 00000000:42:00.0 Off |                  N/A |
| 40%   21C    P8    35W /  75W |     10MiB /  4038MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

the second GPU doesn't seem to be used at all, and there's more than enough memory left on the first one, to support the 3rd file.

Any ideas would be extremely helpful!

talonmies
  • 70,661
  • 34
  • 192
  • 269
VelDev
  • 160
  • 2
  • 7
  • from the ffmpeg info page [here](https://stackoverflow.com/tags/ffmpeg/info) "**Questions about interactive use of the ffmpeg command line tool are off-topic.**" – Robert Crovella Sep 24 '17 at 20:10
  • 1
    Hi VelDev! Could you change the answer you accepted? The second answer actually gives you a way to fix the issue (i.e. applying `nvidia-patch`). – GG. Jan 31 '20 at 06:36

2 Answers2

14

Actually your card is 'non-qualified' (in terms of NVIDIA) and supports only 2 simultaneous sessions. You could consult with https://developer.nvidia.com/video-encode-decode-gpu-support-matrix#Encoder or download NVENC SDK, which contains pdf with license terms for qualified and non-qualified GPUs. There are some patches for drivers which disables session count checking, you could try them https://github.com/keylase/nvidia-patch

GG.
  • 21,083
  • 14
  • 84
  • 130
p0rsche
  • 503
  • 7
  • 20
  • Why is their GTX 1050 Ti considered non-qualified and thus supporting max 2 sessions when it's clearly listed on the official matrix as allowing 3 max sessions? Where does one see what is qualified and what isn't? – Vic Feb 01 '21 at 00:24
  • To answer my own question, all consumer (GeForce) cards are considered non-qualified and all Professional (Quadro) and Server (Tesla) are qualified. – Vic Feb 01 '21 at 00:30
2
  1. Since there's no codes about how you apply the encoding context, I can't tell why the second gpu is not used. Have you specified using it in av_opt_set() or command line argument?
  2. The more important problem here is geforce cards cannot own more than 2 encoding sessions in one system. If you need more, you have to use those expensive ones like quadro, tesla etc.
halfelf
  • 9,737
  • 13
  • 54
  • 63
  • Thank you, didn't know that the cards support only 2 econding sessions, that's highly dissapointing. I have tried using -gpu 1. – VelDev Sep 25 '17 at 14:08
  • My command: ffmpeg -analyzeduration 100M -probesize 100M -gpu 2 -hwaccel cuvid -c:v h264_cuvid -i in.mp4 -vf scale_npp=858:480 -maxrate 800K -bufsize 4000K -threads 0 -profile:v main -level 4.0 -movflags +faststart -preset fast -c:v h264_nvenc -ac 2 out.mp4 – VelDev Sep 25 '17 at 14:09
  • 1
    @VelDev You haven't specify encoding gpu in such command. `-gpu` before `-i` only apply `cuvid` decoding part. There should be another `-gpu` with `nvenc`. – halfelf Sep 26 '17 at 03:07