1、docker镜像下载
下载链接:https://catalog.ngc.nvidia.com/orgs/nvidia/containers/tritonserver/tags
或者直接 docker pull nvcr.io/nvidia/tritonserver:23.01-py3
2、克隆wenet项目
git clone https://github.com/wenet-e2e/wenet.git
3、下载预训练模型,下载链接
https://github.com/wenet-e2e/wenet/blob/main/docs/pretrained_models.en.md
模型文件主要有以下四个文件:
- final.pt 模型参数文件
- global_cmvn 归一化单数文件
- train.yaml 训练配置文件
- words.txt 字表映射文件
4、模型转onnx格式
model_dir =./ 20210618_u2pp_conformer_exp模型实际位置
onnx_model_dir = onnx模型导出位置
python3 wenet/bin/export_onnx_gpu.py --config=$model_dir/train.yaml --checkpoint=$model_dir/final.pt --cmvn_file=$model_dir/global_cmvn --ctc_weight=0.5 --output_onnx_dir=$onnx_model_dir --fp16
onnx格式模型有以下几个文件
- config.yaml 模型配置文件
- decoder_fp16.onnx
- decode.onnx
- encoder_fp16.onnx
- encoder.onnx
- global_cmvn 归一化单数文件
- train.yaml 训练配置文件
- words.txt 字表映射文件
5、配置文件拷贝
cp $model_dir/words.txt $model_dir/train.yaml $onnx_model_dir/
cp $model_dir/words.txt $onnx_model_dir/unit.txt
6、启动容器:
docker run --gpus '"device=0"' -itd -p 8000:8000 -p 8001:8001 -p 8002:8002 --shm-size=1g --ulimit memlock=-1 --name triton_server nvcr.io/nvidia/tritonserver:23.01-py3
7、模型脚本拷贝到容器或启动模型时做路径映射
docker cp ./wenet/runtime/gpu/model_repo_stateful 容器ID:/ws/model_repo/
docker cp ./output_onnx_model 容器ID:/ws/onnx_model/
docker cp /home/ai_data2/jaxyu/wenet/runtime/gpu/scripts 容器ID:/workspace/
8、容器环境搭建或基于triton_server重新build一个镜像
- apt-get update
- apt-get -y install swig
- apt-get -y install python3-dev
- apt-get install -y cmake
- pip3 install torch=2.0.1 torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple/
- pip3 install -v kaldifeat pyyaml onnx -i https://pypi.tuna.tsinghua.edu.cn/simple/
- cd /workspace
- git clone https://github.com/Slyne/ctc_decoder.git && cd ctc_decoder/swig && bash setup.sh
- export PYTHONPATH=/root/.local/lib/python3.8/site-packages:/root/.local/lib/python3.8/site-packages/swig_decoders-1.1-py3.8-linux-x86_64.egg:$PYTHONPATH
9、启动服务
cd /workspace
sh ./scripts/convert_start_server.sh
10、报错信息处理
报错一:No module named 'swig_decoders'
export PYTHONPATH=/root/.local/lib/python3.8/site-packages:/root/.local/lib/python3.8/site-packages/swig_decoders-1.1-py3.8-linux-x86_64.egg:$PYTHONPATH
报错二:FileNotFoundError: [Errno 2] No such file or directory: '/ws/onnx_model/units.txt'
cp /ws/onnx_model/words.txt /ws/onnx_model/units.txt
标签:triton,asr,--,onnx,model,txt,wenet,dir From: https://www.cnblogs.com/jax-/p/17776737.html