How Haris runs speech-to-text on an NVIDIA MX450 when it can, on the CPU when it can't, and never makes you wait for a multi-gigabyte download.

Part 3 of 3 in "Building Haris".

Haris in voice mode: the conversation hidden, the star on stage

Haris is an open-source desktop AI assistant for Windows. You can talk to it in Arabic or English: a wake word ("Hey Haris", Vosk, inside the app), push-to-talk on Ctrl+Space, Whisper for speech-to-text, and Piper for the spoken replies. Whisper and Piper run in Docker on your machine, listening on loopback ports only.

Speech-to-text is the step you feel. Every voice turn waits for it before the model even starts. On my laptop CPU it was fine but not snappy, and the laptop has a small discrete GPU that was doing nothing: an NVIDIA MX450 with 2 GB of memory. This is the story of putting it to work without making anything worse for people who don't have one.

The numbers

Measured on my laptop — Intel i7-1165G7, Intel Iris Xe plus an NVIDIA MX450 (2 GB) — with Whisper small (the int8 build on the CPU, int8_float16 on the GPU, same decoding settings) and a short phrase:

CPU GPU (MX450)
English, short phrase 1.47 s 1.02 s
Arabic, short phrase 1.52 s 1.06 s
Video memory used — about 0.4 GB

That's about 30% off the speech-to-text step, the part every voice turn waits for, on a GPU most people would call too small for AI work. The model fits with lots of room to spare in 2 GB.

These are short phrases. A long sentence takes longer on both; I'm only quoting what I measured.

Starting point: a hardened CPU container

Before the GPU work, the voice engines already ran from voice/compose.yaml with one hardening block shared by every service:

x-hardening: &hardening read_only: true tmpfs: [/tmp] cap_drop: [ALL] security_opt: ["no-new-privileges:true"] restart: "no" # Haris starts and stops these itself  logging: driver: local options: { max-size: "5m", max-file: "2" } services: whisper: <<: *hardening image: rhasspy/wyoming-whisper:3.8.1 # beam-size 1 + VAD trimming roughly halve latency on a laptop CPU with little accuracy loss.  command: ["--model", "${WHISPER_MODEL:-small-int8}", "--data-dir", "/data", "--beam-size", "1", "--cpu-threads", "4", "--vad-filter", "--initial-prompt", "Haris"] environment: WYO_WHISPER_LOCAL_FILES_ONLY: "${WHISPER_OFFLINE:-false}" HF_HUB_OFFLINE: "${WHISPER_OFFLINE:-false}" ports: ["127.0.0.1:10300:10300"] volumes: ["whisper-data:/data"] mem_limit: 2g cpus: 4 # ... (Piper service, comments and the volumes block trimmed) 

Read-only root filesystem, every Linux capability dropped, no privilege escalation, a loopback-only port, memory and CPU caps, an image pinned to an exact version, and an offline switch: after the first start, WHISPER_OFFLINE=true forbids further model downloads. Whatever the GPU path did, it had to keep all of that.

Design goal: the rest of Haris must not know

The cleanest trick was to keep the same port. Haris talks to Whisper over the Wyoming protocol on 127.0.0.1:10300. If the GPU container answers on the same port, nothing outside the start-up code needs to care which device is behind it.

So the GPU version is not a second service. It's a Compose override layered on top of the CPU file:

docker compose -f voice/compose.yaml -f voice/compose.gpu.yaml up -d 

The GPU override

