智能语音大模型FishSpeech1-5部署记录

0 阅读1分钟

背景

FishSpeech是一个开源的智能语音大模型,目前已经到1.5版本,能够提供比较好的TTS文字转语音,语音复刻等功能。但是需要注意的是,FishSpeech模型协议是CC-BY-NC-SA-4.0,无法直接商用。

CC - BY - NC - SA 4.0 是一种知识共享许可协议,全称为 “署名 - 非商业性使用 - 相同方式共享 4.0 国际”(Creative Commons Attribution - NonCommercial - ShareAlike 4.0 International)

部署步骤

1. 准备机器

机器配置GPU推荐采用A10 GPU 及以上(24GB,Ampere 架构,具备 6144 个 CUDA 核心,单精度浮点TFLOPS 35.6)

2. 安装显卡驱动

可以参考阿里云(手动安装):help.aliyun.com/zh/egs/user-guide/install-a-gpu-driver-on-a-gpu-accelerated-compute-optimized-linux-instance

注意Nvidia GPU 驱动版本可以使用最新的570(2025年4月22日),对应cuda版本12.8,可以正常使用

驱动可以通过cuda包解压得到,只安装驱动即可,也可以使用操作系统包管理工具安装。

 wget https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_570.124.06_linux.run

chmod +x cuda_12.8.1_570.124.06_linux.run 
./cuda_12.8.1_570.124.06_linux.run --extract=/root/cuda128

cd cuda128
./NVIDIA-Linux-x86_64-570.124.06.run

验证驱动安装成功:

(py3) root@iZ8vb7rgz0erhq04yqfvmoZ:~/cuda128# nvidia-smi
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.124.06             Driver Version: 570.124.06     CUDA Version: 12.8     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  Tesla T4                       Off |   00000000:00:07.0 Off |                    0 |
| N/A   43C    P0             27W /   70W |    1847MiB /  15360MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A           89296      C   python                                 1844MiB |
+-----------------------------------------------------------------------------------------+

3. 下载模型文件

huggingface-cli download fishaudio/fish-speech-1.5 --local-dir checkpoints/fish-speech-1.5

4. 下载代码文件

如果可以连接github,可以使用gitclone直接获得,如果没有,可以本地clone之后再上传到服务器上。

5. 进行安装

首先解压相关代码,然后执行下面命令进行安装,实际执行建议安装conda,用来创建指定版本的python虚拟环境。

apt install python3-venv
python3 -m venv py3
source py3/bin/activate

#切换到虚拟环境
cd fish-speech
pip3 install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu121

apt install libsox-dev ffmpeg 

apt install build-essential cmake libasound-dev portaudio19-dev libportaudio2  libportaudiocpp0


#最终安装
pip3 install -e .[stable]

export GRADIO_SERVER_NAME="0.0.0.0"

python tools/run_webui.py --compile --half 


重启命令
source py3/bin/activate
cd fish-speech-main/
python tools/run_webui.py --compile

nohup python -u tools/run_webui.py --compile >>run.log 2>&1 &

6. 开通网络访问

如果是公有云,给对应端口添加安全组访问策略。 如例子中使用8080和7860端口。

7. 启动脚本

为了方便管理,增加了2个启动脚本,分别用来启动webui和api_server。 用来启动UI端。

#start_webui.sh
#!/bin/bash
# Activate the Python virtual environment
source py3/bin/activate
# Enter the project directory
cd fish-speech-1.5
# Set the environment variable
export GRADIO_SERVER_NAME="0.0.0.0"
# Start the project silently in the background
nohup python -u tools/run_webui.py --compile >> run_webui.log 2>&1 &
# Output the prompt message
echo "webui starting ..."

用来启动API服务。

#start_api.sh 

#!/bin/bash
# Activate the Python virtual environment
source py3/bin/activate
# Enter the project directory
cd fish-speech-1.5
# Start the project silently in the background
nohup python -u tools/api_server.py --compile --listen 0.0.0.0:8028 >> run_api.log 2>&1 &
# Output the prompt message
echo "api server starting ..."

8. 关闭程序

关闭程序简单使用查询服务端口,然后kill的方式。

netstat -anp | grep 7860 
kill -9 <pid>

netstat -anp | grep 8028
kill -9 <pid>

问题和解决

  1. 阿里云部分机器安装显卡驱动不成功。报错如内核不匹配,GPL不匹配等。 确认是否是共享GPU,共享GPU只能安装GRID驱动,版本最高为470,对应cuda版本11.4。

  2. webui无法在公网访问 设置export GRADIO_SERVER_NAME="0.0.0.0"

  3. API_SERVER无法在公网访问,以及自定义端口。 这种情况看日志可以发现启动使用的127.0.0.1。 可以添加 --listen 0.0.0.0:8080 ,设置监听地址和端口。

  4. 生成速度较慢 如果本身显卡资源足够,可以通过添加 --half --compile 参数进行加速。但不建议使用half,可能影响效果。 另外实践中,4090显卡加入-- compile之后,能达到260 token/s的执行速度。A10公有云独享GPU能达到160 token/s,供参考。