🍏 torchserve安装
# pip安装
```
pip install torchserve==0.4.2 torch-model-archiver==0.4.2
```
>i torch-workflow-archiver暂时没有安装,没用到
>i 不是说不能安装其他版本,只是镜像里使用0.4.2版本而已
# Docker安装
```
docker pull pytorch/torchserve:0.4.2-gpu
```
# 基本流程
torchserve是一种部署框架
torchserve是一种使用Java和Python语言编写的软件包,软件包中含有三个命令行工具:torchserve, torch-model-archiver, torch-workflow-archiver.
torchserve,用于启动torchserve服务,需要mar包
torch-model-archiver,将服务所需的问价打包成mar包
torch-workflow-archiver不清楚用途
下面以行为识别模型部署为例
## 打包成mar包
```txt
torch-model-archiver --model-name tsm_action \
--version 1.0 \
--serialized-file tsm_action.pth \
--export-path model-store \
--extra-files label.txt,tsm_r50_video_1x1x8_50e_kinetics400_rgb.py,tsm_r50.py,sgd_tsm_50e.py,default_runtime.py \
--handler handler.py -f
```
## 运行torchserve服务
```txt
torchserve --start --model-store model-store --models tsm_action=tsm_action.mar
```
>i 上述参数中--export-path和--model-store不建议修改
>i 没有特殊情况mar包命令和模型名称保持一致