Win11 部署 NotaGen (大模型作曲)

NotaGen 是一个大模型预训练的音乐生成模型


项目地址:https://github.com/ElectricAlexis/NotaGen



项目DEMO:https://electricalexis.github.io/notagen-demo/


下面试试本地部署效果

首先下载项目文件

git clone https://github.com/ElectricAlexis/NotaGen.git

image



然后我们创建一个 3.10 的 Python 环境

conda create  --prefix G:\AI\NotaGen python=3.10

image



然后激活环境

conda activate G:\AI\NotaGen

image



安装 pytouch 和 cuda

conda install pytorch==2.3.0 pytorch-cuda=11.8 -c pytorch -c nvidia

image



安装 accelerate

pip install accelerate

image



安装 optimum

pip install optimum

image



最后安装必要的依赖

pip install -r requirements.txt

image



最后检查下我们的 pytorch 是不是支持 cuda 的

python
import torch
torch.__version__
print(torch.cuda.is_available())

image

返回 true 表示支持 cuda,可以使用 GPU




项目自带了个damo,在 gradio 文件夹中

首先下载模型

demo使用的模型为 NotaGen-X

模型地址:https://huggingface.co/ElectricAlexis/NotaGen/blob/main/weights_notagenx_p_size_16_p_length_1024_p_layers_20_h_size_1280.pth

镜像站模型地址:https://hf-mirror.com/ElectricAlexis/NotaGen/blob/main/weights_notagenx_p_size_16_p_length_1024_p_layers_20_h_size_1280.pth

然后把模型放到 gradio 文件夹中(主要不要改模型的文件名)


运行Demo:

python demo.py

image


看下模型已经加载到了显存中(8G显存的机器就能跑)

image


这个时候打开 http://127.0.0.1:7861/ 就能看到 Demo 界面了

随便选个风格生成下看看,显卡开始狂转中…

image



等待一会,生成完成

image



保存文件,然后找个在线播放乐谱的网站试试效果,比如:https://bbs.moonyueqi.com/xmlplay/

image

posted @ 2025-05-19 15:43  sun8134  阅读(148)  评论(0)    收藏  举报
分享按钮