admin 管理员组

文章数量: 887629

KAN-TTS搭建SAMBERT个性化语音合成开发环境

  • 1、下载源码和预训练模型
    • 1.1 安装Git 和 LFS支持
    • 1.2 下载KAN-TTS源码
    • 1.3 下载预训练模型
  • 2、配置conda安装源
    • 2.1 查看conda源配置
    • 2.2 命令增加源
    • 2.3 删除源配置
    • 2.4 直接编辑配置文件
    • 2.5 独立设置pip命令源
  • 3、创建开发环境
    • 3.1 创建环境maas
    • 3.2 遇到pytorch_wavelets 模块报错 GnuTLS recv error (-110)
      • 3.2.1 方法1-重新编译Git安装OpenSSL版本
        • 3.2.1.1 安装编译git所需依赖库
        • 3.2.1.2 切换到编译目录
        • 3.2.1.3 下载git的源码
        • 3.2.1.4 修改Gnutls库为OpenSSL库依赖
        • 3.2.1.5 编译安装Git
      • 3.2.2 方法2-用git单独安装pytorch_wavelets
        • 3.2.2.1 禁用安装pytorch_wavelets 模块
        • 3.2.2.2 手动安装pytorch_wavelets 模块
  • 4、错误处理
    • 4.1 SoX could not be found!
    • 4.2 ONNXRuntime
      • 4.2.1 [ONNXRuntimeError] : 7 : INVALID_PROTOBUF
      • 4.2.2 import onnxruntime
      • 4.2.3 Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession.
    • 4.3 sm_89 is not compatible with the current PyTorch installation.
      • 4.3.1 重新安装CUDA Toolkit 11.8
      • 4.3.2 虚拟环境下重新安装PyTorch匹配cuda 11.7
      • 4.3.3 PyTorch支持CUDA版本匹配测试
    • 4.4 Could not load library libcudnn_cnn_infer.so.x
      • 4.4.1 Could not load library libcudnn_cnn_infer.so.8
      • 4.4.2 ImportError: libffi.so.7: cannot open shared object file: No such file or directory
    • 4.5 多卡训练/分布式训练报错MKL_THREADING_LAYER=INTEL
    • 4.6 推理错误
      • 4.6.1 model_dir没用绝对路径 filelist = os.listdir(ckpt_path) FileNotFoundError: [Errno 2] No such file or directory
    • 4.7 kantts命令训练错误
      • 4.7.1 subprocess.CalledProcessError: Command '['git', 'rev-parse', 'HEAD']' returned non-zero exit status 128.
      • 4.7.1.1 原因1:没有用git命令拉取,而是直接下载解压安装
      • 4.7.1.1 原因2:不小心删除了.git仓库配置目录
      • 4.7.2 se model loading error!!!

1、下载源码和预训练模型

1.1 安装Git 和 LFS支持

安装Git
sudo apt install git

Git LFS(Large File Storage, 大文件存储)
sudo apt-get install git-lfs
git lfs install

curl 16 Error:

error: RPC failed; curl 16 Error in the HTTP2 framing layer
fatal: expected flush after ref listing
  • 强制git使用HTTP 1.1
    git config --global http.version HTTP/1.1
  • 想要设置回HTTP2
    git config --global http.version HTTP/2

1.2 下载KAN-TTS源码

跳转到项目目录
cd ~/msai

msai是我的ai项目目录

下载源码并跳转到源码目录

git clone https://github/alibaba-damo-academy/KAN-TTS.git
cd KAN-TTS

1.3 下载预训练模型

git clone https://www.modelscope/damo/speech_personal_sambert-hifigan_nsf_tts_zh-cn_pretrain_16k.git

2、配置conda安装源

2.1 查看conda源配置

conda config --show-sources

2.2 命令增加源

conda config --add channels https://pypi.tuna.tsinghua.edu/simple

2.3 删除源配置

删除指定源
conda config --remove channels https://pypi.tuna.tsinghua.edu/simple
删除所有自定义源 还原默认源
conda config --remove-key channels

2.4 直接编辑配置文件

sudo vim /home/你的用户名/.condarc

channels:
  - defaults
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu/anaconda/cloud
default_channels:
  - https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu/anaconda/pkgs/msys2
show_channel_urls: True

清理源索引缓存让新配置生效
conda clean -i

2.5 独立设置pip命令源

pip config set global.index-url https://pypi.tuna.tsinghua.edu/simple

Writing to /home/fb/.config/pip/pip.conf

3、创建开发环境

3.1 创建环境maas

创建名为maas的python开发环境
conda env create -f environment.yaml

3.2 遇到pytorch_wavelets 模块报错 GnuTLS recv error (-110)

原因是git版本使用了GnuTLS库,不是OpenSSL

Collecting git+https://github/fbcotter/pytorch_wavelets.git (from -r /mnt/d/develop/Ubuntu/kan-tts/condaenv.s5y8fuxa.requirements.txt (line 19))
  Cloning https://github/fbcotter/pytorch_wavelets.git to /tmp/pip-req-build-utwg371g

Pip subprocess error:
  Running command git clone --filter=blob:none --quiet https://github/fbcotter/pytorch_wavelets.git /tmp/pip-req-build-utwg371g
  fatal: unable to access 'https://github/fbcotter/pytorch_wavelets.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.
  error: subprocess-exited-with-error

  × git clone --filter=blob:none --quiet https://github/fbcotter/pytorch_wavelets.git /tmp/pip-req-build-utwg371g did not run successfully.
  │ exit code: 128
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git clone --filter=blob:none --quiet https://github/fbcotter/pytorch_wavelets.git /tmp/pip-req-build-utwg371g did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

failed

CondaEnvException: Pip failed

3.2.1 方法1-重新编译Git安装OpenSSL版本

重新编译Git从GnuTLS版本到OpenSSL版本

3.2.1.1 安装编译git所需依赖库
sudo apt-get install build-essential fakeroot dpkg-dev
sudo apt-get build-dep git
sudo apt-get install libcurl4-openssl-dev
sudo apt install libssl-dev
3.2.1.2 切换到编译目录
cd ~
mkdir src-git
cd src-git
3.2.1.3 下载git的源码

apt-get source git

(base) fb@VP01:~/src-git$ apt-get source git
Reading package lists... Done
E: You must put some 'deb-src' URIs in your sources.list

这是deb-src源码地址被注释掉了,以提高apt update速度,我们需要开启才能下载git的源码

备份源列表
sudo cp /etc/apt/sources.list /etc/apt/sources.list.back

修改源列表,去年deb-src前面的#注释
sudo vim /etc/apt/sources.list

# See http://help.ubuntu/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu/ubuntu/ jammy main restricted
deb-src http://archive.ubuntu/ubuntu/ jammy main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu/ubuntu/ jammy-updates main restricted
deb-src http://archive.ubuntu/ubuntu/ jammy-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu/ubuntu/ jammy universe
deb-src http://archive.ubuntu/ubuntu/ jammy universe
deb http://archive.ubuntu/ubuntu/ jammy-updates universe
deb-src http://archive.ubuntu/ubuntu/ jammy-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu/ubuntu/ jammy multiverse
deb-src http://archive.ubuntu/ubuntu/ jammy multiverse
deb http://archive.ubuntu/ubuntu/ jammy-updates multiverse
deb-src http://archive.ubuntu/ubuntu/ jammy-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://archive.ubuntu/ubuntu/ jammy-backports main restricted universe multiverse

deb http://security.ubuntu/ubuntu/ jammy-security main restricted
deb-src http://security.ubuntu/ubuntu/ jammy-security main restricted
deb http://security.ubuntu/ubuntu/ jammy-security universe
deb-src http://security.ubuntu/ubuntu/ jammy-security universe
deb http://security.ubuntu/ubuntu/ jammy-security multiverse
deb-src http://security.ubuntu/ubuntu/ jammy-security multiverse

更新源列表
sudo apt-get update

重新下载git源码
apt-get source git

3.2.1.4 修改Gnutls库为OpenSSL库依赖

进入git源码目录
cd git-2.34.1

(base) fb@VP01:~/src-git$ ll
total 7240
drwxr-xr-x  3 fb fb    4096 Apr 10 00:11 ./
drwxr-x--- 13 fb fb    4096 Apr  9 21:15 ../
drwxr-xr-x 28 fb fb   20480 Apr 10 00:11 git-2.34.1/
-rw-r--r--  1 fb fb  753396 Feb 15 02:53 git_2.34.1-1ubuntu1.8.debian.tar.xz
-rw-r--r--  1 fb fb    2927 Feb 15 02:53 git_2.34.1-1ubuntu1.8.dsc
-rw-r--r--  1 fb fb 6623760 Jan 25  2022 git_2.34.1.orig.tar.xz
(base) fb@VP01:~/src-git$ cd git-2.34.1
(base) fb@VP01:~/src-git/git-2.34.1$

