Skip to content

Commit 3cf2ff3

Browse files
committed
Refactor documentation
Signed-off-by: Manjunath-A-C <[email protected]>
1 parent 2d1858d commit 3cf2ff3

File tree

5 files changed

+63
-50
lines changed

5 files changed

+63
-50
lines changed

examples/tritonserver/Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM na.artifactory.swg-devops.com/sys-pcloud-docker-local/devops/pim/base
1+
FROM quay.io/<account id>/pim:base
22

33
COPY tritonserver_config.sh /usr/bin/
44
COPY tritonserver_config.service /etc/systemd/system

examples/tritonserver/README.md

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,39 @@
33
Triton inference server can be used to serve machine learning or deep learning models like classification, regression etc on CPU/GPU platforms.
44
Triton inference server is built on top of base image [here](../../base-image/)
55

6-
## Steps to setup e2e inference flow
6+
## Build PIM triton server
7+
**Step 1: Build Base image**
8+
Follow the steps provided [here](../../base-image/README.md) to build the base image.
9+
10+
**Step 2: Build triton server PIM image**
11+
Ensure to replace the `FROM` image in [Containerfile](Containerfile) with the base image you have built before building this image.
712

8-
## Step 1: Building the images
9-
Build container image for AI example application covered in [ai-demos](https://github.com/PDeXchange/ai-demos) using [build-steps](app/README.md)
10-
To reuse the built container image, push the built image to container registry.
1113
```shell
12-
podman push <registry>/build_env
14+
podman build -t <your_registry>/pim-triton-server
15+
16+
podman push <your_registry>/pim-triton-server
1317
```
1418

15-
## Step2: Train the model
16-
Model with ONNX runtime can be trained by running the container image built in Step 1. Follow the [training steps](app/README.md)
17-
After the successful training completion, model(mode.onnx) and config(config.pbtxt) files will be available in path **<current_dir>/app/model_repository/fraud**
19+
## Steps to setup e2e inference flow
1820

19-
### Setting up PIM partition
20-
Follow this [deployer section](../../README.md#deployer-steps) to setup PIM cli, configuring your AI partition and launching it.
21+
### Step 1: Preparing the model and config file
22+
As mentioned earlier triton inference server can be used to serve any machine learning models with their respective model and configuration files stored in model repository. You can build your model and config file for your use case.
23+
To show case the e2e flow of triton inference server deployment from PIM, we will be utilising the existing application [fraud-detection](https://github.com/PDeXchange/ai-demos/tree/main/02_Fraud_Detection). Please follow below steps to build the model and config file.
2124

22-
Regarding configuration of AI application served from triton server, user need to provide generated model artifacts like model file and config file to the PIM partition as shown below in `ai.config-json` section.
23-
```ini
24-
config-json = """
25-
{
26-
"modelSource": "http://<Host/IP>/fraud_detection/model.onnx",
27-
"configSource": "http://<Host/IP>/fraud_detection/config.pbtxt"
28-
}
29-
```
30-
Both of the model files will be available in `<current_dir>/model_repository/fraud` dir on the machine wher you have trained the model. Store these files in a simple HTTP server and pass the URI path to the PIM partition like above.
25+
#### Step I: Building the image
26+
To easily train the model with the provided python application, we have provided a Containerfile with the necessary packages, environment and tools to run the python application which can train the model for you. the source files for the python application will be volume mounted during training.
27+
28+
Build the container image for AI example application covered in [ai-demos](https://github.com/PDeXchange/ai-demos) using [build-steps](app/README.md)
29+
30+
To reuse the built container image, push the built image to container registry.
31+
`podman push <registry>/build_env`
32+
33+
#### Step II: Train the model
34+
Model with ONNX runtime can be trained by running the container image built in Step I. Follow the [training steps](app/README.md)
35+
After the successful training completion, model(mode.onnx) and config(config.pbtxt) files will be available in path **<current_dir>/app/model_repository/fraud**
36+
37+
### Step 2: Store model artifacts in a model repository
38+
Store both model file(model.onnx) and config file(config.pbtxt) in a simple HTTP server
3139

3240
#### Steps to start http server and copy the model artifacts
3341
```shell
@@ -41,9 +49,23 @@ cp <current_dir>/model_repository/fraud/config.pbtxt /var/www/html/fraud_detecti
4149
cp <current_dir>/model_repository/fraud/1/model.onnx /var/www/html/fraud_detection/
4250
```
4351

44-
### Validate AI application functionality
45-
To verify AI example application served from Triton server, Apply below speicifed configurations in [config.ini](../../config.ini).
46-
Sample JSON payload is provided for fraud detection usecase. Feed the appropriate JSON payload specific to AI example app to be served from triton.
52+
### Step 3: Setting up PIM partition
53+
Follow this [deployer section](../../README.md#deployer-steps) to setup PIM cli, configuring your AI partition and launching it.
54+
55+
Regarding configuration of AI application served from triton server, user need to provide generated model artifacts like model file and config file to the PIM partition as shown below in `ai.config-json` section.
56+
```ini
57+
config-json = """
58+
{
59+
"modelSource": "http://<Host/IP>/fraud_detection/model.onnx",
60+
"configSource": "http://<Host/IP>/fraud_detection/config.pbtxt"
61+
"aiApp": "fraud_detection"
62+
}
63+
```
64+
modelSource and configSource are the URI path to the model artifacts stored on the model repository covered in Step 2. Specify name of the AI application for which model and config files need to be pulled from model repository.
65+
66+
### Step 4: Validate AI application functionality
67+
To verify AI example application served from Triton server, feed the ai.validation section with application specific REST schema like URL, headers and payload. If you have built and trained model for fraud detection usecase, apply below speicifed configurations in [config.ini](../../config.ini).
68+
4769
4870
```ini
4971
[[validation]]
@@ -114,16 +136,3 @@ Once PIM partition is deployed with triton server serving the model of configure
114136
}]
115137
}
116138
```
117-
118-
### Build PIM triton server
119-
**Step 1: Build Base image**
120-
Follow the steps provided [here](../../base-image/README.md) to build the base image.
121-
122-
**Step 2: Build triton server PIM image**
123-
Ensure to replace the `FROM` image in [Containerfile](Containerfile) with the base image you have built before building this image.
124-
125-
```shell
126-
podman build -t <your_registry>/pim-triton-server
127-
128-
podman push <your_registry>/pim-triton-server
129-
```

examples/tritonserver/app/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
Users can deploy AI workloads of their choice of model and configuration by supplying the trained model file(model.onnx) and configuration file (config.pbtxt) to http server to be used by Triton server when its run on a PIM partition.
55

66
## Fraud detection usecase with ONNX runtime
7+
### Pre-requisites
8+
Below mentioned pre-requisites are needed to build container image for fraud detection example
9+
- podman
10+
- container registry to push the built fraud detection container image
11+
- protobuf
12+
713
### Build fraud detection container image
814
The [script](build_and_train.sh) builds the base container image for the AI example applications given in [ai-demos](https://github.com/PDeXchange/ai-demos). AI application name for which container image to be built is given as an argument to the script.
915
```shell

examples/tritonserver/tritonserver.container

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RestartSec=60
99
EnvironmentFile=/etc/pim/env.conf
1010

1111
[Container]
12-
Image=na.artifactory.swg-devops.com/sys-linux-power-team-ftp3distro-docker-images-docker-local/tritonserver:latest
12+
Image=quay.io/powercloud/tritonserver:latest
1313
ContainerName=tritonserver
1414
EnvironmentFile=/etc/pim/tritonserver.conf
1515
Network=host

examples/tritonserver/tritonserver_config.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,20 @@ set -x
44

55
[ -f /etc/pim/tritonserver.conf ] || touch /etc/pim/tritonserver.conf
66

7-
# List of AI applications to be served from tritonserver
8-
ai_apps=("fraud")
7+
AI_APP=$(jq -r '.aiApp' /etc/pim/pim_config.json)
8+
echo "Application: ${AI_APP}"
99

10-
for app in "${ai_apps[@]}"; do
11-
mkdir -p /var/models/model_repository/${app}/1
10+
mkdir -p /var/models/model_repository/${AI_APP}/1
1211

13-
ONNX_MODEL_SOURCE=$(jq -r '.modelSource' /etc/pim/pim_config.json)
14-
if [[ -n "$ONNX_MODEL_SOURCE" ]]; then
15-
curl "$ONNX_MODEL_SOURCE" --output /var/models/model_repository/${app}/1/model.onnx
16-
fi
12+
ONNX_MODEL_SOURCE=$(jq -r '.modelSource' /etc/pim/pim_config.json)
13+
if [[ -n "$ONNX_MODEL_SOURCE" ]]; then
14+
curl "$ONNX_MODEL_SOURCE" --output /var/models/model_repository/${AI_APP}/1/model.onnx
15+
fi
1716

18-
CONFIG_FILE=$(jq -r '.configSource' /etc/pim/pim_config.json)
19-
if [[ -n "$CONFIG_FILE" ]]; then
20-
curl "$CONFIG_FILE" --output /var/models/model_repository/${app}/config.pbtxt
21-
fi
22-
done
17+
CONFIG_FILE=$(jq -r '.configSource' /etc/pim/pim_config.json)
18+
if [[ -n "$CONFIG_FILE" ]]; then
19+
curl "$CONFIG_FILE" --output /var/models/model_repository/${AI_APP}/config.pbtxt
20+
fi
2321

2422
var_to_add=MODEL_REPOSITORY=/var/models/model_repository
2523
sed -i "/^MODEL_REPOSITORY=.*/d" /etc/pim/tritonserver.conf && echo "$var_to_add" >> /etc/pim/tritonserver.conf

0 commit comments

Comments
 (0)