GPT-SoVITS 环境搭建及应用
https://github.com/RVC-Boss/GPT-SoVITS
python 3.11
创建目录 E:\aizzz-env-dev\vits-env
创建环境 vits-env
conda create -n vits-env python=3.11
conda activate vits-env
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
python -m pip --version
安装 PyTorch 2.5.1 (CUDA 12.1 版本)
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu121
cudnn暂时说不用装 说安装torch时候就带上了 conda install -c conda-forge cudnn -y
查看cudnn版本
python -c "import torch; print('cuDNN Enabled:', torch.backends.cudnn.enabled); print('cuDNN Version:', torch.backends.cudnn.version())"
官方windows安装
conda create -n GPTSoVits python=3.10
conda activate GPTSoVits
pwsh -F install.ps1 --Device <CU126|CU128|CPU> --Source <HF|HF-Mirror|ModelScope> [--DownloadUVR5]
根据官方说明,我cuda是12.6 所以用CU1126,所以安装命令如下
pwsh -F install.ps1 --Device CU126 --Source HF-Mirror --DownloadUVR5
上面破命令导致笔记本死机3次,W~~
安装GPT-SoVITS
当前目录 (vits-env) PS E:\aizzz-env-dev\vits-env>
github 下载,命令框 有点问题,从cla-h开powershell
刚才死机了3次,改了系统自动内存管理,改成固定初始32G,最大72G内存 再试试。
注意进去后,切环境
期间还注册了一个hf,最后也没用到,就是密码要求还挺严格,普通密码都不合格
conda activate vits-env
cd E:\\aizzz-env-dev\\vits-env
git clone https://github.com/RVC-Boss/GPT-SoVITS.git
(vits-env) PS E:\aizzz-env-dev\vits-env> cd .\GPT-SoVITS\
这个命令执行就死机,换下面的方案
pwsh -F install.ps1 --Device CU126 --Source HF-Mirror --DownloadUVR5
由于上面命令死机3次,换个方法安装
根据手动安装文档:https://github.com/RVC-Boss/GPT-SoVITS/tree/main/docs/cn
pip安装git项目的依赖+ffmpeg
pip install -r extra-req.txt --no-deps
pip install -r requirements.txt (这个不用了,改下面的,因为里面对gpu的版本太高了)
pip install -r requirements.txt onnxruntime-gpu==1.18.0 gradio==3.50.2
pip uninstall -y fastapi starlette uvicorn
pip install "fastapi<0.110.0" "starlette<0.36.0" "uvicorn"
conda install ffmpeg
一个坑:如果一个库装过高版本的,直接指定老版本,不会覆盖,需要卸载再重装
pip uninstall gradio onnxruntime-gpu -y
pip install -r requirements.txt onnxruntime-gpu==1.18.0 gradio==3.50.2
下载一共3个文件,具体位置再整理
1.
第一个,整个仓库(GPT-SoVITS 主模型 放在 GPT_SoVITS/pretrained_models)
(vits-env) PS E:\aizzz-env-dev\vits-env\GPT-SoVITS\pretrained_models>git clone https://huggingface.co/lj1995/GPT-SoVITS
第2个文件(G2PW 模型 (中文必需) 解压后重命名为 G2PWModel,放入 GPT_SoVITS/text)
https://hf-mirror.com/XXXXRT/GPT-SoVITS-Pretrained/resolve/main/G2PWModel.zip
第3个文件 (UVR5 模型 (人声分离) tools/uvr5/uvr5_weights)
https://huggingface.co/lj1995/VoiceConversionWebUI/tree/main/uvr5_weights
这个比较特殊,因为是这个库的一个子目录,这个库80多个G,用git命令下hf的下不下来,所以改用hf命令下载
# 安装客户端
pip install -U huggingface_hub (这个不行,不写版本 版本太新,后面会报错)
pip install huggingface-hub==0.26.0
# 设置镜像源(国内用户推荐)
$env:HF_ENDPOINT = "https://hf-mirror.com"
# 下载整个 uvr5_weights 文件夹到本地
hf download lj1995/VoiceConversionWebUI --include "uvr5_weights/*" --local-dir ./
后面是放到相应目录,回头再看
后来又安装了几个老版本
pip install "fastapi<0.110.0" "starlette<0.36.0" "uvicorn"
pip show fastapi starlette gradio
GPT_SoVITS 这个模型目录名字很迷惑人,因为项目的叫 GPT-SoVITS,
一个是下划线,一个是中横线。我开始没反应过来。GPT_SoVITS 里面又是很复杂的结构。
check脚本
Set-Content check.py @'
import os, sys, torch, onnxruntime as ort
print('='*50)
print('1. Software Version Check')
print(f'Python: {sys.version.split()[0]}')
print(f'Torch: {torch.__version__}')
print(f'Torch CUDA Support: {torch.cuda.is_available()}')
print(f'Torch CUDA Ver: {torch.version.cuda}')
print(f'ONNX Runtime: {ort.__version__}')
print(f'ONNX Device: {ort.get_device()}')
print(f'ONNX Providers: {ort.get_available_providers()}')
print('='*50)
print('2. Key DLL Physical Path Check')
t_lib = os.path.join(os.path.dirname(torch.__file__), 'lib')
print(f'Torch lib Path: {t_lib}')
if os.path.exists(t_lib):
print(f' -> cuDNN DLLs: {[f for f in os.listdir(t_lib) if "cudnn" in f.lower() and f.endswith(".dll")]}')
print(f' -> CUDA RT DLLs: {[f for f in os.listdir(t_lib) if "cudart" in f.lower() and f.endswith(".dll")]}')
else:
print(' -> Torch lib not found!')
o_capi = os.path.join(os.path.dirname(ort.__file__), 'capi')
print(f'ONNX capi Path: {o_capi}')
print(f'System CUDA_PATH: {os.environ.get("CUDA_PATH", "Not Set")}')
print('='*50)
'@; python check.py; remove-item check.py
输出
==================================================
1. Software Version Check
Python: 3.11.15
Torch: 2.5.1+cu121
Torch CUDA Support: True
Torch CUDA Ver: 12.1
ONNX Runtime: 1.18.0
ONNX Device: GPU
ONNX Providers: ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider']
==================================================
2. Key DLL Physical Path Check
Torch lib Path: E:\CondaConfig\envs\vits-env\Lib\site-packages\torch\lib
-> cuDNN DLLs: ['cudnn64_9.dll', 'cudnn_adv64_9.dll', 'cudnn_cnn64_9.dll', 'cudnn_engines_precompiled64_9.dll', 'cudnn_engines_runtime_compiled64_9.dll', 'cudnn_graph64_9.dll', 'cudnn_heuristic64_9.dll', 'cudnn_ops64_9.dll']
-> CUDA RT DLLs: ['cudart64_12.dll']
ONNX capi Path: E:\CondaConfig\envs\vits-env\Lib\site-packages\onnxruntime\capi
System CUDA_PATH: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.4
==================================================
解释
诊断结果非常清晰!问题原因已经被我们精准锁定了:
软件版本配合:你的虚拟环境里安装的是 PyTorch 2.5.1 (CUDA 12.1),它自带的是 cuDNN 9.x (cudnn64_9.dll) 文件夹,以及 cudart64_12.dll。
ONNX Runtime-GPU 依赖冲突:你安装的是 onnxruntime-gpu==1.18.0。
根据 ONNX 官方的兼容性规范,onnxruntime-gpu==1.18.0 默认寻找并依赖的是 cuDNN 8.x (cudnn64_8.dll)。
可是,你环境里 PyTorch 2.5.1 自带的是最新的 cuDNN 9.x (cudnn64_9.dll)。
同时,由于你系统的 CUDA_PATH 指向了 CUDA\v12.4,这就导致 ONNX 乱了套,既找不到 cuDNN 8,也没能把 PyTorch 12.1 的运行时路径加载进来。
解决方案 onnxruntime-gpu==1.19.2 支持的 cuDNN 9.x
# 1. 干净地卸载当前的 onnxruntime(防止 CPU 和 GPU 版本冲突)
pip uninstall onnxruntime onnxruntime-gpu -y
# 2. 安装与你的 CUDA 12.1 / cuDNN 9 完美适配的 ONNX Runtime 版本
pip install onnxruntime-gpu==1.19.2
---------------------------------------------
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
https://pengchenggang.github.io/vuejsdev-com-github/
SMART原则:
目标必须是具体的(Specific)
目标必须是可以衡量的(Measurable)
目标必须是可以达到的(Attainable)
目标必须和其他目标具有相关性(Relevant)
目标必须具有明确的截止期限(Time-based)
生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
https://pengchenggang.github.io/vuejsdev-com-github/
SMART原则:
目标必须是具体的(Specific)
目标必须是可以衡量的(Measurable)
目标必须是可以达到的(Attainable)
目标必须和其他目标具有相关性(Relevant)
目标必须具有明确的截止期限(Time-based)

浙公网安备 33010602011771号