wenet环境部署及

本文详细描述了如何在Ubuntu系统上部署NVIDIA官方Kaldi镜像,包括选择不同CUDA版本的container,配置docker、conda和pip以优化环境,以及解决常见问题如安装PyTorch版本对应。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

环境部署步骤

  1. 下载镜像、生成container

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

例如: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  
  • 下载命令: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 64G \
      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 64G \
      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 64G \
      nvcr.io/nvidia/kaldi:22.01-py3 bash
    
  • 启动容器:

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

      vim ~/.bashrc 
      添加
      alias docker_connect='nvidia-docker exec -it wyr_wenet_kaldi_cuda11.6 bash'
    
      或者直接 
      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
     ( 如果conda init报错:运行 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
     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. 如果安装时总是安装CPU版本的pytorch,则可以尝试降低cudatoolkit版本
    cuda不能装太低版本的pytorch,能装比较高的pytorch
  2. 尝试手动安装(https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch中下载包)
  conda install --use-local  **.tar.bz2

下载特定cuda版本的torch,使用pip安装

# 修改最后的cu117为你想下载的就行
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
# 或者下面的
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch==1.12.0+cu116 torchvision -f https://download.pytorch.org/whl/torch_stable.html

缺点:下载速度慢;

也可以提前手动下载好:

  1. 下载需要包网址:https://download.pytorch.org/whl/torch_stable.html
    pytorch的版本号,cuda版本号,python版本号都对应好。
  2. 使用pip手动安装
pip install some_package.whl

查看conda缓存路径

  1. conda info找到下载包的临时存放地址
  2. 查看该地址下的urls.txt,找到下载地址:https://conda.anaconda.org/pytorch/linux-64/torchaudio-0.8.1-py38.tar.bz2

torch和torchvision版本对应情况查看

https://gitcode.com/pytorch/vision/overview#installation?utm_source=csdn_github_accelerator&isLogin=1

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值