You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TensorFlowTTS在Google Colab适配TensorFlow2.8+版本的安装问题求助

在Google Colab中解决TensorFlowTTS安装失败问题

问题说明

尝试用以下命令安装TensorFlowTTS时遇到版本不兼容和编译错误:

import os
os.system("rm -rf TensorFlowTTS")
!git clone https://github.com/TensorSpeech/TensorFlowTTS.git
os.chdir("TensorFlowTTS")
!pip install .
os.chdir("..")
import sys
sys.path.append("TensorFlowTTS/")

首先触发的错误是找不到指定版本的tensorflow-gpu:

ERROR: Could not find a version that satisfies the requirement tensorflow-gpu==2.7.0 (from tensorflowtts) (from versions: 2.8.0rc0, 2.8.0rc1, 2.8.0, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.9.0rc0,  2.9.0rc1, 2.9.0rc2, 2.9.0, 2.9.1, 2.9.2, 2.9.3, 2.10.0rc0, 2.10.0rc1, 2.10.0rc2, 2.10.0rc3, 2.10.0, 2.10.1, 2.11.0rc0, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.12.0)
ERROR: No matching distribution found for tensorflow-gpu==2.7.0

Google Colab默认用TensorFlow 2.12,尝试降级到2.8或文档推荐的2.6都失败,后续调整tensorflow-gpu版本后又出现numba编译错误:

error: subprocess-exited-with-error
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for numba (setup.py) ... error
ERROR: Failed building wheel for numba

需要在Colab环境完成安装,用于训练多语言模型。

可行解决办法

办法1:修改依赖并兼容安装

  1. 先卸载现有TensorFlow,安装兼容的2.9.3版本:
!pip uninstall -y tensorflow tensorflow-gpu
!pip install tensorflow==2.9.3
  1. 克隆仓库并进入目录:
!rm -rf TensorFlowTTS
!git clone https://github.com/TensorSpeech/TensorFlowTTS.git
%cd TensorFlowTTS
  1. 修改setup.py里的依赖要求,适配当前TF版本并指定numba的兼容版本:
!sed -i 's/tensorflow-gpu==2.7.0/tensorflow>=2.9.0/' setup.py
!sed -i 's/numba>=0.53.0/numba==0.56.4/' setup.py
  1. 安装本地包,加上参数避免依赖隔离导致的问题:
!pip install . --no-build-isolation
  1. 验证安装:
import sys
sys.path.append("/content/TensorFlowTTS")
from tensorflow_tts.inference import TFAutoModel
print("TensorFlowTTS安装成功")

办法2:直接安装预编译包

  1. 安装兼容的TensorFlow版本:
!pip install tensorflow==2.9.3
  1. 安装预编译的TensorFlowTTS包,再补全依赖:
!pip install tensorflow-tts==0.11.0 --no-deps
!pip install -r https://raw.githubusercontent.com/TensorSpeech/TensorFlowTTS/master/requirements.txt --force-reinstall
  1. 验证版本:
import tensorflow_tts
print(f"TensorFlowTTS版本:{tensorflow_tts.__version__}")

办法3:使用预配置镜像(Colab可选)

如果Colab允许使用Docker,可直接拉取官方预配置镜像:

!docker pull tenspeech/tensorflowtts:latest-gpu
!docker run -it --gpus all tenspeech/tensorflowtts:latest-gpu

注:Colab中使用Docker需要调整权限,更适合本地环境,但也可尝试。


内容的提问来源于stack exchange,提问作者Moseich

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 08:26:36