How to run MusicGen (AudioCraft) on a cloud GPU

Rent a GPU on Deploy, then open a terminal in JupyterLab or over SSH. Install MusicGen from the official facebookresearch/audiocraft repository the way the README prints, then run the Python API in docs/MUSICGEN.md or the Gradio demo in demos/musicgen_app.py. The Gradio command on this page does not pass --share. Copy the wav files off the instance before you destroy it, because destroying the instance deletes its disk.

Other music pages: How to run Stable Audio Open on a cloud GPU, How to run ACE-Step music generation on a cloud GPU, How to run YuE music generation on a cloud GPU, and How to run Bark text-to-audio on a cloud GPU. Stem separation, whose README prints at least 3GB and about 7GB, is How to separate music stems with Demucs on a cloud GPU. If the process runs out of memory: How to fix CUDA out of memory on a cloud GPU. The tunnel for the Gradio demo is How to use SSH port forwarding on a cloud GPU. How published FLUX and SDXL weight sizes are read: How much VRAM do I need for FLUX and SDXL.

The README says the code is released under the MIT license as found in the LICENSE file, and the model weights are released under the CC-BY-NC 4.0 license as found in the LICENSE_weights file. model_cards/MUSICGEN_MODEL_CARD.md says the same split: code under MIT, weights under CC-BY-NC 4.0. The LICENSE file is the MIT License. Its copyright line names an organization. This page does not print that name. The GitHub license field on 2026-11-13 was MIT. The NonCommercial definition in LICENSE_weights does not print a dollar amount. Read both files before you redistribute the code or the weights.

The commands below are copied from the upstream files named in each step. They were not run on a CloudGPU instance for this page. Anything this page adds around them is marked. docs/MUSICGEN.md and demos/musicgen_app.py pass Hub ids to get_pretrained and to a Gradio radio. This page does not paste those ids. Copy each string from the file you are following.

What the documentation says about memory

docs/MUSICGEN.md (commit 62201d6e74c705e93e61e1aab7f83373c028aa9d, 2023-11-21) says AudioCraft requires a GPU with at least 16 GB of memory for running inference with the medium-sized models (~1.5B parameters). The same file says it recommends 16GB of memory, and that smaller GPUs will be able to generate short sequences, or longer sequences with the small model. The size words in that file are 300M, 1.5B, and 3.3B. It does not print a separate GPU GB figure for the 300M model or the 3.3B model. The model card repeats 300M, 1.5B, and 3.3B and prints no GPU GB figure. This page does not treat a parameter count as VRAM.

GET /v1/public/compute-capabilities does not list GPUs. It returns feature flags. The memory column is vram_gb from gpu-prices.json, updated_at 2026-11-13T18:00:59.357Z. GET /v1/public/gpu-catalog the same day (generated_at 2026-11-13T18:00:59.934Z) listed the same names and the same vram_gb values, plus Ascend 910B at 64, which is not in gpu-prices.json and is not listed here. The catalog response also includes an availability field. This page does not copy it. Every prices row has gpu_count 1. Every catalog row has min_gpu_count 1. As a number, RTX 2080 (8), RTX 3080 (10), RTX 2080 Ti (11), and RTX 3080 Ti (12) are below the 16 in the medium-model sentence. V100 16G is 16. The other printed values are higher than 16. The small-model sentence does not print a GB figure, so this page does not match those four rows to it. This page did not run MusicGen and does not mark a row as enough. Which listing you can start is on Deploy.

The catalog template list had no MusicGen template and no AudioCraft template.

Catalog name vram_gb
RTX 2080 8
RTX 3080 10
RTX 2080 Ti 11
RTX 3080 Ti 12
V100 16G 16
A30 24
RTX 3090 24
RTX 4090 24
RTX 4090D 24
RTX 4080 SUPER 32G 32
RTX 5090 32
RTX 5090D 32
V100 32G 32
A100 40G 40
A800 40G 40
A40 48
RTX 4090 48G 48
RTX 4090D 48G 48
RTX A6000 48
NVIDIA RTX PRO 5000 72G 72
RTX PRO 5000 72G 72
A100 80G 80
A800 80G 80
H800 80
RTX 6000D 83
H20 96G 96
RTX PRO 6000 96G 96
RTX PRO 6000 Max-Q 96
H20-3e 141G 141

