wenet环境部署

  1. 下载镜像、生成container

原始nvidia 提供镜像的网站(包含kaldi):

  • https://docs.nvidia.com/deeplearning/frameworks/kaldi-release-notes/rel_20-03.html#rel_20-03

  • 本次采用的是21.02版本,包含如下内容:

    Ubuntu 20.04 including Python 3.8
    NVIDIA CUDA 11.2.0 including cuBLAS 11.3.1
    NVIDIA cuDNN 8.1.0
    NVIDIA NCCL 2.8.4 (optimized for NVLink™)
    MLNX_OFED 5.1
    OpenMPI 4.0.5
    Nsight Compute 2020.3.0.18
    Nsight Systems 2020.4.3.7
    TensorRT 7.2.2

  • 130服务器更新为 22.01 版本

Ubuntu 20.04 including Python 3.8
NVIDIA CUDA 11.6.0
cuBLAS 11.8.1.74
NVIDIA cuDNN 8.3.2.44
NVIDIA NCCL 2.11.4 (optimized for NVLink™)
rdma-core 36.0
NVIDIA HPC-X 2.10
OpenMPI 4.1.2rc4+
OpenUCX 1.12.0
GDRCopy 2.3
Nsight Systems 2021.5.2.53
TensorRT 8.2.2
SHARP 2.5
DALI 1.9

  • 下载命令:docker pull nvcr.io/nvidia/kaldi:22.01-py3

    下载之后,docker images就可以看到这个镜像了。

  • 使用如下命令创建容器:

      NV_GPU=0,1 nvidia-docker run -itd -P \
      --name wyr_wenet_kaldi_cuda11.2 \
      --mount type=bind,source=/home/work/wangyaru05,target=/home/work/wangyaru05 \
      -v /opt/wfs1/aivoice:/opt/wfs1/aivoice \
      --net host \
      --shm-size 8G \
      nvcr.io/nvidia/kaldi:21.02-py3 bash
    
      NV_GPU=0,1,2,3,4,5,6,7 nvidia-docker run -itd -P \
      --name wyr_wenet_kaldi_cuda11.2 \
      --mount type=bind,source=/home/work/wangyaru05,target=/home/work/wangyaru05 \
      -v /opt/wfs1/aivoice:/opt/wfs1/aivoice \
      --net host \
      --shm-size 8G \
      nvcr.io/nvidia/kaldi:21.02-py3 bash
    

NV_GPU=0,1,2,3,4,5,6,7 nvidia-docker run -itd -P
–name wyr_wenet_kaldi_cuda11.6
–mount type=bind,source=/home/work/wangyaru05,target=/home/work/wangyaru05
-v /opt/wfs1/aivoice:/opt/wfs1/aivoice
–net host
–shm-size 8G
nvcr.io/nvidia/kaldi:22.01-py3 bash

  • 启动容器:

      docker container start wyr_wenet_kaldi_cuda11.6
    
  • 进入容器:

      nvidia-docker exec -it wyr_wenet_kaldi_cuda11.6 bash
    
  • 进入容器快捷命令:

    vim ~/.bashrc

      alias wyr_docker_connect='nvidia-docker exec -it wyr_wenet_kaldi_cuda11.6 bash'
    
  • 查看ubantu版本

      cat /etc/issue
    
  1. 配置pip镜像

    vim ~/.pip/pip.conf
    添加如下内容

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

  1. 配置conda镜像

vim ~/.condarc

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

  1. 下载wenet代码

     git clone --branch v1.0.0 https://github.com/wenet-e2e/wenet.git
    
     git clone https://github.com/wenet-e2e/wenet.git
    
  2. 创建conda虚拟环境

    下载conda

     wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
    

    安装conda

     bash Anaconda3-2021.05-Linux-x86_64.sh
    

    添加anaconda3环境变量

     vim ~/.bashrc
     添加: export PATH=$PATH:/root/anaconda3/bin
    

    安装wenet虚拟环境

     conda create -n wenet python=3.8
    
     source activate
    
     conda activate wenet
    
  3. 安装依赖 pytorch torchvision torchaudio cudatoolkit

     pip install -r requirements.txt
    
     conda install pytorch torchvision torchaudio cudatoolkit=11.2 -c pytorch -c conda-forge
     conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
    
  • 问题是:nvcc 版本是11.2 但是官方pytorch安装例子里只有11.1,使用以上命令安装11.2对应版本的时候总是装CPU版本的

    • 尝试解决方法:据说安装11.1也是可以的,只能试一下
      conda install pytorch=1.8.1 torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge

        conda install pytorch=1.8.1 torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
      

conda install pytorch torchvision torchaudio cudatoolkit=11.5 -c pytorch -c conda-forge

	成功了✅

conda install pytorch=1.12.1 torchvision torchaudio cudatoolkit=11.3 -c pytorch -c conda-forge

  1. 下载1.0.0代码

git clone --branch v1.0.0 https://github.com/wenet-e2e/wenet.git

  1. conda环境配置
  • conda create -n wenet python=3.8

  • conda activate wenet

    报错 需要conda init:解决方法 source activate

  • pip install -r requirements.txt

  • conda install pytorch torchvision torchaudio cudatoolkit=10.1 -c pytorch -c conda-forge

    本来cudatoolkit的版本是11.1, 这里本地的是10.1,所以改为了10.1.

    通过安装命令可以看到,pytorch的版本是1.8.1, torchaudio的版本是0.8.1, cudatoolkit的版本是10.1.243,都没有问题。唯一有问题的有两个地方:一个是网上有cuda和pytorhc版本的对应关系,总是显示pytorch版本1.7.0需要11.0的cuda版本。可能是cuda不能装太低版本的pytorch,能装比较高的pytorch。

    安装时间非常长,于是改了conda的镜像。

    channels:

    • defaults
      show_channel_urls: true
      default_channels:

    • https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main

    • https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r

    • https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
      custom_channels:
      conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

      安装会很快。

      另外查了一下官网的是在哪下载的,通过conda info找到了下载包的临时存放地址,通过查看urls.txt看到了下载地址:https://conda.anaconda.org/pytorch/linux-64/torchaudio-0.8.1-py38.tar.bz2

  1. pip镜像源配置文件

vim ~/.pip/pip.conf
添加如下内容

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

你可能感兴趣的:(语音识别)