Skip to main content

whisper-gpu-kit: run Whisper on the GPU, finish on the CPU when VRAM runs out, download the model only when it is missing. Beside it, the log of one transcribe_with_fallback call: the model loads on cuda, transcription fails with CUDA out of memory, the model reloads on cpu and returns the text, the language 'en' and the device 'cpu'.

CI PyPI Python versions License: MIT

GPU plumbing around faster-whisper for batch transcription.

It preloads the pip CUDA libraries, caches the model per device and tells a CUDA failure from a missing model. When the GPU runs out of memory, it redoes the file on CPU. It also parses the .vtt/.srt captions a downloader already saved, so those files skip the GPU.

I pulled it out of two of my projects that carried the same code byte for byte. It installs as whisper-gpu-kit and imports as whisper_gpu.

What a fallback looks like

One transcribe_with_fallback() call where CUDA runs out of memory. The model layer is stubbed as in the tests, with an error string from a real OOM. The log lines are the library's own:

INFO    Loading faster-whisper large-v3 on cuda…
INFO    Whisper model ready (cuda).
WARNING GPU transcription failed (CUDA failed with error out of memory). Likely VRAM is occupied
        (check `nvidia-smi` for another process). Falling back to CPU — slower; free VRAM and re-run for GPU speed.
INFO    Loading faster-whisper large-v3 on cpu…
INFO    Whisper model ready (cpu).
('Hello and welcome back.', 'en', 'cpu')

The third value is the device that did the work. An error that is not a GPU error, such as undecodable audio, is raised unchanged. The caller can then skip that file.

Install

uv add "whisper-gpu-kit[gpu]"        # or: pip install "whisper-gpu-kit[gpu]"

The gpu extra pulls the pip CUDA runtimes (nvidia-cudnn-cu12==9.*, nvidia-cublas-cu12). Leave it out if CUDA is installed system-wide or you only need the caption parser. Needs Python 3.12 or newer.

faster_whisper is imported inside the functions, so import whisper_gpu works without GPU packages. whisper_gpu.subtitles needs only webvtt-py.

How it works

Four steps: 1, find_subtitle looks for a sibling .vtt or .srt and, if found, parses it and skips the GPU. 2, warn_if_low_vram reads free VRAM from nvidia-smi and warns under 3500 MiB. 3, whisper_transcribe runs large-v3 in float16 with the model cached per device. 4, on a CUDA error only, free_gpu_model drops the GPU model and the file is redone in int8 on CPU; bad audio still raises.

Each piece fixes a failure seen in practice:

  • preload_cuda_libs(): without it the GPU model load hangs with no error.
  • Local cache first: the Hugging Face Hub check can stall for minutes on a slow network.
  • is_cache_miss() rules out CUDA errors, so a missing cuDNN does not start a 3 GB re-download.
  • After a CUDA out-of-memory error the file is redone on CPU, so good audio is not marked undecodable.

Details and the error table: docs/api.md. Step by step: docs/logic-map.md.

Usage

Captions first (free, no GPU), Whisper second:

from pathlib import Path
from whisper_gpu import (find_subtitle, parse_subtitle, lang_from_subtitle_name,
                         transcribe_with_fallback, warn_if_low_vram)

audio = Path("data/audio/someone/7123456789.m4a")

sub = find_subtitle(audio)                  # sibling <id>.<lang>.vtt/.srt
if sub is not None:
    text, lang, source = parse_subtitle(sub), lang_from_subtitle_name(sub), "native_sub"
else:
    warn_if_low_vram()                      # logs if another process holds the GPU
    text, lang, device = transcribe_with_fallback(audio)   # cuda → cpu on GPU failure

parse_subtitle() drops cue numbers and timestamps and collapses repeated rolling-caption lines.

Lower-level pieces, all functions and constants: docs/api.md.

Tests

uv sync --extra dev && uv run pytest -q

They need no GPU and no model download. The model layer is monkeypatched.

License

MIT

Metadata

Release files for whisper-gpu-kit 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whisper-gpu-kit 0.1.4
File Size Uploaded Provenance Actions
whisper_gpu_kit-0.1.4.tar.gz 12.4 kB With provenance Details for whisper_gpu_kit-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for whisper-gpu-kit 0.1.4
File Interpreter ABI Platform Actions
whisper_gpu_kit-0.1.4-py3-none-any.whl Python 3 none any Details for whisper_gpu_kit-0.1.4-py3-none-any.whl

Total release size: 22.4 kB

Release files / whisper_gpu_kit-0.1.4.tar.gz

Download URL whisper_gpu_kit-0.1.4.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1a6ee0926681d9993267581a8af59992db7df84be4f28ab8234a043e927364fb
BLAKE2b-256 checksum
How to use checksums
8193dec6c4d31806069ad3fa43b5c42e554b705e56c844448c13102645c6f464
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / whisper_gpu_kit-0.1.4-py3-none-any.whl

Download URL whisper_gpu_kit-0.1.4-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0cbb55e6cfee85e6c5c2ec782e20552010dcf971650334a2db1bb290c19cfd89
BLAKE2b-256 checksum
How to use checksums
d232c816021a0425d0c9030798c93d9e99499ffc70c5aa67c9240662f7c8936d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for whisper-gpu-kit 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for whisper_gpu_kit-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page