Install

On Deploy, choose Raw GPU. The README says AudioCraft requires Python 3.9 and PyTorch 2.1.0. The install block does not print git clone. The Gradio command in docs/MUSICGEN.md is a module path in this repository. The clone below is this page’s, and it comes first so that path exists. It was not run.

# The README install block does not print a clone. These two lines are this page's. They were not run.
git clone https://github.com/facebookresearch/audiocraft.git
cd audiocraft

The install block, copied. How to install a specific PyTorch CUDA version is the index check against the CUDA Version in the nvidia-smi header. The block does not pass a CUDA wheel index. This page did not pick a wheel.

# Best to make sure you have torch installed first, in particular before installing xformers.
# Don't run this if you already have PyTorch installed.
python -m pip install 'torch==2.1.0'
# You might need the following before trying to install the packages
python -m pip install setuptools wheel
# Then proceed to one of the following
python -m pip install -U audiocraft  # stable release
python -m pip install -U git+https://git@github.com/facebookresearch/audiocraft#egg=audiocraft  # bleeding edge
python -m pip install -e .  # or if you cloned the repo locally (mandatory if you want to train).
python -m pip install -e '.[wm]'  # if you want to train a watermarking model

After the clone, this page follows python -m pip install -e . so the demo module is the one in the clone. The stable-release line and the watermark extra are in the same block. This page did not run them. The ffmpeg lines, copied:

sudo apt-get install ffmpeg
# Or if you are using Anaconda or Miniconda
conda install "ffmpeg<5" -c conda-forge

requirements.txt (commit ed418e4bce89c93f5281ad34f4618b23958157ec, 2025-01-12) opens with the comment please make sure you have already a pytorch install that is cuda enabled! and pins torch==2.1.0, torchaudio>=2.0.0,<2.1.2, torchvision==0.16.0, and xformers<0.0.23. It also lists gradio with no version. It does not pass a CUDA index. Repository HEAD was 896ec7c47f5e5d1e5aa1e4b260c4405328bf009d, committed 2025-03-13T16:01:11Z. The README commit is e5fcc458a4dc1c6f7248cbceac9cfe471f2c92b8, committed 2025-01-15T12:25:54Z.

Model sizes

docs/MUSICGEN.md says it provides a simple API and 10 pre-trained models. The size words and tasks, copied without the Hub ids:

Size word in that file Parameters Task, as that file prints it
small 300M text to music only
medium 1.5B text to music only
melody 1.5B text to music and text+melody to music
large 3.3B text to music only
melody-large 3.3B text to music and text+melody to music
stereo, five rows the same five fine tuned for stereo generation

Each row in the file is a Hub id. Copy the string from docs/MUSICGEN.md. This page does not paste it. The same file says the authors observe the best trade-off between quality and compute with the medium model or the melody model. That sentence is theirs. This page did not measure it.

On 2026-11-13 this page requested six of those ids: small, medium, large, melody, melody-large, and stereo-small. Each response had license cc-by-nc-4.0, gated false, and pipeline_tag text-to-audio. lastModified was 2023-11-17T13:56:10.000Z, 2023-11-17T15:25:23.000Z, 2023-11-17T15:25:38.000Z, 2024-04-24T12:27:39.000Z, 2024-02-21T10:34:31.000Z, and 2024-03-06T14:41:16.000Z, in that order. This page did not request the other four stereo ids.

The README FAQ says Hugging Face stores the model in a location that AUDIOCRAFT_CACHE_DIR can override for the AudioCraft models. It points at the Transformers cache docs for other Hugging Face models. It says a model that relies on Demucs, and names a melody model in parentheses, uses the Torch Hub cache. How to separate music stems with Demucs on a cloud GPU is that other repository. This page does not paste the parenthetical id.

