This document is relevant for: Inf1

Torchserve Example#

 1#!/bin/bash
 2
 3MODEL_STORE=/opt/ml/model
 4TS_CONFIG=/home/model-server/config.properties
 5MODEL_PATH=""
 6
 7while getopts ":m:t:" opt; do
 8  case $opt in
 9    m) MODEL_PATH="$OPTARG"
10    ;;
11    t) TS_CONFIG="$OPTARG"
12    ;;
13    \?) echo "Invalid option -$OPTARG" >&2
14    ;;
15  esac
16done
17
18printf "Model path: %s\n" "$MODEL_PATH"
19printf "TS_CONFIG: %s\n" "$TS_CONFIG"
20# Start the Model Server
21if [[ -z "$MODEL_PATH" ]]; then
22  torchserve --start --ts-config /home/model-server/config.properties --model-store /opt/ml/model &
23else
24  torchserve --start --ts-config $TS_CONFIG --models $MODEL_PATH &
25fi
26status=$?
27if [ $status -ne 0 ]; then
28  echo "Failed to start TF Model Server: $status"
29  exit $status
30fi

This document is relevant for: Inf1