在 CentOS Stream 9 上安装 GPT-SoVITS 的完整教程

针对您的 CentOS Stream 9 系统,以下是完整的安装指南:

1. 安装系统依赖

sudo dnf update -y
sudo dnf install -y epel-release
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y git wget ffmpeg sox-devel bzip2-devel sqlite-devel openssl-devel readline-devel zlib-devel libffi-devel

2. 安装 Miniconda

cd /www/wwwroot/14.103.143.124
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p /www/wwwroot/14.103.143.124/miniconda
rm Miniconda3-latest-Linux-x86_64.sh

# 初始化 conda
source /www/wwwroot/14.103.143.124/miniconda/bin/activate
conda init bash
exec bash

3. 创建 Conda 环境

conda create -n GPTSoVits python=3.9 -y
conda activate GPTSoVits

4. 克隆 GPT-SoVITS 仓库

cd /www/wwwroot/14.103.143.124
git clone https://github.com/RVC-Boss/GPT-SoVITS.git
cd GPT-SoVITS

5. 安装 Python 依赖

pip install -r requirements.txt

6. 安装 PyTorch (CentOS 9 特定)

# 对于 NVIDIA GPU
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

# 或者对于 CPU
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

7. 下载预训练模型

mkdir -p GPT_SoVITS/pretrained_models
mkdir -p GPT_SoVITS/text

# 下载主模型
wget -P GPT_SoVITS/pretrained_models/ https://huggingface.co/lj1995/GPT-SoVITS/resolve/main/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt
wget -P GPT_SoVITS/pretrained_models/ https://huggingface.co/lj1995/GPT-SoVITS/resolve/main/s2G488k.pth

# 下载 G2PW 模型
wget https://github.com/Alexander-Wen/G2PW/archive/refs/tags/v1.1.zip
unzip v1.1.zip -d GPT_SoVITS/text/
mv GPT_SoVITS/text/G2PW-1.1 GPT_SoVITS/text/G2PWModel
rm v1.1.zip

# 下载 UVR5 模型
mkdir -p tools/uvr5/uvr5_weights
wget -P tools/uvr5/uvr5_weights/ https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP2-%E4%BA%BA%E5%A3%B0vocals%2B%E9%9D%9E%E4%BA%BA%E5%A3%B0instruments.pth
wget -P tools/uvr5/uvr5_weights/ https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/uvr5_weights/HP5-%E4%B8%BB%E4%BA%BA%E5%A3%B0vocals%2B%E5%90%AC%E8%A7%89%E4%BC%B4%E5%A5%8Finstruments.pth

8. 解决 CentOS 9 特有依赖问题

# 安装 libsndfile
sudo dnf install -y libsndfile

# 解决可能的 libGL 问题
sudo dnf install -y mesa-libGL

9. 创建启动脚本

cat > start_gpt_sovits.sh << 'EOF'
#!/bin/bash
source /www/wwwroot/14.103.143.124/miniconda/bin/activate GPTSoVits
cd /www/wwwroot/14.103.143.124/GPT-SoVITS
python webui.py
EOF

chmod +x start_gpt_sovits.sh

10. 创建 systemd 服务

sudo tee /etc/systemd/system/gpt-sovits.service > /dev/null << 'EOF'
[Unit]
Description=GPT-SoVITS WebUI
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/www/wwwroot/14.103.143.124
Environment="PATH=/www/wwwroot/14.103.143.124/miniconda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ExecStart=/www/wwwroot/14.103.143.124/GPT-SoVITS/start_gpt_sovits.sh
Restart=always
RestartSec=30
StandardOutput=file:/var/log/gpt-sovits.log
StandardError=file:/var/log/gpt-sovits-error.log

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable gpt-sovits
sudo systemctl start gpt-sovits

11. 防火墙配置

sudo firewall-cmd --permanent --add-port=9880/tcp
sudo firewall-cmd --permanent --add-port=9871/tcp
sudo firewall-cmd --permanent --add-port=9872/tcp
sudo firewall-cmd --permanent --add-port=9873/tcp
sudo firewall-cmd --permanent --add-port=9874/tcp
sudo firewall-cmd --reload

12. 验证安装

# 检查服务状态
sudo systemctl status gpt-sovits

# 检查日志
journalctl -u gpt-sovits -f

13. 访问 WebUI

服务启动后,您可以通过以下方式访问:

  • 主界面: http://服务器IP:9874
  • TTS 推理界面: http://服务器IP:9874/1-GPT-SoVITS-TTS/1C-inference

CentOS 9 特有注意事项

  1. Python 版本:CentOS 9 默认 Python 版本可能较高,我们使用 Conda 环境确保 Python 3.9
  2. FFmpeg 版本:确保安装的 FFmpeg 版本 >= 4.0
  3. CUDA 支持:如果使用 NVIDIA GPU,确保已安装正确的 CUDA 驱动
  4. SELinux:如果遇到权限问题,可以临时设置为 permissive 模式:

    sudo setenforce 0
    sudo sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
  5. 内存限制:GPT-SoVITS 需要较多内存,建议服务器至少有 16GB RAM

现在您应该可以在 CentOS Stream 9 上成功运行 GPT-SoVITS 了。如果遇到任何问题,可以检查日志文件获取详细信息。

本文著作权由作者所有, GPT-SoVITS 收录于 日有所思,商业授权请联系作者。

添加新评论

登录