Demucs tutorial: splitting an AI-generated song into an instrumental and a cappella on an 8 GB GPU
on this page
TL;DR
- We separated a Korean ballad made with ACE-Step 1.5 into vocal, instrumental (MR) and per-instrument stems with Demucs v4.
- Installation is
pip install "demucs>=4.1.0", and separation is a single command. - On an RTX 5060 8 GB, a 30-second track was separated in 1.4 seconds (htdemucs). A 3-minute song took 5.4 seconds.
- Peak GPU memory was only about 1.5 GB — roughly a fifth of the 8 GB.
- In sections with only accompaniment, the vocal stem was 30–42 dB quieter than the original, effectively silent.
- For instrumentals and a cappella tracks, we recommend
htdemucs --two-stems=vocals. The 6-stem model has limits on piano separation quality.
Introduction
In our previous ACE-Step 1.5 post, we generated a Korean ballad on an RTX 5060 8 GB. This time, we take that song apart again: an a cappella track with only the vocals, an instrumental with only the accompaniment, and stems for each instrument.
The model is Demucs v4 (Hybrid Transformer Demucs), a source separation model released by Meta AI. It’s MIT-licensed, is now officially maintained in the original author’s repository (adefossez/demucs), and version 4.1.0 came out in July 2026.
| Item | Details |
|---|---|
| Input | 30 seconds of a Korean ballad generated with ACE-Step 1.5 (our own track) |
| Models | htdemucs, htdemucs_ft, htdemucs_6s |
| GPU | gcube RTX 5060 8 GB |
| Output | 4 stems (vocals/drums/bass/other), 2 stems (vocals + instrumental), 6 stems |
We used a track we generated ourselves because of copyright. Separate from the Demucs license, separating and publishing commercial recordings can raise copyright issues with the original song.
1. Setup: create a gcube workload
In the gcube console, select the RTX 5060 8 GB and enter the values below. It’s the same image as in the YOLO26 post, with only ffmpeg added.
| Item | Value |
|---|---|
| Container Image | pytorch/pytorch:2.9.1-cuda12.8-cudnn9-runtime |
| Container Port | 8888 |
| Container Environment Variables | HF_HOME=/workspace/hf_cache |
Container Command
bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git wget ffmpeg && pip install jupyterlab && jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root --ServerApp.token='' --ServerApp.password=''"
- Image: The RTX 5060 uses the Blackwell (sm_120) architecture, so it needs PyTorch built with CUDA 12.8 or later.
- ffmpeg: Demucs 4.1.0 uses ffmpeg for MP3/FLAC output and for decoding some input formats.
- HF_HOME: Starting with 4.1.0, pretrained weights are downloaded from Hugging Face. If you mount personal storage at
/workspace, you won’t have to download them again after a restart.
Once the workload is running, add /lab to the end of the service URL to open JupyterLab, then upload the track you made with ACE-Step (ballad_30s.wav).
2. Install and check the GPU
Open a new notebook (Python 3) and install Demucs. Be sure to specify version 4.1.0 or later.
!pip install -q "demucs>=4.1.0"
import torch, importlib.metadata as md
print(torch.__version__, torch.cuda.get_device_name(0))
print("demucs", md.version("demucs"))
You’re ready when you see 2.9.1+cu128, NVIDIA GeForce RTX 5060 and demucs 4.1.0.
Why 4.1.0? Starting with torchaudio 2.9, load/save switched to a TorchCodec-based implementation. Because of this change, older versions of Demucs can fail when reading or saving audio. Version 4.1.0 removes torchaudio from inference and decodes with sphn instead, so it doesn’t have this problem.
3. Run the separation
3-1. 4-stem separation (default)
A single command produces four files: vocals, drums, bass and other instruments (other). On the first run, the weights download automatically.
!demucs -n htdemucs -o separated ballad_30s.wav
The results are saved under separated/htdemucs/ballad_30s/.
3-2. Make an instrumental and an a cappella track (2 stems)
- Adding
--two-stems=vocalssplits the track into the vocals (vocals) and everything else (no_vocals, i.e. the instrumental). If you’re sharing the results, you can save straight to MP3 with--mp3.
!demucs -n htdemucs --two-stems=vocals --mp3 -o separated_mr ballad_30s.wav
3-3. Comparing three models: processing time and VRAM
With the Python API (demucs.api.Separator), you can measure each model’s processing time and peak VRAM in one go.
import time, torch, demucs.api
for name in ["htdemucs", "htdemucs_ft", "htdemucs_6s"]:
sep = demucs.api.Separator(model=name, device="cuda")
torch.cuda.empty_cache(); torch.cuda.reset_peak_memory_stats(); torch.cuda.synchronize()
t = time.time()
origin, stems = sep.separate_audio_file("ballad_30s.wav")
torch.cuda.synchronize()
sec = time.time() - t
peak = torch.cuda.max_memory_allocated() / 1024**3
print(f"{name:12s} {sec:6.1f}s peak {peak:.2f}GB stems={list(stems)}")
for k, v in stems.items():
demucs.api.save_audio(v, f"{name}_{k}.wav", samplerate=sep.samplerate)
del sep
| Model | Stems | Characteristics |
|---|---|---|
| htdemucs | 4 | The default model. A balance of speed and quality |
| htdemucs_ft | 4 | A bundle of four models, each fine-tuned for one stem (vocals, drums, etc.). About 4x slower, but reported to give slightly better quality |
| htdemucs_6s | 6 | Also separates guitar and piano. Marked experimental in the official docs |
If your GPU is short on VRAM: 8 GB had plenty of headroom in our measurements, but on a smaller GPU, lower the --segment value and set PYTORCH_NO_CUDA_MEMORY_CACHING=1. HT models support segments of up to 7.8 seconds only, so set it to 7 or lower.
4. Results
4-1. Processing speed and VRAM (RTX 5060 8 GB)
| Model | Time (30-second track) | Time (3-minute song) | Speed vs. real time | PyTorch peak allocation |
|---|---|---|---|---|
| htdemucs | 1.4 s | 5.4 s | About 21–33x | 0.54 GB |
| htdemucs_ft | 4.2 s | 19.8 s | About 7–9x | 0.54 GB |
| htdemucs_6s | 1.0 s | – | About 30x | 0.61 GB |
- We ran the measurements twice after downloading the weights, and both runs gave the same values. On the very first run, downloading the weights adds tens of seconds.
- Total GPU memory usage seen in
nvidia-smipeaked at about 1.5 GB. This includes the CUDA context and idle usage (about 0.5 GB). - Peak memory for the 3-minute song was the same as for the 30-second track, because the song is processed in short segments.
At this speed, a single RTX 5060 can separate about 600 three-minute songs per hour (htdemucs, excluding file I/O).
4-2. Output format
The input was 48 kHz, but the output is saved as 44.1 kHz · 16-bit WAV, because the Demucs models were trained at 44.1 kHz. If you need a higher bit depth, add --int24 or --float32.
4-3. Checking separation quality
An AI-generated song has no original stems (ground truth), so standard metrics like SDR can’t be calculated. Instead, we checked two things.
- Vocal leakage: In the accompaniment-only intro (0–10 seconds), the vocal stem’s level was about -56 dBFS, 30–42 dB lower than the original (-14 to -28 dBFS). Sections without vocals are left effectively silent.
- Reconstruction error: We summed all the stems back together and compared the result with the original. A higher value means less sound was lost during separation.
| Model | Reconstruction SNR (2 runs) | Energy share by stem |
|---|---|---|
| htdemucs | 27–29 dB | Vocals 49% · other 50% · bass 1% · drums 0% |
| htdemucs_ft | 24–26 dB | Vocals 48% · other 50% · bass 2% · drums 0% |
| htdemucs_6s | 17 dB | Vocals 54% · piano 27% · other 19% · guitar, bass, drums 0% |
The values vary by 2–3 dB from run to run because Demucs shifts the input by small random amounts (random shift) when separating.
What it means
- This song is a piano- and strings-driven ballad, so with the 4-stem models most of the accompaniment ends up in
other. The drum stem is almost empty. htdemucs_6spulled the piano out as its own stem, but its reconstruction SNR is 7–12 dB lower than the other models. The official docs also describe it as an experimental model whose piano stem has a lot of bleed and artifacts.- If your goal is an instrumental or a cappella track,
htdemucs --two-stems=vocalsis the most practical choice.
[Audio/video: original → a cappella → instrumental comparison]
5. FAQ
Q. Can I separate commercial recordings?
Demucs is MIT-licensed, so there are no restrictions on using the model. However, publishing or distributing the separated results can raise copyright issues with the original song. In this post, we used only a track we generated ourselves.
Q. Which model is best?
For instrumentals and a cappella tracks, htdemucs is enough. If you want slightly better quality, use htdemucs_ft, but processing takes about 4x longer.
Q. Do long songs work on 8 GB?
Yes. Demucs processes songs in short segments. Even with a 3-minute song, peak memory was 0.54 GB, the same as for the 30-second track; only the processing time grew, to 5.4 seconds.
Q. I get a You are sending unauthenticated requests to the HF Hub warning.
This is a notice shown when downloading weights from Hugging Face. It doesn’t affect the separation results, so you can ignore it.
Q. I get torchaudio/TorchCodec errors when reading or saving audio.
Demucs 4.0.x and earlier use torchaudio for audio I/O, which can fail at this step when used with torchaudio 2.9 or later. Upgrade with pip install -U "demucs>=4.1.0".
Wrapping up
We took a song made with ACE-Step and split it back apart with Demucs. Both generation and separation run on a single RTX 5060 8 GB. You can also use the separated vocals as preprocessing to improve speech recognition (STT) accuracy or to clean up voice datasets.
On gcube, you can rent as many GPUs as you need, from the RTX 5060 up to the RTX 5090, and try experiments like this right away.