MAGNeT : AI from META to generate music on your Mac Silicon
This tutorial is a step by step guide to run audiocraft and MAGNeT on you Mac Silicon.
This tutorial is a step by step guide to run audiocraft and MAGNeT on you Mac Silicon.
Introduction
META recently released MAGNeT: Masked Audio Generation using a Single Non-Autoregressive Transformer in OpenSource.
Unfortunately, this implementation rely on audiocraft which use xformers which is known to work only on CUDA devices.
Some modifications are required to use MAGNeT on you Mac Silicon, however it does not support MPS yet (working on it) and therefore runs on your Mac CPU.
Step by steps tutorial
Open a terminal.
First install brew on your Mac, then install ffmpeg :
brew install ffmpeg
Clone the respository :
https://github.com/ezeeFlop/audiocraft
then
cd audiocraft
Create a python venv and install the dependencies :
python3 -m venv .venv
source .venv/bin/activate
pip install — upgrade pip
pip install -r requirements.txt
Thanks to peanutcocktail, he provide slight modifications to apply to the repository. The repository you just cloned includes these modifications.
Run the Gradio Demo Interface like this (don't forget to set the variables accordingly):
export IGNORE_MEMORY_EFFICIENT=1
export PYTORCH_ENABLE_MPS_FALLBACK=1
python -m demos.magnet_app — share
The Gradio app should be up and running, now open this URL with your browser : http://127.0.0.1:7860/
You should see the Gradio app, the first generation takes time (models download).
On a Mac M3, it took 69s to generate 10s of music with the facebook/magnet-small-10secs model.
Conclusion
I hope this quick tutorial will help some of you, hopefully we will have a full MPS support in the near futur !
If you find this article useful, I would appreciate some claps on it !
Many thanks, and happy generating.
Comments ()