Skip to content

Installation Instructions

ftshijt edited this page Jan 11, 2021 · 1 revision

This Wiki aims to provide the installation instructions for the MusicGeneration

Steps1: Git clone MusicGeneration

$ cd <any-place>
$ git clone https://github.com/SJTMusicTeam/MusicGeneration.git

Step2 [Optional]: Put complied Kaldi under MusicGeneration/tools

If you have complied Kaldi at Step1, put it under tools.

$ cd <MusicGeneration-root>/tools
$ ln -s <kaldi-root> .

If you do not have MusicGeneration/tools/kaldi, when make, Kaldi repository is automatcally put without compliling (For now, we only use some basic shell in Kaldi, so no need for complied versions).

Step3: Setup Python environment

You have to create <MusicGeneration-root>/tools/activate_python.sh to specify the Python interpreter used in MusicGeneration recipes. (To understand how MusicGeneration specifies Python, see path.sh for example.)

We also have some scripts to generate tools/activate_python.sh.

  • Option A: setup anaconda environment
$ cd <MusicGeneration-root>/tools
$ ./setup_anaconda.sh [output-dir-name|default=venv] [conda-env-name|default=root] [python-version|default=none]
# e.g.
$ ./setup_anaconda.sh anaconda mg 3.8

This script tries to create a new miniconda if the output directory doesn’t exist. If you already have Anaconda and you’ll use it then,

$ cd <MusicGeneration-root>/tools
$ CONDA_TOOLS_DIR=$(dirname ${CONDA_EXE})/..
$ ./setup_anaconda.sh ${CONDA_TOOLS_DIR} [conda-env-name] [python-version]
# e.g.
$ ./setup_anaconda.sh ${CONDA_TOOLS_DIR} mg 3.8
  • Option B: Setup system Python environment
$ cd <MusicGeneration-root>/tools
$ ./setup_python.sh $(command -v python3)
  • Option C: Without setting Python environment

Option B and Option C are almost same. This option might be suitable for Google colab.

$ cd <MusicGeneration-root>/tools
$ rm -f activate_python.sh && touch activate_python.sh

Step4: Install mg

$ cd <MusicGeneration-root>/tools
$ make

The Makefile tries to install MusicGeneration and all dependencies including PyTorch. You can also specify PyTorch version, for example:

$ cd <MusicGeneration-root>/tools
$ make TH_VERSION=1.3.1

Note that the CUDA version is derived from nvcc command. If you’d like to specify the other CUDA version, you need to give CUDA_VERSION.

$ cd <MusicGeneration-root>/tools
$ make TH_VERSION=1.3.1 CUDA_VERSION=10.1

If you don’t have nvcc command, packages are installed for CPU mode by default. If you’ll turn it on manually, give CPU_ONLY option.

$ cd <MusicGeneration-root>/tools
$ make CPU_ONLY=0

Step5: Check installation

You can check whether your installation is successfully finished by

$ cd <MusicGeneration-root>/tools
$ . ./activate_python.sh; python3 check_install.py

Note that this check is always called in the last stage of the above installation.