Skip to content

fix: skip ggml_backend_load_all when use_gpu=0 in whisper filter#207

Closed
dymoo wants to merge 1 commit intoseydx:mainfrom
dymoo:fix/whisper-skip-gpu-backends-when-disabled
Closed

fix: skip ggml_backend_load_all when use_gpu=0 in whisper filter#207
dymoo wants to merge 1 commit intoseydx:mainfrom
dymoo:fix/whisper-skip-gpu-backends-when-disabled

Conversation

@dymoo
Copy link
Copy Markdown

@dymoo dymoo commented Apr 8, 2026

Problem

The FFmpeg whisper filter (af_whisper.c in the jellyfin-ffmpeg submodule) unconditionally calls ggml_backend_load_all() during initialization, which triggers Vulkan and OpenCL backend registration. On CPU-only systems (e.g. Docker containers without GPU hardware or ICD drivers), this causes a segfault when:

  1. ggml_backend_vk_reg()ggml_vk_instance_init()vk::createInstance() / vk::enumeratePhysicalDevices() crashes
  2. The Vulkan C++ bindings may throw or the ICD loader may segfault before throwing

This means WhisperTranscriber.create({ useGpu: false }) still crashes on CPU-only containers, because ggml_backend_load_all() runs before the use_gpu parameter is consulted by whisper.cpp.

Fix

Update the jellyfin-ffmpeg submodule to include seydx/jellyfin-ffmpeg#1, which conditions ggml_backend_load_all() on use_gpu:

  • use_gpu=0: Skip ggml_backend_load_all(). Only the CPU backend is needed (always available via GGML_USE_CPU). No GPU device enumeration occurs.
  • use_gpu=1: Load all backends as before (preserving existing behavior).

Why this works

ggml_backend_registry (in ggml-backend-reg.cpp) uses C++11 function-local static initialization, making it lazy — it's only constructed on first call to get_reg(). Since ggml_backend_load_all() is the caller, skipping it means:

  1. The lazy static constructor never runs
  2. ggml_backend_vk_reg() never gets called
  3. No Vulkan instance creation or device enumeration occurs

The CPU backend is independently available via static linking and doesn't need ggml_backend_load_all().

Impact

Testing

  • Verified on a CPU-only Docker container (Debian, no GPU/ICD): WhisperTranscriber.create({ useGpu: false }) no longer crashes
  • Transcription works correctly using the CPU backend
  • No Vulkan or OpenCL initialization occurs when use_gpu=0

Update jellyfin-ffmpeg submodule to include the fix in af_whisper.c
that skips ggml_backend_load_all() when use_gpu=0, preventing segfaults
on CPU-only containers where Vulkan/OpenCL initialization crashes.
@seydx
Copy link
Copy Markdown
Owner

seydx commented Apr 14, 2026

Already merged upstream in seydx/jellyfin-ffmpeg and submodule updated. Closing.

@seydx seydx closed this Apr 14, 2026
@seydx
Copy link
Copy Markdown
Owner

seydx commented Apr 14, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants