Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add torchserve custom server with pv storage #1182

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Torchserve with external storage

For running torchserve with external storage, the model archive files and config.properties should be copied to the storage.
jagadeeshi2i marked this conversation as resolved.
Show resolved Hide resolved

The storage mount to ```/mnt/models``` directory.

## Folder structure

```json
├──config.properties
├── model-store
│   ├── mnist.mar
| ├── densenet161.mar
```

The entrypoint should be modified, to start torchserve with config.properties in ```/mnt/models``` path.

## Create PV and PVC

This document uses amazonEBS PV

### Create PV

Edit volume id in pv.yaml file

```bash
kubectl apply -f pv.yaml
```

Expected Output

```bash
persistentvolume/model-pv-volume created
```

### Create PVC

```bash
kubectl apply -f pvc.yaml
jagadeeshi2i marked this conversation as resolved.
Show resolved Hide resolved
```

Expected Output

```bash
persistentvolumeclaim/model-pv-claim created
```

### Create PV Pod

```bash
kubectl apply -f pvpod.yaml
```

Expected Output

```bash
pod/model-store-pod created
```

Generate marfile from [here](https://github.com/pytorch/serve/tree/master/examples/image_classifier/mnist)

### Copy mar file and config properties to storage

Copy Marfile

```bash
kubectl exec --tty pod/model-store-pod -- mkdir /pv/model-store/
kubectl cp mnist.mar model-store-pod:/pv/model-store/mnist.mar
```

Copy config.properties

```bash
kubectl exec --tty pod/model-store-pod -- mkdir /pv/config/
kubectl cp config.properties model-store-pod:/pv/config/config.properties
```

### Delete pv pod

Since amazon EBS provide only ReadWriteOnce mode

## Create the InferenceService

In the `torchserve-custom-pv.yaml` file edit the container image with your Docker image and add your pv storage.

Apply the CRD

```bash
kubectl apply -f torchserve-custom-pv.yaml
```

Expected Output

```bash
$inferenceservice.serving.kubeflow.org/torchserve-custom-pv created
```
12 changes: 12 additions & 0 deletions docs/samples/custom/torchserve/torchserve-custom-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: "serving.kubeflow.org/v1beta1"
kind: "InferenceService"
metadata:
name: "torchserve-custom-pv"
spec:
predictor:
containers:
- image: {username}/torchserve:latest
name: kfserving-container
env:
- name: STORAGE_URI
value: "pvc://model-pv-claim" # The storage mounts to /mnt/models