Skip to content

Multi GPU, NVIDIA_VISIBLE_DEVICES and FFMPEG 7 NVDEC errors #1209

@baudneo

Description

@baudneo

So, this is a weird and pretty specific problem. I am at a loss at what I can do next because I am unsure if this is an issue with nvidia or ffmpeg (nvdec specifically). Issue has been observed in the frigate tensorrt images and ubuntu cuda images with ffmpeg 7.

This is in relation to ffmpeg crashing (due to not finding a CUDA device) when using multiple nvidia gpus while trying to use any other index than '0'. I have tried to only expose devices using NVIDIA_VISIBLE_DEVICES env var and assigning using index or GPU-UUID. The weird part is that I can load ONNX models onto GPU 1, which kind of leads towards this may be something specific to ffmpeg.

I am opening this issue to seek advice and to see if there are any other users having this issue.

Error from ffmpeg output:

  2025-07-29 16:57:53.773105842  [2025-07-29 16:57:53] ffmpeg.alley.detect            ERROR   : [AVHWDeviceContext @ 0x5dfde7cb58c0] cu->cuDeviceGet(&hwctx->internal->cuda_device, device_idx) failed -> CUDA_ERROR_INVALID_DEVICE: invalid device ordinal
  2025-07-29 16:57:53.773621224  [2025-07-29 16:57:53] ffmpeg.alley.detect            ERROR   : Device creation failed: -542398533.
  2025-07-29 16:57:53.774103329  [2025-07-29 16:57:53] ffmpeg.alley.detect            ERROR   : [vist#0:0/h264 @ 0x5dfde7c75f40] [dec:h264 @ 0x5dfde7d32440] No device available for decoder: device type cuda needed for codec h264.
  2025-07-29 16:57:53.774607022  [2025-07-29 16:57:53] ffmpeg.alley.detect            ERROR   : [vist#0:0/h264 @ 0x5dfde7c75f40] [dec:h264 @ 0x5dfde7d32440] Hardware device setup failed for decoder: Generic error in an external library
  2025-07-29 16:57:53.775085378  [2025-07-29 16:57:53] ffmpeg.alley.detect            ERROR   : [vost#0:0/rawvideo @ 0x5dfde7c80000] Error initializing a simple filtergraph
  2025-07-29 16:57:53.775575817  [2025-07-29 16:57:53] ffmpeg.alley.detect            ERROR   : Error opening output file pipe:.
  2025-07-29 16:57:53.776048525  [2025-07-29 16:57:53] ffmpeg.alley.detect            ERROR   : Error opening output files: Generic error in an external library

Edit: Other issues where this error occurs:

I have also opened a ticket on the ffmpeg bug tracker: https://trac.ffmpeg.org/ticket/11694

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions