Skip to content

Use a GPU for video

With video on, the desk encodes the station’s picture as AV1, one encoder per rung (Video in the desk). On the CPU that is SVT-AV1, which costs the server the cores the sound needs. An NVIDIA card with an AV1 encoder (NVIDIA’s Ada generation or later: the GeForce RTX 40 series, or the matching workstation cards) does it with NVENC instead, and RTMP out’s H.264 too (RTMP out).

From 1.2 the Compose bundle and the Quadlets hand the desk a card, by its CDI name (the Container Device Interface), when the station says so, or when weavesignal.sh finds one on a new install. The image carries no driver: the host’s driver comes in with the device.

An update never moves a station to the card (from 1.2.1). A station that was installed before keeps encoding on the CPU until someone sets GPU=nvidia; the script says the card is there, and so does the studio app (The hint in Settings).

A Cloudron app has no GPU. The package encodes on the CPU with SVT-AV1 (VIDEO_ENCODER=svt), and auto or nvenc there find no card and fall back with a line in the desk’s log (Install on Cloudron).

  • The station on the Compose bundle or the Quadlets, with video on (VIDEO=true).

  • NVIDIA’s driver on the server, and the NVIDIA Container Toolkit, which writes the CDI spec:

    Terminal window
    sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
    nvidia-ctk cdi list # nvidia.com/gpu=0, nvidia.com/gpu=all, ...

    Run it again after a driver update: the spec names the driver’s files.

  • A Podman that takes CDI device names (the routes were written against Podman 6.1), or Docker with CDI turned on: docker info lists CDI spec directories when it is.

  1. In the settings file weavesignal.sh writes (deploy/compose/.env, or the one you keep for the Quadlets), set:

    Terminal window
    VIDEO=true
    GPU=auto

    GPU=auto asks the script to look for an NVIDIA CDI spec in /etc/cdi and /var/run/cdi. It writes what it found, GPU=nvidia or GPU=none, and says so; the next run changes nothing until you set auto again. A new install with no GPU line looks the same way. A station installed before (its settings file already holds its secrets) and with no GPU line is not switched: the script writes GPU=none, says once that the card is there, and leaves the rest to you. Write GPU=nvidia (or GPU=auto) yourself to use it.

  2. Run the script again, from the folder it is in:

    Terminal window
    cd deploy/compose
    ./weavesignal.sh

    With GPU=nvidia and VIDEO=true it adds gpu.yaml, which hands the desk’s container the card and turns SELinux labelling off for that container only. GPU=nvidia with no spec stops the script, naming the command above.

  3. On the Quadlets, generate the units again (deploy/quadlets/generate.sh, Run with Quadlets): the desk’s unit gains AddDevice=nvidia.com/gpu=all.

The install wizard asks the same question under A graphics card for video when video is ticked (Install wizard).

From 1.2.1 the studio app’s Settings has a panel, Graphics card (settings.graphics-card), for an admin, whenever the script found an NVIDIA card on the server:

  • Not in use: This server has an NVIDIA graphics card, and the station is not using it, with the two steps above (set GPU=nvidia, and VIDEO=true if video is off; run weavesignal.sh again).
  • With the desk: the desk has been given the card and video is on.
  • With the desk · video off: the desk has been given the card, and nothing is encoded yet.

The panel says what the install knows: that a card is there, and whether the desk has been given it. It does not know the card’s model, so it does not promise NVENC: a card with an AV1 encoder (the RTX 40 series or later) takes the station’s video, and with an older card the desk stays on the CPU and says so in its log (Check it).

The panel changes nothing by itself: a card is handed to the desk when its container is made, which only the install script does, and the studio app cannot write the settings file. It reads what the script found on its last run (GPU_FOUND, below), so a card fitted since shows after the next run of the script. A server with no card, and a Cloudron station, show no such panel.

If 1.2.0 already moved your station to the card. 1.2.0 looked for a card on every station with no GPU line, an updated one included, and wrote GPU=nvidia where it found one. 1.2.1 does not undo that (it would be a second change nobody asked for): the panel says With the desk, and GPU=none with another run of the script puts video back on the CPU.

Setting Default Meaning
GPU a new install: auto (written as what was found); a station installed before, with no GPU line: none nvidia: hand the desk the card; none: the CPU only; auto: look for a CDI spec on the next run
GPU_FOUND written by the script on every run nvidia or none: whether the script found a card’s CDI spec on the server. Not a setting to change: the control plane is told it ([setup] gpu_found), and Settings offers the card from it
GPU_DEVICE nvidia.com/gpu=all which card, by its CDI name: nvidia.com/gpu=0 for the first of several
VIDEO_ENCODER auto (Cloudron: svt) auto: NVENC when the desk has a card, else SVT-AV1; nvenc; svt keeps the picture on the CPU with the card there
NVENC_SESSIONS 12 NVENC sessions the desk may open, 0 to 64: one per rung and one for RTMP out. A consumer card’s driver limits sessions for the whole machine, other programs included

Each is the desk’s [video] encoder and nvenc_sessions in desk.toml (Settings). A rung past the session limit, or one NVENC refuses, is encoded by SVT-AV1, and the desk’s log says which.

  • The desk’s log line video: AV1 to CMAF HLS names each rung’s encoder, Nvenc or Svt, when the picture starts (podman logs weavesignal-desk-1 on Compose, journalctl --user -u weavesignal-desk on the Quadlets); a rung that fell back to the CPU has a warning above it saying why.
  • The desk’s status over its control socket lists each rung’s encoder.
  • nvidia-smi lists the desk’s process while video runs.
  • The driver’s faults are Xid lines in the kernel log: journalctl -k | grep Xid. A card that has logged one can stop the whole machine; set GPU=none, run the script again, and look at the card before trying again.

To measure the card before a show, the repository has tests/gpu/measure.sh (just gpu-measure): it runs the desk’s AV1 chain from the server image on the card at each rung, several at once, and on the CPU for comparison, watches the kernel log from its start, and stops at the first Xid. It needs the card free: it refuses to start while nvidia-smi lists a compute process. On a desktop it always lists the compositor (kwin_wayland, gnome-shell) and the browser’s GPU process, so stop every job that encodes or computes on the card (a local model, a speech engine), check that only those are left, and run it with --force. tests/gpu/measure.sh --help lists its options.

A host in their own studio may already encode a picture with their own card (OBS with NVENC, say). In 1.2 the station takes only the sound from a host’s software, over Icecast, SRT, WHIP, the bridge or VBAN, and the picture viewers see is the desk’s own, encoded on the station’s server. Passing a host’s picture through without encoding it again is designed but not built: see A host’s own picture.

Text and images CC BY-SA 4.0; code samples AGPL-3.0-only, as the code is. Licences.