services: whisper: # Pinned by digest as well as tag: a linuxserver tag is rebuilt in place now and then.  image: lscr.io/linuxserver/faster-whisper:gpu-v3.8.1-ls71@sha256:45864167538e51dd843545291f71b7f2420bd12d8190d98948d6d9ddb939e50c entrypoint: ["/lsiopy/bin/python3", "-m", "wyoming_faster_whisper"] # Same decoding settings as on the CPU: beam 1, VAD trimming, "Haris" as the initial prompt.  command: ["--uri", "tcp://0.0.0.0:10300", "--model", "${WHISPER_GPU_MODEL:-small}", "--compute-type", "${WHISPER_GPU_COMPUTE:-int8_float16}", "--device", "cuda", "--data-dir", "/data", "--beam-size", "1", "--vad-filter", "--initial-prompt", "Haris"] environment: LD_LIBRARY_PATH: /lsiopy/lib/python3.12/site-packages/nvidia/cublas/lib:/lsiopy/lib/python3.12/site-packages/nvidia/cudnn/lib TMPDIR: /tmp HOME: /tmp volumes: !override ["whisper-gpu-data:/data"] deploy: resources: reservations: devices: - driver: nvidia count: 1 capabilities: [gpu] # CUDA runtime + cuDNN are loaded into host memory too; 3 GB leaves room for them and the model.  mem_limit: 3g # ... (labels and the whisper-gpu-data volume declaration trimmed) 

Four decisions are hiding in there.

1. Same server, CUDA build. The image is linuxserver's CUDA build of the same wyoming-faster-whisper 3.8.1 that the CPU file runs. Same protocol, same decoding settings (beam size 1, VAD filter, "Haris" as the initial prompt), so results should match and only speed changes.

2. Bypassing the init, to keep the hardening. That image normally starts through an s6-overlay init that wants to chown files and switch users — which needs Linux capabilities the hardened block drops. Rather than give them back, the override sets the entrypoint to the Python server directly, with the CUDA library path the image's own run script would have set. Result: still no capabilities, still a read-only root, no extra tmpfs. (It runs as root inside the container, like the CPU one, but with every capability dropped.)

3. A separate model volume. The GPU runs the float16-capable small model with int8_float16; the CPU runs small-int8. A half-written download in one must not break the other, so the GPU gets its own whisper-gpu-data volume. That's what !override is for: without it, Compose would merge the volume lists and mount both on /data.

4. Pinned by digest. A linuxserver tag is occasionally rebuilt in place, so the tag alone doesn't guarantee the same bits. The digest does.

The !override merge tag needs Docker Compose 2.24.4 or later. Haris checks the Compose version first and simply stays on the CPU with an older one — including not downloading the GPU image at all.

Deciding: GPU or CPU?

All the decisions live in one small class, WhisperRoute, with Docker and nvidia-smi behind interfaces so they can be tested without either. The first decision is whether to try the GPU at all:

/** The GPU when it is allowed, Docker has the NVIDIA runtime, and the host's NVIDIA driver answers. */ static Device choose(boolean gpuAllowed, Host host) { if (!gpuAllowed) { return Device.CPU; } String runtimes = host.dockerRuntimes(); if (runtimes == null || !runtimes.contains("\"nvidia\"")) { return Device.CPU; } return host.nvidiaSmi() ? Device.GPU : Device.CPU; } 

gpuAllowed is the user's switch: HARIS_WHISPER_GPU=false (as an environment variable, or a line in voice/.env) forces the CPU. Unset means "use the GPU if there is one". Upgrades keep your voice/.env, so the switch survives a new version.

Don't make the first launch wait for gigabytes

The GPU image is several gigabytes. Pulling it inside docker compose up would block all voice — Piper is in the same Compose project — on the first launch, and a slow connection could cancel the pull on every launch. So if the image isn't on the machine yet, Haris starts on the CPU right away and downloads it in the background:

