home/ atoms/ gpu-memory-segment-trick

Processing audio in short segments reduces GPU memory at the cost of segment-boundary artefacts

Neural separation models process audio in overlapping chunks (segments). A longer segment means more temporal context, which improves quality — but requires more GPU VRAM. Demucs defaults need ~7 GB VRAM; on a 3 GB GPU, setting --segment 8 reduces this with some quality loss. At segment boundaries, Demucs applies 25% overlap with linear interpolation to reduce discontinuity artefacts. The Hybrid Transformer model caps the maximum segment at 7.8 seconds due to its positional encoding. If you still run out of memory, add -d cpu; CPU processing takes roughly 1.5× the track duration.

Examples

# For a GPU with 3 GB VRAM:
demucs --segment 8 mytrack.mp3

# No GPU at all:
demucs -d cpu mytrack.mp3

Assessment

You have a 12 GB VRAM GPU and a 10-minute track. What segment length would you choose and why? What is the trade-off vs the default?

“A segment length of at least 10 is recommended (the bigger the number is, the more memory is required, but quality may increase).”
corpus · demucs-music-source-stem-separation · chunk 6