GRPC for torchserve
依赖安装
torchserve相关
pip install torchserve torch-model-archiver torch-workflow-archiver
GRPC相关
pip install -U grpcio protobuf grpcio-tools
启动torchserve
mkdir model_store
torchserve --start --ts-config ./config.properties --model-store model_store --ncs
使用 proto 文件生成 python gRPC客户端
python -m grpc_tools.protoc --proto_path=proto/ --python_out=ts_scripts --grpc_python_out=ts_scripts proto/inference.proto proto/management.proto
densenet161模型注册
python ts_scripts/torchserve_grpc_client.py register densenet161
densenet161模型推理
python ts_scripts/torchserve_grpc_client.py infer densenet161 examples/image_classifier/kitten.jpg
densenet161模型注销
python ts_scripts/torchserve_grpc_client.py unregister densenet161