Skip to content

GPU Acceleration

Phillippe Pelzer edited this page Nov 24, 2026 · 4 revisions

GPU Acceleration

The ggml filters whisper, stemsplit and lyricsalign can run on a GPU through Vulkan. The Vulkan backend is compiled into the executable on Linux, Windows and FreeBSD. macOS uses Metal instead. See Metal.

If there is no usable GPU, the filters run on the CPU. The command line does not change.

What the machine needs

Need Detail
A Vulkan loader From the host's graphics installation. It is not shipped with FFmpeg.
A Vulkan driver From the GPU vendor or the OS.
A Vulkan SDK Not needed.

The loader is opened on demand, not at program start. GPU use needs the host's loader and driver. CPU use does not. No graphics library is in the archive.

Linux x86_64 uses the system glibc, 2.35 or newer. See Platforms.

Which filter uses the GPU by default

Filter Default Notes
whisper use_gpu=1 GPU on. The transcript is the same as on the CPU.
stemsplit use_gpu=auto Since stemsplit 2.0.0 (v1.0.47). Spleeter stays on the CPU. RoFormer uses a GPU only when it computes like the CPU.
lyricsalign use_gpu=0 Off by default. use_gpu=1 allows the ggml GPU backend. See Filter-lyricsalign.

keydetect, beatdetect and trailingsilence have no GPU option.

Option details are on Filter-stemsplit and Whisper-Word-Timestamps.

Platforms

Platform Vulkan in the binary Status
linux-x86_64 Yes Starts and runs CPU inference on Ubuntu 22.04 and Debian 12. NVENC (H.264, HEVC), CUDA decode and whisper on Vulkan pass with an RTX 3070 under Windows Subsystem for Linux 2. A Vulkan video path through Dozen fails cleanly. Native Linux GPU execution is not verified on hardware.
linux-aarch64 Yes Built. Not verified on hardware: no ARM GPU has been exercised.
windows-x86_64 Yes GPU selection verified on an RTX 3070.
windows-aarch64 Yes Built and checked statically. Not verified on hardware: not yet run on a Windows on ARM GPU.
freebsd-x86_64 Yes Startup, codecs, loader and driver guard verified under FreeBSD 14.3 in QEMU. Physical GPU execution is not verified on hardware.
darwin-arm64 No Uses Metal. See Metal.
darwin-x86_64 No Uses Metal when the default GPU is a discrete one that reports Metal 3, since v1.0.50. Otherwise the CPU. Not verified on hardware. See Metal.

See what ran

The filter logs the backend once at -v info:

whisper: ggml backend 'vulkan' (NVIDIA GeForce RTX 3070).

It also writes frame metadata, so a program does not need to read logs.

Key Meaning
lavfi.whisper.backend The backend whisper used.
lavfi.stemsplit.backend The backend that computed the stem: vulkan, cpu, or one value per model such as vulkan|cpu.
lavfi.stemsplit.device The GPU name, when a GPU ran.
lavfi.whisper.cpu_variant, lavfi.stemsplit.cpu_variant The CPU instruction-set level. See CPU-Instruction-Sets.

Trust the metadata, not the first log line. The log line names the device that opened. The metadata names what computed. A device can open and then refuse the graph.

Pick a GPU

gpu_device=<n> selects a GPU on a machine with more than one. An index that is out of range does not use the wrong card. It says so and runs on the CPU:

stemsplit: gpu_device=99 but this machine has 1 GPU device(s); running on the CPU.

stemsplit on a GPU

Spleeter

Spleeter never moves to a GPU under use_gpu=auto. The output would change. ggml's Vulkan backend accumulates convolutions in 16-bit float on a GPU with cooperative-matrix support. Against the CPU that measured -58.8 dB. It is not audible. It is not bit-identical.

Opt in with use_gpu=1:

ffmpeg -i in.mp3 -af "stemsplit=model=spleeter-2stems-f16.gguf:stem=vocals:use_gpu=1" out.wav

Measured by the project on one RTX 3070: 30 s of audio, twenty runs each, whole-process time including model load. 830 ms with use_gpu=1, 2198 ms on the CPU. That is 2.6 times faster.

RoFormer

Under auto, RoFormer goes to the best-ranked device of a backend that the build enables for auto. ffmpeg -h filter=stemsplit ends with the list. The v1.0.47 Linux x86_64 binary says Backends enabled for use_gpu=auto: vulkan. On macOS both darwin binaries print Backends enabled for use_gpu=auto: none., so auto is the CPU.

A GPU is taken only when all of this is true:

  • It is a real GPU, not a software rasteriser.
  • It wins one calibration against the CPU.
  • It passes a self-check against the CPU's mask on every model (85 dB SNR on 32 frames).
  • It can hold the work.

Otherwise that model runs on the CPU, with a warning. A machine without a usable GPU gives the same bytes as use_gpu=0.