Python API

The API example in docs/MUSICGEN.md, with the Hub argument replaced. The replacement is this page’s. The rest is copied.

import torchaudio
from audiocraft.models import MusicGen
from audiocraft.data.audio import audio_write

# docs/MUSICGEN.md passes a Hub id here. Copy that string from the file. This page does not paste it.
model = MusicGen.get_pretrained("HUB_ID_FROM_MUSICGEN_MD")
model.set_generation_params(duration=8)  # generate 8 seconds.
wav = model.generate_unconditional(4)    # generates 4 unconditional audio samples
descriptions = ['happy rock', 'energetic EDM', 'sad jazz']
wav = model.generate(descriptions)  # generates 3 samples.

melody, sr = torchaudio.load('./assets/bach.mp3')
# generates using the melody from the given audio and the provided descriptions.
wav = model.generate_with_chroma(descriptions, melody[None].expand(3, -1, -1), sr)

for idx, one_wav in enumerate(wav):
    # Will save under {idx}.wav, with loudness normalization at -14 db LUFS.
    audio_write(f'{idx}', one_wav.cpu(), model.sample_rate, strategy="loudness", loudness_compressor=True)

audiocraft/data/audio.py on main, read 2026-11-13, defines audio_write with format defaulting to wav and add_suffix defaulting to True. The stem is the filename without the extension. The comment’s {idx}.wav matches that default. This page did not call it.

The same file’s Transformers section says MusicGen is available in Transformers from version 4.31.0 onwards, and its install line is:

pip install git+https://github.com/huggingface/transformers.git

requirements.txt pins transformers>=4.31.0. This page does not treat the git install and the >=4.31.0 pin as the same command. The snippet builds AutoProcessor and MusicgenForConditionalGeneration with from_pretrained. The argument is a Hub id. Copy it from docs/MUSICGEN.md. This page does not paste it. The save block, copied:

import scipy

sampling_rate = model.config.audio_encoder.sampling_rate
scipy.io.wavfile.write("musicgen_out.wav", rate=sampling_rate, data=audio_values[0, 0].numpy())

This page did not run it. The training section of docs/MUSICGEN.md is not copied here.

Gradio demo

docs/MUSICGEN.md prints python -m demos.musicgen_app --share. In demos/musicgen_app.py, --share is store_true and its help text is Share the gradio UI. The script sets launch_kwargs['share'] only when that flag is set. It sets launch_kwargs['auth'] only when both --username and --password are non-empty. The command below is this page’s. It passes --listen 127.0.0.1 and --server_port 7860. It does not pass --share, --username, --password, or --inbrowser. It was not run.

python -m demos.musicgen_app --listen 127.0.0.1 --server_port 7860

--listen is a string. Its help text is IP to listen on for connections to Gradio. The default is 127.0.0.1 when SPACE_ID is not in the environment, and 0.0.0.0 when it is. This page passes 127.0.0.1, and launch_kwargs sets server_name from that value. --server_port is an int. Its help text is Port to run the server listener on. The default is 0, and the script adds server_port to launch_kwargs only when that value is true, so the default 0 is not passed. This page passes 7860, which is true, so launch_kwargs['server_port'] is 7860. 7860 is the Gradio port on the SSH forwarding page. It is not the default in this script. IS_BATCHED is computed from SPACE_ID. The README command does not set SPACE_ID, so the else branch calls ui_full, which calls interface.queue().launch(**launch_kwargs). The radio in ui_full lists 10 Hub ids. load_model defaults to a Hub id. Copy those strings from the file. This page does not paste them.

