下载ESPNet:https://github.com/espnet/espnet
这里分享一个下载GITHUB项目的代理点,速度能快上很多:http://gitd.cc/
官方安装文档:https://espnet.github.io/espnet/installation.html
ESPNet的搭建过程网上有很多,他们在搭建的时候,会再另行安装Python或者anaconda。但是对于电脑上已经有了环境的人来说个人感觉并非最优的方式。以下给出个人方式:
解压,进入tools文件夹。
先查一下cuda的路径:
whereis cuda
然后指向该路径:
sudo sh ./setup_cuda_env.sh (你的路径)
按照官方文档,设置Python环境:
我已经有了Python,但我没有anaconda,我选择B,从系统Python设置venv,也就是从用系统的Python创建一个新的虚拟环境。 cd <espnet-root>/tools
./setup_venv.sh $(command -v python3)
开始安装ESPnet,在安装过程中需要下载很多库文件。众所周知,直接安装的话,下载很慢,很容易超时报错。
我们来修改一下脚本文件,把PIP源换到清华(其他的也可以):
打开makefile文件,在第125、126行处:
pytorch.done: activate_python.sh
. ./activate_python.sh && python3 -m pip install numpy --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple some-package # Workaround for "ImportError: numpy.core.multiarray failed to import"
. ./activate_python.sh && python3 -m pip install $(PIP_PYTORCH) -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
touch pytorch.done
在136行处:
espnet.done: pytorch.done conda_packages.done
. ./activate_python.sh && python3 -m pip install -e .. -i https://pypi.tuna.tsinghua.edu.cn/simple some-package # Install editable mode by default
touch espnet.done
在141-149行处:
ifneq ($(strip $(NO_CUPY)),)
. ./activate_python.sh && python3 -m pip install $(PIP_CHAINER) -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
else
# Precompiled cupy==6.0.0 for python>=3.8 is not provided
. ./activate_python.sh && \
if python3 -c "import sys; from distutils.version import LooseVersion as L; assert L(sys.version) < L('3.8')" 2>&1 /dev/null; then \
python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package $(PIP_CHAINER) cupy-cuda$(CUDA_VERSION_WITHOUT_DOT)==$(CHAINER_VERSION) ; \
else \
python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package $(PIP_CHAINER) cupy==$(CHAINER_VERSION); \
fi
然后执行安装,我装的是1.2的pytorch
make TH_VERSION=1.2
可能会有少许漏掉的,如果有,自己发掘下,加上 -i 源 就好了。
再不行就直接自己在网上下载库的whl文件,然后放到虚拟环境的库文件里。
最后一步测试安装:
make check_install