Option Effect
cpu_fallback=0 Refuse a RoFormer run that would compute on the CPU. It stops before it computes anything. The error starts with stemsplit: cpu_fallback=0 and. The exit code is non-zero.
cpu_assist On by default. With a GPU, one worker thread computes chunks on the CPU beside it when that helps. Two runs can then differ within the GPU tolerance. cpu_assist=0 gives the same stems every time.
gpu_device=<n> Pins device n.
# RoFormer on a GPU when one takes it, the CPU otherwise (the default)
ffmpeg -i song.flac -filter_complex "[0:a]stemsplit=preset=full[voc][acc]" -map "[voc]" vocals.flac -map "[acc]" instrumental.flac

# RoFormer only on a GPU: no GPU gives an error, not an hour on the CPU
ffmpeg -i song.flac -filter_complex "[0:a]stemsplit=preset=full:cpu_fallback=0[voc][acc]" -map "[voc]" vocals.flac -map "[acc]" instrumental.flac

Measurements from the stemsplit project, not repeated here:

  • With the F32 path (below), the four models of preset=full on an RTX 3070 are 108.8 to 124.9 dB from the CPU.
  • That card did 65 s of work for 60 s of music, against about 54 minutes per minute of music on its CPU.
  • On a GTX 1060 3GB all four models were within 45 dB of the CPU.

The F32 path

Since stemsplit 2.0.0 the filter sets two variables for its own process when use_gpu is auto or 1, before it opens a device.

Variable Value Effect
GGML_VK_DISABLE_COOPMAT 1 No cooperative-matrix path.
GGML_VK_DISABLE_F16 1 No 16-bit float path. ggml-vulkan computes in 32-bit float.

A variable that is already in the environment is left alone. use_gpu=0 sets nothing.

Warning. The two variables are process-wide. A whisper filter in the same ffmpeg process then computes in F32 too. That was measured to slow whisper on a GPU about 3.5 times. Run whisper on a GPU in another ffmpeg process than a stemsplit run that uses a GPU.

STEMSPLIT_VK_FAST=1 keeps the card's half-precision path. auto then refuses such a card.

whisper on a GPU

whisper is on the GPU by default because the output does not change. GPU and CPU transcripts were compared on an RTX 3070 across three inputs: clean speech, 90 s of speech, and 60 s of music. All three were byte-identical.

The driver guard

A broken Vulkan driver can crash a program that only asks for a list of devices. On Linux and FreeBSD the binary first tests the drivers in a throwaway child process. It switches Vulkan off for itself if they crash, hang, or show only software rendering. Windows and macOS have no guard.

The log distinguishes three outcomes.

Outcome What it means
… drivers crash a statically linked binary; vulkan disabled for this process The driver crashed the probe. The text says "statically linked" because the guard was written for static builds. It means the same on the dynamic Linux x86_64 and FreeBSD builds.
… could not verify … as a precaution. This is not a report that anything is broken … The check ran out of time. Your machine is not necessarily broken.
… the only vulkan device here is a software rasteriser; running on the CPU … Software rasterisers (llvmpipe, lavapipe) are refused on purpose. They are slower than the CPU backend.

Environment variables

Variable Platforms Effect
NOMERCY_GGML_GPU=0 All Turns the GPU off for every ggml filter, whatever they are asked for.
NOMERCY_VK_ICD_GUARD=0 Linux, FreeBSD Skips the driver check and uses Vulkan as it is.
NOMERCY_VK_GUARD_MS=<ms> Linux, FreeBSD Time budget of the whole check. The default is 30000. Raise it if you see "could not verify" on a machine you know is fine.
NOMERCY_VK_PROBE_MS=<ms> Linux, FreeBSD Cap for one probe child. The default is 10000.
STEMSPLIT_VK_FAST=1 All with Vulkan Keeps the half-precision path. See above.
GGML_VK_* All with Vulkan ggml's own Vulkan switches, for example GGML_VK_VISIBLE_DEVICES. The binary contains them. This project does not document or test them.

NOMERCY_GGML_GPU=0 is read by the backend selector, not by the driver check. It works on every platform. The three NOMERCY_VK_* variables belong to the driver check, so they do nothing on Windows and macOS.

Linux and FreeBSD runtime

Loading a shared GPU driver into a static glibc executable can create two C runtimes in one process. A minimal executable and plugin test showed colliding pthread keys and wrong thread-destructor ownership, with glibc 2.39 on both sides and no GPU API involved. Matching glibc versions does not make that safe.

So the Linux x86_64 build uses the installed glibc, the same one as the host's loader and driver. It needs glibc 2.35 or newer and keeps the codec, C++ and OpenMP libraries built in.

FreeBSD does the same with its base system. It links libc.so.7, libm.so.5 and libthr.so.3 dynamically, so /libexec/ld-elf.so.1 can load the host's Vulkan loader and driver. Codec libraries stay built in. FreeBSD 14.3 is the supported baseline.

Linux aarch64 stays fully static, with Vulkan compiled in and the driver guard. No native ARM GPU run has been verified.

Hardware video encode and decode

This page is about ggml. For NVENC, VAAPI, Quick Sync and the other FFmpeg hardware paths, see the table on Codecs-and-Libraries.

Related pages

Clone this wiki locally