The predict path writes each clip with NamedTemporaryFile("wb", suffix=".wav", delete=False) and audio_write(..., add_suffix=False). A FileCleaner is constructed with file_lifetime defaulting to 3600, and _cleanup unlinks files older than that. The markdown in ui_full says the model can generate up to 30 seconds of audio in one pass. The same markdown includes a duration warning. This page does not copy that timing and did not start the demo. Forward 127.0.0.1 port 7860 with how to use SSH port forwarding on a cloud GPU. demos/musicgen_app.py was commit f83babff6b5e97f75562127c4cc8122229c8f099, committed 2023-11-27T09:51:39Z. The same --listen, --server_port, --username, --password, --inbrowser, and --share arguments are on repository HEAD 896ec7c47f5e5d1e5aa1e4b260c4405328bf009d.

ComfyUI

The AudioCraft README and docs/MUSICGEN.md do not mention ComfyUI. The ComfyUI examples top-level directory list on 2026-11-13 had no MusicGen directory. 3d/README.md and audio/README.md in that repository had no MusicGen section. Examples HEAD was f9431bb000ce792094ff345446e22cac1ea6cef3, committed 2025-11-26T20:33:58Z. Installing ComfyUI itself is How to install ComfyUI and ComfyUI-Manager on a cloud GPU. This page did not install a node.

When it fails

CUDA out of memory. docs/MUSICGEN.md prints 16 GB for the medium-sized models and does not print a low-memory flag. If the process raises that error, use how to fix CUDA out of memory on a cloud GPU.

“CUDA error: no kernel image is available for execution on the device” on an RTX 5090. The README pins torch==2.1.0 and does not pass a CUDA wheel index. The RTX 5090 guide says that card is compute capability 12.0 (sm_120) and that PyTorch 2.7 and later, on a build for CUDA 12.8 or newer, is the line that announced support. This page did not re-test this pin on an RTX 5090. Catalog RTX 5090 and RTX 5090D are 32. That is the catalog number only.

Save the wav files, then destroy

Copy {idx}.wav from the API example, musicgen_out.wav from the Transformers example, and any temporary wav the Gradio demo has not yet deleted, before you destroy the instance. Save your work before you destroy a cloud GPU is the checklist. The terms say data on local instance storage is permanently deleted when the instance is destroyed.

The pricing page FAQ states the billing rule in these words:

Per-minute options have a 1-minute minimum; unused prepaid minutes are refunded when you destroy the instance. Some configurations use whole-hour billing with a 1-hour minimum; unused time within a charged hour is not refunded on voluntary stop. The billing period, minimum charge and initial prepayment are shown before confirmation. No subscription.

Frequently asked questions

How much VRAM does the MusicGen documentation publish?

docs/MUSICGEN.md says AudioCraft requires a GPU with at least 16 GB of memory for running inference with the medium-sized models, about 1.5B parameters (read 2026-11-13). The same file says it recommends 16GB of memory, and that smaller GPUs will be able to generate short sequences, or longer sequences with the small model. It prints 300M, 1.5B, and 3.3B as model sizes. It does not print a separate GPU GB figure for the 300M model or the 3.3B model. This page does not mark a catalog vram_gb as enough. Which listing you can start is on https://cloudgpu.app/deploy.

Which license applies to the code, and which applies to the weights?

The AudioCraft README says the code is released under the MIT license in the LICENSE file, and the model weights are released under the CC-BY-NC 4.0 license in the LICENSE_weights file. The model card in the repository says the same split. On 2026-11-13 the six model-API responses this page recorded, for the small, medium, large, melody, melody-large, and stereo-small rows, had license cc-by-nc-4.0 and gated false. The copyright line in the code LICENSE names an organization. This page does not print that name. The NonCommercial definition in LICENSE_weights does not print a dollar amount. Read both files before you redistribute the code or the weights.

Where does the documented API save audio, and does the repository ship a Gradio demo?

