Skip to content

Instantly share code, notes, and snippets.

@halr9000
Last active February 22, 2024 00:25
Show Gist options
  • Save halr9000/274406cc97b22ae7d7573874fc23c2ea to your computer and use it in GitHub Desktop.
Save halr9000/274406cc97b22ae7d7573874fc23c2ea to your computer and use it in GitHub Desktop.
Quick MusicGen setup for Windows

MusicGen for Windows

Overview

The following is a super quick mnod of facebookresearch/audiocraft to reliably install PyTorch with Cuda support on Windows, which the original repo does not document, and that slowed me down quite a bit. I wasted time so you don't have to! I am too lazy to create a proper fork and PR, but I'm sure someone else can do that if motivated.

I have included both virtualenv and conda methods.

Preparing your environment

Install Python, Git, and Cuda, if not already present. From a PowerShell terminal:

winget install Python.Python.3.10
winget install git.git
winget install Nvidia.CUDA

Change to a project folder with 10-20 GB space free. Clone the repo:

git clone https://github.com/facebookresearch/audiocraft

Download one of the requirements files and place it in the audiocraft folder.

Filename Environment
requirements-win.txt virtualenv
requirements.yml conda

If unsure, just grab the txt file. The below documents the steps only for virtualenv. Conda users -- I'm sure you can figure it out. I believe in you.

Next, create your virtualenv:

python -m venv venv

Activate the new environment

./venv/scripts/activate.ps1

Install Pytorch using the requirements-win.txt file in this gist. This must be done prior to the main reqwuirements, or you'll have torch without Cuda, and no access to use your GPU from within Python. (Note that Conda avoids this issue and setup can be completed in one step.)

pip install -r requirements-win.txt

Install remaining dependencies

pip install -r requirements.txt

That's it!

P.S. you could smash all of the preceding lines into a script and do it in one shot.

Running MusicGen

Lastly, start the web UI with the following command:

python app.py
# Remote index required for Windows
-i https://download.pytorch.org/whl/cu117
torch
torchaudio
name: audiocraft
channels:
- pytorch
- nvidia
- conda-forge
- defaults
dependencies:
- python=3.9
- pytorch
- pytorch-cuda=11.7
- torchaudio
- torchvision
- av
- einops
- hydra-core>=1.1
- num2words
- numpy
- sentencepiece
- spacy==3.5.2
- huggingface_hub
- tqdm
- transformers
- librosa
- gradio
- pip
- pip:
- xformers
- flashy
- hydra_colorlog
- julius
- demucs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment