上一个 docker 容器让我安装奇奇怪怪的库的时候,动了一个系统库的文件,然后之间用的 ohmyzsh 给崩了……正好上一个容器忘了多开几个端口,这次重新搭建一个环境,把零零碎碎的东西记录下来。
首先搭建好终端环境,不然之后 miniconda 安装之后再切 shell 环境还要有别的操作。
sudo apt install zsh
这里的安装,我之前在自己的 BLOG 网站有所记录:
https://haulyn5.cn/2021/10/26/ohmyzsh-installation/https://haulyn5.cn/2021/10/26/ohmyzsh-installation/
下载地址:
Miniconda — conda documentationhttps://docs.conda.io/en/latest/miniconda.html#linux-installers我是 Ubuntu 的环境,下载了 Miniconda3 Linux 64-bit 。下载之后得到一个 bash 文件,可以检查一下 hash。
sha256sum Miniconda3-latest-Linux-x86_64.sh
输出结果
78f39f9bae971ec1ae7969f0516017f2413f17796670f7040725dd83fcff5689 Miniconda3-latest-Linux-x86_64.sh
可以看到与官网提供的校验值一致。
zsh Miniconda3-latest-Linux-x86_64.sh
注意用什么 shell 这里就写什么,比如使用 bash 就修改 zsh 为 bash。然后会弹出一大段的 License,读完之后输入 yes 同意,然后回车确认安装路径,然后 yes 执行 conda init 。然后重新启动终端,就 OK 了。然后更新一下 conda。
conda update conda
然后如果需要换源,参考
conda换源 - 知乎Windows下 1. conda源更换为清华源Anaconda 是一个用于科学计算的 Python 发行版,支持 Linux, Mac, Windows, 包含了众多流行的科学计算、数据分析的 Python 包。 Anaconda 安装包可以到 https://mirrors.tuna.tsi…https://zhuanlan.zhihu.com/p/87123943如果将环境从旧机器上转移到新机器上,参考:
Anaconda | Moving Conda EnvironmentsConda is known as a package manager for Python and R packages produced by Anaconda, Inc. and conda-forge, the open-source community for conda Python…https://www.anaconda.com/blog/moving-conda-environments
旧机器:(-f 指定输出文件名,-n 指定env名)
conda env export -f conda-coqui-environment.yml -n coqui
新机器:
conda env create -f conda_coqui_env.yml
我这里的 yml 内容是:
name: coqui
channels:
- nvidia
- conda-forge
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=4.5=1_gnu
- argon2-cffi=21.3.0=pyhd3eb1b0_0
- argon2-cffi-bindings=21.2.0=py38h7f8727e_0
- asttokens=2.0.5=pyhd3eb1b0_0
- attrs=21.4.0=pyhd3eb1b0_0
- backcall=0.2.0=pyhd3eb1b0_0
- bc=1.07.1=h516909a_0
- blas=1.0=mkl
- bleach=4.1.0=pyhd3eb1b0_0
- brotli=1.0.9=he6710b0_2
- brotlipy=0.7.0=py38h27cfd23_1003
- ca-certificates=2022.4.26=h06a4308_0
- certifi=2022.6.15=py38h06a4308_0
- cffi=1.15.0=py38hd667e15_1
- charset-normalizer=2.0.4=pyhd3eb1b0_0
- conda-package-handling=1.7.3=py38h27cfd23_1
- cryptography=36.0.0=py38h9ce1e76_0
- cudatoolkit=11.1.74=h6bb024c_0
- cycler=0.11.0=pyhd3eb1b0_0
- dbus=1.13.18=hb2f20db_0
- debugpy=1.5.1=py38h295c915_0
- decorator=5.1.1=pyhd3eb1b0_0
- defusedxml=0.7.1=pyhd3eb1b0_0
- executing=0.8.3=pyhd3eb1b0_0
- expat=2.4.4=h295c915_0
- fontconfig=2.13.1=h6c09931_0
- fonttools=4.25.0=pyhd3eb1b0_0
- freetype=2.11.0=h70c0345_0
- gflags=2.2.2=he1b5a44_1004
- giflib=5.2.1=h7b6447c_0
- glib=2.69.1=h4ff587b_1
- gst-plugins-base=1.14.0=h8213a91_2
- gstreamer=1.14.0=h28cd5cc_2
- icu=58.2=he6710b0_3
- importlib_metadata=4.8.2=hd3eb1b0_0
- intel-openmp=2021.4.0=h06a4308_3561
- ipykernel=6.9.1=py38h06a4308_0
- ipython=8.1.1=py38h06a4308_0
- ipython_genutils=0.2.0=pyhd3eb1b0_1
- jedi=0.18.1=py38h06a4308_1
- jpeg=9e=h7f8727e_0
- jupyter_client=7.1.2=pyhd3eb1b0_0
- jupyter_core=4.9.2=py38h06a4308_0
- jupyterlab_pygments=0.1.2=py_0
- lcms2=2.12=h3be6417_0
- ld_impl_linux-64=2.35.1=h7274673_9
- libblas=3.9.0=12_linux64_mkl
- libfaiss=1.7.1=cuda111hf54f04a_1_cuda
- libffi=3.3=he6710b0_2
- libgcc-ng=11.2.0=h1234567_1
- libgfortran-ng=7.5.0=ha8ba4b0_17
- libgfortran4=7.5.0=ha8ba4b0_17
- libgomp=11.2.0=h1234567_1
- liblapack=3.9.0=12_linux64_mkl
- libpng=1.6.37=hbc83047_0
- libprotobuf=3.19.1=h4ff587b_0
- libsodium=1.0.18=h7b6447c_0
- libstdcxx-ng=12.1.0=ha89aaad_16
- libtiff=4.2.0=h85742a9_0
- libuuid=1.0.3=h7f8727e_2
- libuv=1.40.0=h7b6447c_0
- libwebp=1.2.2=h55f646e_0
- libwebp-base=1.2.2=h7f8727e_0
- libxcb=1.15=h7f8727e_0
- libxml2=2.9.12=h03d6c58_0
- lz4-c=1.9.3=h295c915_1
- matplotlib-base=3.5.1=py38ha18d171_1
- mistune=0.8.4=py38h7b6447c_1000
- mkl=2021.4.0=h06a4308_640
- mkl-service=2.4.0=py38h7f8727e_0
- mkl_fft=1.3.1=py38hd3c417c_0
- mkl_random=1.2.2=py38h51133e4_0
- munkres=1.1.4=py_0
- nb_conda=2.2.1=py38h06a4308_1
- nb_conda_kernels=2.3.1=py38h06a4308_0
- nbclient=0.5.11=pyhd3eb1b0_0
- nbformat=5.1.3=pyhd3eb1b0_0
- ncurses=6.3=h7f8727e_2
- ninja=1.10.2=py38hd09550d_3
- notebook=6.4.8=py38h06a4308_0
- numexpr=2.8.3=py38h807cd23_0
- openssl=1.1.1p=h5eee18b_0
- packaging=21.3=pyhd3eb1b0_0
- pandocfilters=1.5.0=pyhd3eb1b0_0
- parso=0.8.3=pyhd3eb1b0_0
- pcre=8.45=h295c915_0
- pexpect=4.8.0=pyhd3eb1b0_3
- pickleshare=0.7.5=pyhd3eb1b0_1003
- prometheus_client=0.13.1=pyhd3eb1b0_0
- ptyprocess=0.7.0=pyhd3eb1b0_2
- pure_eval=0.2.2=pyhd3eb1b0_0
- pycosat=0.6.3=py38h7b6447c_1
- pycparser=2.21=pyhd3eb1b0_0
- pygments=2.11.2=pyhd3eb1b0_0
- pyopenssl=22.0.0=pyhd3eb1b0_0
- pyqt=5.9.2=py38h05f1152_4
- pysocks=1.7.1=py38h06a4308_0
- python=3.8.12=h12debd9_0
- python-dateutil=2.8.2=pyhd3eb1b0_0
- python_abi=3.8=2_cp38
- pytorch=1.10.1=py3.8_cuda11.1_cudnn8.0.5_0
- pytorch-mutex=1.0=cuda
- pyzmq=22.3.0=py38h295c915_2
- qt=5.9.7=h5867ecd_1
- readline=8.1.2=h7f8727e_1
- ruamel_yaml=0.15.100=py38h27cfd23_0
- seaborn=0.11.2=pyhd3eb1b0_0
- send2trash=1.8.0=pyhd3eb1b0_1
- setuptools=58.0.4=py38h06a4308_0
- sip=4.19.13=py38h295c915_0
- six=1.16.0=pyhd3eb1b0_1
- sqlite=3.37.2=hc218d9a_0
- stack_data=0.2.0=pyhd3eb1b0_0
- tensorboardx=2.2=pyhd3eb1b0_0
- tk=8.6.11=h1ccaba5_0
- torchaudio=0.10.1=py38_cu111
- tornado=6.1=py38h27cfd23_0
- tqdm=4.62.3=pyhd3eb1b0_1
- traitlets=5.1.1=pyhd3eb1b0_0
- tsnecuda=3.0.1=cuda111py38h1f61482_0
- typing-extensions=3.10.0.2=hd3eb1b0_0
- typing_extensions=3.10.0.2=pyh06a4308_0
- urllib3=1.26.8=pyhd3eb1b0_0
- wcwidth=0.2.5=pyhd3eb1b0_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.2.5=h7b6447c_0
- yaml=0.2.5=h7b6447c_0
- zeromq=4.3.4=h2531618_0
- zipp=3.7.0=pyhd3eb1b0_0
- zlib=1.2.11=h7f8727e_4
- zstd=1.4.9=haebb681_0
- pip:
- absl-py==1.0.0
- antlr4-python3-runtime==4.8
- anyascii==0.3.1
- appdirs==1.4.4
- audioread==2.1.9
- babel==2.10.3
- backports-zoneinfo==0.2.1
- beautifulsoup4==4.10.0
- bitarray==2.6.0
- bottleneck==1.3.2
- cachetools==5.0.0
- chardet==4.0.0
- ci-sdr==0.0.0
- click==8.0.3
- colorama==0.4.4
- configargparse==1.5.3
- coqpit==0.0.16
- ctc-segmentation==1.7.1
- cython==0.29.28
- d2l==0.17.3
- dateparser==1.1.1
- distance==0.1.3
- docker-pycreds==0.4.0
- docopt==0.6.2
- editdistance==0.5.2
- einops==0.4.0
- entrypoints==0.4
- espnet-model-zoo==0.1.7
- espnet-tts-frontend==0.0.3
- fairscale==0.4.5
- fastdtw==0.3.4
- ffmpeg-python==0.2.0
- filelock==3.6.0
- flask==2.2.2
- fsspec==2022.8.2
- future==0.18.2
- g2p-en==2.1.0
- gdown==4.3.0
- gitdb==4.0.9
- gitpython==3.1.26
- google-auth==2.6.0
- google-auth-oauthlib==0.4.6
- grpcio==1.44.0
- gruut==2.2.3
- gruut-ipa==0.13.0
- gruut-lang-cs==2.0.0
- gruut-lang-de==2.0.0
- gruut-lang-en==2.0.0
- gruut-lang-es==2.0.0
- gruut-lang-fr==2.0.2
- gruut-lang-it==2.0.0
- gruut-lang-nl==2.0.2
- gruut-lang-pt==2.0.0
- gruut-lang-ru==2.0.0
- gruut-lang-sv==2.0.0
- h5py==3.6.0
- huggingface-hub==0.4.0
- humanfriendly==10.0
- hydra-core==1.0.7
- idna==2.10
- importlib-metadata==4.11.1
- importlib-resources==5.4.0
- inflect==5.6.0
- ipywidgets==7.6.5
- itsdangerous==2.1.2
- jaconv==0.3
- jamo==0.4.1
- jieba==0.42.1
- jinja2==3.0.3
- joblib==1.1.0
- jsonlines==1.2.0
- jsonschema==4.4.0
- jupyter==1.0.0
- jupyter-console==6.4.0
- jupyterlab-widgets==1.0.2
- kaldiio==2.17.2
- kiwisolver==1.3.2
- librosa==0.8.0
- llvmlite==0.38.0
- markdown==3.3.6
- markupsafe==2.1.1
- matplotlib==3.3.3
- matplotlib-inline==0.1.3
- mecab-python3==1.0.5
- mir-eval==0.7
- morfessor==2.0.6
- musdb==0.4.0
- museval==0.4.0
- nara-wpe==0.0.7
- nbconvert==6.4.2
- nest-asyncio==1.5.4
- networkx==2.8.6
- nltk==3.7
- nnmnkwii==0.1.1
- num2words==0.5.12
- numba==0.55.1
- numpy==1.21.6
- oauthlib==3.2.0
- omegaconf==2.0.6
- pandas==1.2.2
- pathtools==0.1.2
- pillow==9.0.1
- pip==22.2.2
- pooch==1.6.0
- portalocker==2.4.0
- promise==2.3
- prompt-toolkit==3.0.28
- protobuf==3.19.4
- psutil==5.9.0
- pyaml==21.10.1
- pyasn1==0.4.8
- pyasn1-modules==0.2.8
- pynndescent==0.5.7
- pyparsing==3.0.7
- pypinyin==0.44.0
- pyrsistent==0.18.1
- pysbd==0.3.4
- pysptk==0.1.20
- pystoi==0.3.3
- python-crfsuite==0.9.8
- pytorch-ranger==0.1.1
- pytorch-wpe==0.0.1
- pytz==2021.3
- pytz-deprecation-shim==0.1.0.post0
- pyworld==0.2.10
- pyyaml==6.0
- qtconsole==5.2.2
- qtpy==2.0.1
- regex==2022.1.18
- requests==2.25.1
- requests-oauthlib==1.3.1
- resampy==0.2.2
- rsa==4.8
- sacrebleu==2.0.0
- scikit-learn==1.0.2
- scipy==1.8.0
- sentencepiece==0.1.96
- sentry-sdk==1.5.5
- shortuuid==1.0.8
- simplejson==3.17.6
- smmap==5.0.0
- soundfile==0.10.3.post1
- soupsieve==2.3.1
- stempeg==0.2.3
- tabulate==0.8.9
- tensorboard==2.8.0
- tensorboard-data-server==0.6.1
- tensorboard-plugin-wit==1.8.1
- termcolor==1.1.0
- terminado==0.13.2
- testpath==0.6.0
- threadpoolctl==3.1.0
- torch-complex==0.2.1
- torch-optimizer==0.3.0
- torch-tb-profiler==0.4.0
- torchinfo==1.6.3
- trainer==0.0.14
- tts==0.8.0
- typeguard==2.13.3
- tzdata==2022.2
- tzlocal==4.2
- umap-learn==0.5.1
- unidecode==1.3.2
- unidic-lite==1.0.8
- wandb==0.12.10
- webencodings==0.5.1
- werkzeug==2.2.2
- widgetsnbextension==3.5.2
- yaspin==2.1.0
- youtube-dl==2021.12.17
prefix: /root/miniconda3/envs/coqui
接下来就是漫长的等待了。然后 2分钟后报错,说 pytorch的依赖解析有问题。
emmm 好吧,只好手动安了,参照我之前的博客进行。
conda 配置深度学习环境 pytorch transformers_Haulyn5的博客-CSDN博客最近想学习一下 Huggingface 的 Transformers 库的使用,需要重新搭建一个虚拟环境,做简单记录方便之后工作。这次搭建主要是平时测试和玩的环境,不考虑为某某应用兼容用低版本,看一眼 python 的版本。 差不多是一年一个小版本号呀,3.7 再有一年停止维护了,打算用 3.8 了。create 命令创建环境。这里 miniconda 的安装,还有 channel 的设置就不赘述了。提示 conda 需要更新,顺手更新一下 conda。❯ python --versionPyhttps://blog.csdn.net/Haulyn5/article/details/125486589
conda install cudatoolkit=11.1 -c nvidia
注意这里的安装,他读条会显示一直是 0%,不要担心,等着就好了,大约几分钟会一下子跳到 100% 。
我这里用时 4 分钟不到。
conda install pytorch=1.10.1 -c pytorch
pip install TTS
但是没想到程序下载了半个小时后,又在下 torch,太奇怪了。ctrl+c 取消,重新下载。
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install TTS
没想到又要重新下载,不过这次速度快很多,也还好。最后用了 10 分钟共计。
很玄学,pip 把我安装的 1.10.1 的 torch 卸载了,而在上一个环境安装时没有。新安装的 '1.12.1+cu102' 居然可以用 CUDA,玄学了。
测试 tts 命令,再次报错。sndfile library not found
Traceback (most recent call last):
File "~/miniconda3/envs/dev38/bin/tts", line 5, in
from TTS.bin.synthesize import main
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/TTS/bin/synthesize.py", line 12, in
from TTS.utils.synthesizer import Synthesizer
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/TTS/utils/synthesizer.py", line 14, in
from TTS.utils.audio import AudioProcessor
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/TTS/utils/audio/__init__.py", line 1, in
from TTS.utils.audio.processor import AudioProcessor
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/TTS/utils/audio/processor.py", line 3, in
import librosa
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/librosa/__init__.py", line 211, in
from . import core
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/librosa/core/__init__.py", line 6, in
from .audio import * # pylint: disable=wildcard-import
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/librosa/core/audio.py", line 8, in
import soundfile as sf
File "~/miniconda3/envs/dev38/lib/python3.8/site-packages/soundfile.py", line 142, in
raise OSError('sndfile library not found')
OSError: sndfile library not found
参照 https://www.jianshu.com/p/cc1a10a79cfa, 解决方法:
sudo apt-get install libsndfile1
然后再次测试
tts --text "Hello, this is Tom, a cat who never catch mice." --out_path ~/tmp.wav
ok 可以使用。