The API example in docs/MUSICGEN.md calls audio_write with a stem of the sample index. The comment says it will save under {idx}.wav. audio_write defaults format to wav and add_suffix to True. The Transformers example in the same file writes musicgen_out.wav with scipy.io.wavfile.write. The local Gradio command in that file is python -m demos.musicgen_app --share. The command on this page is python -m demos.musicgen_app --listen 127.0.0.1 --server_port 7860. That command does not pass --share. demos/musicgen_app.py writes wav files through NamedTemporaryFile and a FileCleaner whose default file_lifetime is 3600. This page did not start the demo. The --listen help text is IP to listen on for connections to Gradio, and the command passes 127.0.0.1. The --server_port help text is Port to run the server listener on. The script default is 0, and that 0 is not passed to launch. The command passes 7860, so launch receives that port. Forward 127.0.0.1 port 7860. The tunnel page is https://cloudgpu.app/guides/how-to-use-ssh-port-forwarding-on-a-cloud-gpu.

Does AudioCraft document a ComfyUI route?

The AudioCraft README and docs/MUSICGEN.md do not mention ComfyUI. The ComfyUI examples top-level directory list, the 3d README, and the audio README on 2026-11-13 had no MusicGen section. Examples HEAD was f9431bb000ce792094ff345446e22cac1ea6cef3. This page did not install a node.

Sources (read 2026-11-13, Asia/Shanghai)

  • AudioCraft README (Python 3.9, PyTorch 2.1.0, install block, ffmpeg, MIT code license, CC-BY-NC 4.0 weights, AUDIOCRAFT_CACHE_DIR): https://github.com/facebookresearch/audiocraft/blob/main/README.md commit e5fcc458a4dc1c6f7248cbceac9cfe471f2c92b8. Repository HEAD 896ec7c47f5e5d1e5aa1e4b260c4405328bf009d, committed 2025-03-13T16:01:11Z
  • docs/MUSICGEN.md (16 GB sentence, 10 models, 300M / 1.5B / 3.3B, API example, Transformers example, python -m demos.musicgen_app --share): commit 62201d6e74c705e93e61e1aab7f83373c028aa9d
  • model_cards/MUSICGEN_MODEL_CARD.md (MIT code, CC-BY-NC 4.0 weights, 300M / 1.5B / 3.3B, no GPU GB figure): commit 5905d2ef2526a38d4231096696218b5d4d55752b
  • LICENSE (MIT License; copyright line names an organization this page does not print): commit 5238467a52adc08ddc72ffd7b6ec8ffb74528af2. GitHub license field MIT
  • LICENSE_weights (CC BY-NC 4.0; NonCommercial definition prints no dollar amount): commit 5e3ae32f6957c15211b2248dc3bd87a04da7288a
  • requirements.txt (cuda-enabled comment, torch==2.1.0, no CUDA index): commit ed418e4bce89c93f5281ad34f4618b23958157ec
  • demos/musicgen_app.py (--listen string, --server_port int default 0, --share store_true, auth only when both username and password are set, NamedTemporaryFile, FileCleaner 3600, radio of Hub ids): commit f83babff6b5e97f75562127c4cc8122229c8f099. The same arguments are on repository HEAD 896ec7c47f5e5d1e5aa1e4b260c4405328bf009d
  • audiocraft/data/audio.py (audio_write defaults format='wav', add_suffix=True), read on main 2026-11-13
  • Model API for the small, medium, large, melody, melody-large, and stereo-small rows (cc-by-nc-4.0, gated false), read 2026-11-13. Hub ids are not copied here
  • ComfyUI examples (no MusicGen section): https://github.com/comfyanonymous/ComfyUI_examples commit f9431bb000ce792094ff345446e22cac1ea6cef3
  • Public GPU memory: https://cloudgpu.app/gpu-prices.json (updated_at 2026-11-13T18:00:59.357Z) and https://cloudgpu.app/v1/public/gpu-catalog (generated_at 2026-11-13T18:00:59.934Z). GET /v1/public/compute-capabilities returned feature flags and no GPU list. The catalog had no MusicGen template

Cards you can start are on the Deploy page. Prices are on https://cloudgpu.app/pricing and are not repeated here.

Last updated: 2026-11-13 (Asia/Shanghai).