不知道是 2.x.x,
可以用通配符进入第一个匹配目录

cd git-2.*.*/

也可以用ll列出详细目录名称

ll

使用 sed 命令将 debian/control 中的 gnutls 库改为 openssl 库
sed -i -- 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/' ./debian/control

删除 test 选项
sed -i -- '/TEST\s*=\s*test/d' ./debian/rules

3.2.1.5 编译安装Git

开始编译
dpkg-buildpackage -rfakeroot -b -uc -us

报错 dpkg-checkbuilddeps: error

dpkg-checkbuilddeps: error: Unmet build dependencies: libz-dev gettext libpcre2-dev | libpcre3-dev libexpat1-dev subversion libsvn-perl libyaml-perl tcl libhttp-date-perl | libtime-parsedate-perl libcgi-pm-perl libmailtools-perl cvs cvsps libdbd-sqlite3-perl unzip libio-pty-perl debhelper-compat (= 10) dh-exec (>= 0.7) dh-apache2 asciidoc (>= 8.6.10) xmlto docbook-xsl
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)

对策:安装缺失的包
sudo apt install libz-dev gettext libpcre2-dev libexpat1-dev subversion libsvn-perl libyaml-perl tcl libhttp-date-perl libcgi-pm-perl libmailtools-perl cvs cvsps libdbd-sqlite3-perl unzip libio-pty-perl debhelper-compat dh-exec dh-apache2 asciidoc xmlto docbook-xsl

再次编译
dpkg-buildpackage -rfakeroot -b -uc -us

报错

/home/fb/anaconda3/bin/python3: No module named asciidoc
make[2]: Leaving directory '/home/fb/src-git/git-2.34.1/Documentation'
make[1]: *** [debian/rules:84: override_dh_auto_build-indep] Error 2
make: *** [debian/rules:55: build] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2

对策:安装缺失的包
pip install asciidoc

再次编译
dpkg-buildpackage -rfakeroot -b -uc -us

安装
sudo dpkg -i ../git_*ubuntu*.deb

成功把Git改造为OpenSSL版本,回到Kan-tts项目目录创建maas虚拟环境

(base) fb@VP01:~/msai/kan-tts$ conda env create -f environment.yaml
Collecting package metadata (repodata.json): done
Solving environment: done

Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: / By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia/cuda/eula/index.html

done
Installing pip dependencies: - Ran pip subprocess with arguments:
['/home/fb/anaconda3/envs/maas/bin/python', '-m', 'pip', 'install', '-U', '-r', '/mnt/d/develop/Ubuntu/kan-tts/condaenv.2wsxxqkp.requirements.txt', '--exists-action=b']
Pip subprocess output:
Looking in indexes: https://pypi.tuna.tsinghua.edu/simple/
Looking in links: https://modelscope.oss-cn-beijing.aliyuncs/releases/repo.html
Collecting git+https://github/fbcotter/pytorch_wavelets.git (from -r /mnt/d/develop/Ubuntu/kan-tts/condaenv.2wsxxqkp.requirements.txt (line 19))
  Cloning https://github/fbcotter/pytorch_wavelets.git to /tmp/pip-req-build-fccm4w7t
  Resolved https://github/fbcotter/pytorch_wavelets.git to commit 9a0c507f04f43c5397e384bb6be8340169b2fd9a
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting appnope==0.1.3
  Using cached https://pypi.tuna.tsinghua.edu/packages/41/4a/381783f26df413dde4c70c734163d88ca0550a1361cb74a1c68f47550619/appnope-0.1.3-py2.py3-none-any.whl (4.4 kB)
Collecting backcall==0.2.0
  Using cached https://pypi.tuna.tsinghua.edu/packages/4c/1c/ff6546b6c12603d8dd1070aa3c3d273ad4c07f5771689a7b69a550e8c951/backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Collecting cython==0.29.30
  Using cached https://pypi.tuna.tsinghua.edu/packages/db/de/5e1a3f20487b6ae400f1b40a5a056be37da62239488d92fa29318f9a8755/Cython-0.29.30-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.9 MB)