static Device withImage(Device device, String gpuImage, Images images) { if (device != Device.GPU) { return device; } // ... if (images.present(gpuImage)) { return Device.GPU; } log.info("The GPU speech-to-text image is not downloaded yet: using the CPU now and downloading it in the background."); images.pullInBackground(gpuImage); return Device.CPU; } 

The pull runs on a virtual thread and logs progress as "3 of 12 layers downloaded". If Haris closes mid-download, Docker keeps the finished layers and the next start carries on. The GPU is used from the next start after the image is complete.

The fallback

Then the part that matters most: what if the GPU container starts but never answers — a driver problem, not enough memory, a broken CUDA library?

/** * After {@code up}: waits for Whisper on {@code device}, repairs a broken model download once, * and falls back from the GPU to the CPU if the GPU container does not answer. Returns the device * Whisper ends up on. */ static Device settle(Device device, Engines engines) { Outcome outcome = awaitHealing(device, engines); if (outcome == Outcome.READY || device == Device.CPU) { return device; } log.warn("Speech-to-text did not start on the GPU; using the CPU instead."); return fallBack(engines); } 

Because both containers belong to the same Compose project and service, starting the CPU version replaces the GPU one. Same port, so the rest of Haris just sees Whisper come back. Piper is up as soon as the initial start returns; the GPU health check runs on a side thread.

awaitHealing handles a sneaky case: if an earlier, interrupted download left a broken model in the volume, the container exits immediately. Haris recognises that outcome (MODEL_BROKEN), drops that device's model volume once, and starts again.

There's one more subtlety, in the initial compose up. If it fails on the GPU, Haris tries the CPU — but it only blames the GPU if the CPU start then works:

/** * The GPU is blamed only when the CPU start then works: {@code up} starts the whole voice project * (Piper too), so when both fail the fault is Docker, a port, or Piper, not the GPU, and a healthy * GPU must not be skipped for days because of it. */ static Start start(Device device, Engines engines, BooleanSupplier stopping) { ... } 

Remembering failures — but not forever

Trying a broken GPU on every launch would add delay every time. So a failure is written to ~/.haris/whisper-gpu-failed as the date plus the image name, and for three days Haris goes straight to the CPU:

/** After the GPU failed, Haris starts on the CPU for this many days (or until the GPU image changes). */ static final int RETRY_GPU_DAYS = 3; static boolean gpuRecentlyFailed(String marker, String gpuImage, LocalDate today) { // ... String[] parts = marker.strip().split(" ", 2); if (parts.length != 2 || !parts[1].equals(gpuImage)) { return false; } return today.isBefore(LocalDate.parse(parts[0]).plusDays(RETRY_GPU_DAYS)); } 

Including the image in the marker means a new GPU image (for example after an update) gets a fresh chance right away. Deleting the file retries sooner. When the GPU works, the marker is removed.

What the user sees

Almost nothing, which is the point. The Voice drawer shows ● Online (GPU) when the GPU is answering; otherwise the normal online state. The log explains the decisions that aren't obvious: Compose too old, image still downloading, GPU failed recently, falling back to the CPU. It always names the device speech-to-text ends up on. WHISPER_OFFLINE=true applies to the GPU container too.

Try it on your machine

If you don't have Haris yet, download Haris-0.6.0-windows.zip (about 183 MB) from the Releases page. It isn't code-signed yet, so check the SHA-256 in the release notes and unblock the zip (Properties → Unblock) first: how.

  1. Install Docker Desktop and check that nvidia-smi works in Windows and lists your card.
  2. Make sure Docker knows the NVIDIA runtime and that docker compose version says 2.24.4 or later.
  3. Start Haris. The first time it starts on the CPU and downloads the GPU image in the background; the log shows progress.
  4. When the download is done, close and reopen Haris, open the Voice drawer and look for ● Online (GPU).
  5. To compare, add HARIS_WHISPER_GPU=false to voice/.env (upgrades keep that file), restart, then remove it.

If the GPU isn't used, the log names the device speech-to-text is running on.

Lessons

  • Keep the interface identical. Same port, same protocol, same decoding flags. The GPU became an implementation detail of start-up, not a feature the rest of the app had to learn.
  • Never let the fast path block the slow path. A multi-gigabyte image is a background job, not a start-up step.
  • Blame carefully. Only record a GPU failure when the evidence says it was the GPU.
  • Hardening is a constraint, not a checkbox. It was easier to bypass an image's init than to give back the capabilities it wanted.
  • A small GPU is still a GPU. 2 GB was plenty for Whisper small, at about 0.4 GB.

The compose files are short and heavily commented; they're the best place to start if you want to do the same for your own project: voice/compose.yaml and voice/compose.gpu.yaml in https://github.com/TENMATECH-DIGITAL-SOLUTIONS/haris (MIT). If you try it on a different NVIDIA card, I'd love to see your numbers: post them through the repo's issue forms (https://github.com/TENMATECH-DIGITAL-SOLUTIONS/haris/issues/new/choose).