基础环境:
系统:ubuntu22.04
显卡:A100(40G)
CPU:16C
内存:64G
磁盘空间:100G以上
CUDA版本: 11.4
前言:
项目地址:https://github.com/tencent-ailab/SongGeneration
根据实测,建议使用docker方式进行环境部署,本地安装python依赖包经常出现各种缺失
目前该项目不支持多卡部署,且限制同时请求仅为1个,只能供测试使用
1、docker安装
先卸载老版本docker
sudo apt-get remove docker docker-engine docker.io containerd runc
更新软件包
sudo apt-get update
sudo apt-get upgrade
安装docker依赖
sudo apt-get install ca-certificates curl gnupg lsb-release
添加docker密钥
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
添加阿里云docker安装源
sudo add-apt-repository “deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable”
安装docker
apt-get install docker-ce docker-ce-cli containerd.i
更新dockerhub
curl -s https://static.1ms.run/1ms-helper/scripts/install.sh | sudo bash /dev/stdin config
安装运行环境的docker
docker pull juhayna/song-generation-levo:hf0613
安装docker-gpu支持
添加官方源
distribution=$(. /etc/os-release;echo <math><semantics><mrow><mi>I</mi><mi>D</mi></mrow><annotation encoding="application/x-tex">ID</annotation></semantics></math>IDVERSION_ID)
curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list |
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
安装 Toolkit
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
配置 Docker 使用 nvidia 运行时
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
2、代码和模型下载
代码克隆
git clone https://github.com/tencent-ailab/SongGeneration
安装huggingface下载工具
pip install -U huggingface_hub -i https://pypi.tuna.tsinghua.edu.cn/simple/
将hf源切换为国内镜像站
export HF_ENDPOINT=https://hf-mirror.com
进入代码目录,下载对应模型
cd SongGeneration/
huggingface-cli download --resume-download --local-dir-use-symlinks False tencent/SongGeneration --local-dir ./
完整目录应该如下,包含ckpt,third_party等模型目录
3、运行启动
官方启动命令:
docker run -it --gpus all --network=host juhayna/song-generation-levo:hf0613 /bin/bash #该命令不完整,代码模型已经下载到本地,需要挂载本地目录,不然容器内没有对应的内容
实际执行命令:docker run -it --gpus all -v /$PATH(替换为你的存放路径)/SongGeneration:/workspace --network=host juhayna/song-generation-levo:hf0613 /bin/bash
执行完后,会进入容器内,执行以下命令进行测试
sh generate.sh ckpt/songgeneration_base/ sample/lyrics.jsonl output_path #命令为测试命令
启动运行web页面
sh tools/gradio/run.sh ckpt/songgeneration_base/
访问本地8081即可访问
后台运行
docker run -d --gpus all -v /$PATH(替换为你的存放路径)/SongGeneration:/workspace --network=host juhayna/song-generation-levo:hf0613
bash -c “cd /workspace && sh tools/gradio/run.sh ckpt/songgeneration_base && tail -f /dev/null”