Collecting dataclasses==0.6
  Using cached https://pypi.tuna.tsinghua.edu/packages/26/2f/1095cdc2868052dd1e64520f7c0d5c8c550ad297e944e641dbf1ffbb9a5d/dataclasses-0.6-py3-none-any.whl (14 kB)
Collecting future==0.18.2
  Using cached future-0.18.2-py3-none-any.whl
Collecting greenlet==1.1.2
  Using cached https://pypi.tuna.tsinghua.edu/packages/aa/e0/d6e21c642a477fc97aa667c64c8100fe4a63dd39e9b2dc3faafcfd03bef0/greenlet-1.1.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (150 kB)
Collecting ipdb
  Using cached https://pypi.tuna.tsinghua.edu/packages/0c/4c/b075da0092003d9a55cf2ecc1cae9384a1ca4f650d51b00fc59875fe76f6/ipdb-0.13.13-py3-none-any.whl (12 kB)
Collecting ipython
  Using cached https://pypi.tuna.tsinghua.edu/packages/7c/6a/1f1365f4bf9fcb349fcaa5b61edfcefa721aa13ff37c5631296b12fab8e5/ipython-7.34.0-py3-none-any.whl (793 kB)
Collecting jedi==0.18.1
  Using cached https://pypi.tuna.tsinghua.edu/packages/b3/0e/836f12ec50075161e365131f13f5758451645af75c2becf61c6351ecec39/jedi-0.18.1-py2.py3-none-any.whl (1.6 MB)
Collecting matplotlib-inline==0.1.3
  Using cached https://pypi.tuna.tsinghua.edu/packages/a6/2d/2230afd570c70074e80fd06857ba2bdc5f10c055bd9125665fe276fadb67/matplotlib_inline-0.1.3-py3-none-any.whl (8.2 kB)
Collecting msgpack==1.0.4
  Using cached https://pypi.tuna.tsinghua.edu/packages/d4/d5/18808999054f3c633bf3ff808a652b329a26083dea6bd2386e2aec4ffee0/msgpack-1.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (299 kB)
Collecting parso==0.8.3
  Using cached https://pypi.tuna.tsinghua.edu/packages/05/63/8011bd08a4111858f79d2b09aad86638490d62fbf881c44e434a6dfca87b/parso-0.8.3-py2.py3-none-any.whl (100 kB)
Collecting pexpect==4.8.0
  Using cached https://pypi.tuna.tsinghua.edu/packages/39/7b/88dbb785881c28a102619d46423cb853b46dbccc70d3ac362d99773a78ce/pexpect-4.8.0-py2.py3-none-any.whl (59 kB)
Collecting pickleshare==0.7.5
  Using cached https://pypi.tuna.tsinghua.edu/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
Collecting prompt-toolkit==3.0.30
  Using cached https://pypi.tuna.tsinghua.edu/packages/b0/8f/09a88160539a1164de562809f8b1d0a36dc1f9d8c6473f4b71ebed17b953/prompt_toolkit-3.0.30-py3-none-any.whl (381 kB)
Collecting ptyprocess==0.7.0
  Using cached https://pypi.tuna.tsinghua.edu/packages/22/a6/858897256d0deac81a172289110f31629fc4cee19b6f01283303e18c8db3/ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Collecting pygments==2.12.0
  Using cached https://pypi.tuna.tsinghua.edu/packages/5c/8e/1d9017950034297fffa336c72e693a5b51bbf85141b24a763882cf1977b5/Pygments-2.12.0-py3-none-any.whl (1.1 MB)
Collecting pysptk
  Using cached pysptk-0.2.0-cp37-cp37m-linux_x86_64.whl
Collecting sox
  Using cached https://pypi.tuna.tsinghua.edu/packages/3f/67/1810e9a69956eb236967b7174c11fd8d8c2cdab051509286f72e6c7e147e/sox-1.4.1-py2.py3-none-any.whl (39 kB)
Collecting toml==0.10.2
  Using cached https://pypi.tuna.tsinghua.edu/packages/44/

本文标签: 环境 语音合成 KAN ModelScope SAMBERT