Music generation
Self-hosting MusicGen: 300M to 3.3B, one 24GB card covers it
The audiocraft docs state that inference with the medium (~1.5B) model needs a GPU with at least 16GB. In practice musicgen-large's native audiocraft checkpoint is only 6.51GB — load it on an RTX 4090 24GB ($0.540/GPU-hour) and you still have seventeen gigabytes left to spend on batch size.
MusicGen · self-hosted
MusicGen is the single-stage autoregressive Transformer from Meta FAIR's "Simple and Controllable Music Generation" (arXiv:2306.05284). There is no cascade and no upsampling stage: it models the discrete audio tokens produced by EnCodec directly — 32kHz output, 4 codebooks at 50Hz, which works out to 50 autoregressive steps per second of audio. Text goes through a frozen T5 encoder, and a codebook interleaving (delay) pattern lets all codebooks be predicted in one forward pass. That architecture is exactly why it is still pleasant to deploy: no diffusion sampler to tune, no second-stage vocoder to load separately, `generate()` hands you a waveform.
The family on Hugging Face is facebook/musicgen-{small,medium,large} (300M / 1.5B / 3.3B), musicgen-melody and musicgen-melody-large for chroma conditioning, five musicgen-stereo-* variants, plus the later additions musicgen-style (1.5B, conditioned on a 1.5–4.5 second audio excerpt) and musicgen-stem-6cb / -7cb for bass/drums/other stem generation and editing (arXiv:2501.01757). Be clear about what it will not do: vocals were deliberately stripped from the training data using tags plus source separation, so it does not sing; prompts are English-only; positional embeddings cap a single generation at 30 seconds; and the weights are CC-BY-NC 4.0, so no commercial use.
One more thing you need to know before you `pip install`: audiocraft on PyPI is frozen at 1.3.0 (2024-06-03), while the GitHub main branch changelog has moved to 1.4.0a2 and the last commit landed 2025-03-13. So `pip install audiocraft` gets you MusicGen, MAGNeT and AudioSeal — but not MusicGen-Style or JASCO, which only exist on main. The repo is quiet, but MusicGen remains the most dependable open baseline for instrumental scoring, melody-conditioned generation and stem editing: ACE-Step 3.5B (Apache-2.0) is far faster and YuE 7B actually sings, yet nothing has replaced chroma conditioning or per-stem rewriting. On NexGPU it starts at $0.188/GPU-hour, billed by the second, and stops when you stop it.
01 —
Every MusicGen variant: parameters, checkpoint size, what it's for
Sizes are the actual file sizes in the Hugging Face repos — the audiocraft native checkpoints and the transformers conversions are stored at different precisions, so don't mix the two when you size a GPU
| Version | Parameters | VRAM | Context | Notes |
|---|---|---|---|---|
| facebook/musicgen-small | 300M (decoder LM) | audiocraft state_dict 0.84GB / transformers fp32 2.36GB | 30s / 1,500 tokens at 50Hz | Use it to wire up the pipeline, do bulk first-pass screening and iterate on prompt templates. Output quality is clearly below medium. |
| facebook/musicgen-medium | 1.5B | audiocraft 3.68GB / transformers fp32 8.04GB; official docs ask for 16GB+ | 30s / 1,500 tokens | The audiocraft docs call medium the best quality-per-compute trade-off. Most production work should start here, not at large. |
| facebook/musicgen-large | 3.3B | audiocraft fp16 6.51GB / transformers fp32 13.72GB (two shards) | 30s / 1,500 tokens | Top of the quality range. The transformers conversion is stored in fp32 — dropping 13.7GB of weights onto a 16GB card will OOM, so pass torch_dtype=float16. |
| facebook/musicgen-melody / -melody-large | 1.5B / 3.3B | Same class as medium / large | 30s plus a melody chromagram | Condition on a hummed or reference melody. In audiocraft that's generate_with_chroma(); in transformers it is a separate class, MusicgenMelodyForConditionalGeneration — the plain Musicgen class will not load it. |
| facebook/musicgen-stereo-{small,medium,large,melody,melody-large} | 300M – 3.3B | stereo-large fp16 safetensors 6.93GB | 30s across 2 channels | Generates two sets of codebooks, one per channel, each decoded independently through EnCodec and then combined. Budget memory and decode steps as double. |
| facebook/musicgen-style / musicgen-stem-6cb·7cb | 1.5B | stem state_dict 3.72GB plus ~0.70GB of per-stem codecs | 30s; style excerpt 1.5–4.5s | Style conditions on an audio excerpt with double classifier-free guidance (cfg_coef=3 alongside cfg_coef_2=5). Stem splits bass, drums and other into independent tracks so you can regenerate just one. Both live on git main only — they are not in PyPI's 1.3.0. |
02 —
Picking a card, from first run to full fine-tune
A single MusicGen clip is a batch-of-one, 1,500-step autoregressive decode — memory latency is the bottleneck, not FLOPs. Fill the batch before you reach for a more expensive GPU
Get small / medium running, stand up a Gradio demo
Tesla V100 32GB$0.188/GPU-hour
Cheapest card in the fleet, and 32GB swallows medium's 8.04GB fp32 weights or large in fp16 without thinking. Volta has fp16 tensor cores, and audiocraft's pinned torch 2.1.0 fully supports sm_70.
Batch production with musicgen-large / stereo-large in fp16
RTX 4090 24GB$0.540/GPU-hour
6.9GB of fp16 weights leaves 17GB for batch, and Ada's fp16/bf16 decode throughput is exactly what a 1,500-step autoregressive loop consumes. If you want the same 24GB cheaper, RTX 3090 24GB is $0.193/GPU-hour.
Full fine-tune of musicgen-medium 1.5B for a house style
RTX A6000 48GB$0.817/GPU-hour
At roughly 16 bytes per parameter for AdamW (weights, grads, first and second moments), 1.5B lands near 24GB. 48GB leaves room for on-the-fly EnCodec encoding and a real batch, on one card, without FSDP.
Full fine-tune of musicgen-large 3.3B, or many concurrent streams
A100 SXM4 80GB$1.088/GPU-hour
3.3B works out to about 53GB on the same accounting, which one 80GB card holds. If you do want FSDP, nodes go up to 14 GPUs and 2,152GB of node VRAM — no platform change needed.
03 —
Four steps to a running MusicGen
audiocraft is fussy about Python and PyTorch versions — nearly every failure people hit is in step two
- 01
Launch an instance on a PyTorch image
Pick a card in the console (Tesla V100 32GB to get going, RTX 4090 24GB to actually produce), choose one of the 2,000+ prebuilt images from the PyTorch family, and take your pick of SSH, Jupyter or the web terminal. First thing after boot: confirm the driver and the card you were given.
nvidia-smi && python -c "import torch; print(torch.__version__, torch.cuda.get_device_name(0))" - 02
Install audiocraft — the torch version is pinned
The project requires Python 3.9+ and PyTorch 2.1.0. Install torch on its own first, or dependency resolution will pull a newer torch and then blow up building extensions. ffmpeg is a hard dependency for audio I/O. If you need MusicGen-Style or JASCO, swap the last install for git main — PyPI's 1.3.0 (2024-06-03) does not contain them.
apt-get update && apt-get install -y ffmpeg && python -m pip install 'torch==2.1.0' setuptools wheel && python -m pip install -U audiocraft # for style/JASCO: pip install -U git+https://github.com/facebookresearch/audiocraft - 03
Generate your first 30 seconds
set_generation_params defaults to duration=30.0, cfg_coef=3.0, top_k=250, temperature=1.0. Any CFG above 1 means each step runs both a conditional and an unconditional forward, so a 30-second clip is 1,500 steps at two forwards each — don't forget that doubling when you estimate memory or wall time. audio_write drops a 32kHz WAV straight to disk.
python -c 'from audiocraft.models import MusicGen; from audiocraft.data.audio import audio_write; m = MusicGen.get_pretrained("facebook/musicgen-large"); m.set_generation_params(duration=30, cfg_coef=3.0, top_k=250); w = m.generate(["warm lo-fi hip hop, dusty vinyl crackle, mellow rhodes chords"]); audio_write("out", w[0].cpu(), m.sample_rate, strategy="loudness")' - 04
Bring up the Gradio app, or point a batch script at it
The repo ships demos/musicgen_app.py with all ten checkpoints already in the dropdown, stereo variants included. Point AUDIOCRAFT_CACHE_DIR at a data volume so a rebuilt instance doesn't re-download 6.5GB of weights. For long batch runs just write the loop — compute billing stops the moment the instance stops.
AUDIOCRAFT_CACHE_DIR=/workspace/ac_cache python -m demos.musicgen_app --listen 0.0.0.0 --server_port 7860
What a batch of 30-second cues actually costs
Say you're producing a batch of 30-second mono demos with musicgen-large. Take an RTX 4090 24GB at $0.540/GPU-hour: about 6.9GB of fp16 weights, 17GB left over for batch. Three hours = 3 × $0.540 = $1.62. The output side is exactly computable, because MusicGen always writes 32kHz — one 30-second 16-bit WAV is 32000 × 2 × 30 = 1,920,000 bytes ≈ 1.92MB. Assume those three hours produce 1,000 clips: 1.92GB total, and pulling it down costs 1.92 × $0.0081 ≈ $0.016 in egress. Weights plus output occupy 10GB; if you stop the instance but keep the volume that's 10 × $0.414 = $4.14/month, or $0 if you destroy it. Round trip: about $1.64. Spending more doesn't buy proportionally more — the same three hours on an A100 SXM4 80GB is 3 × $1.088 = $3.26, and on an H100 SXM 80GB it's 3 × $3.582 = $10.75. But a single clip is a batch-of-one 1,500-step decode bound by memory latency, so an H100 will not hand you 6.6× the throughput; filling the batch on a 24GB card is what actually saves money. Want it cheaper still? Tesla V100 32GB at $0.188/GPU-hour makes three hours $0.564, and 32GB holds large's fp16 weights with room to spare. Everything is metered per second — no minimum, no setup fee, no quota request.
04 —
FAQ
How much VRAM do I actually need to run MusicGen locally?
Why does MusicGen stop at 30 seconds, and how do I get longer tracks?
Can MusicGen generate vocals or singing?
Can I use MusicGen output commercially?
audiocraft won't install, or won't run on my RTX 5090 — what now?
Is MusicGen still worth using, or has it been superseded?
Start building on NexGPU
Enterprise R&D team or solo developer — either way, your first job can be running in minutes.
Sign up to browse live network pricing. No payment method required.
