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

[WIP] Add Dockerfile for modelmesh-minio-examples image #300

Closed
Show file tree
Hide file tree
Changes from all 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
44 changes: 44 additions & 0 deletions minio_examples/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2023 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Using specific tag for now, there was some reason newer minio versions didn't work
FROM quay.io/cloudservices/minio:RELEASE.2021-06-17T00-10-46Z.hotfix.35a0912ff as minio-examples

EXPOSE 9000

USER root

RUN useradd -u 1000 -g 0 modelmesh
RUN mkdir -p /data1/modelmesh-example-models
RUN chown -R 1000:0 /data1
Copy link
Member

@ckadner ckadner Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as Nick pointed out, doing a chown after the COPY layers causes the final Docker image to be about 86 MB larger.

$ docker images | grep "modelmesh-minio-examples"

kserve/modelmesh-minio-examples   chown_before_cp      15eb3d6f159e   45 minutes ago   438MB
kserve/modelmesh-minio-examples   chown_after_cp       ad16135035ff   2 hours ago      524MB
kserve/modelmesh-minio-examples   cp-chown             7579fe5ccdea   57 minutes ago   438MB
quay.io/cloudservices/minio       RELEASE.2021-06-17   1377bf686561   11 months ago    351MB
kserve/modelmesh-minio-examples   latest               c773b3dc52e5   11 months ago    382MB
kserve/modelmesh-minio-examples   v0.9.0               c773b3dc52e5   11 months ago    382MB

I reverted to COPY --chown 1000:0 ... in commit 33c2f17

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


COPY --chown=1000:0 sklearn /data1/modelmesh-example-models/sklearn/
COPY --chown=1000:0 lightgbm /data1/modelmesh-example-models/lightgbm/
COPY --chown=1000:0 onnx /data1/modelmesh-example-models/onnx/
COPY --chown=1000:0 pytorch /data1/modelmesh-example-models/pytorch/
COPY --chown=1000:0 xgboost /data1/modelmesh-example-models/xgboost/
COPY --chown=1000:0 tensorflow /data1/modelmesh-example-models/tensorflow/
COPY --chown=1000:0 keras /data1/modelmesh-example-models/keras/

USER modelmesh


# Image with additional models used in the FVTs
FROM minio-examples as minio-fvt

USER root

COPY --chown=1000:0 fvt /data1/modelmesh-example-models/fvt/

USER modelmesh
66 changes: 66 additions & 0 deletions minio_examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# ModelMesh MinIO Examples

This MinIO Docker image contains example models. When ModelMesh is deployed with
the `--quickstart` flag, the example models are deployed via this image.

## Build the image

From inside the `minio_examples` directory build the docker image:

```sh
docker build --target minio-examples -t kserve/modelmesh-minio-examples:latest .
```

**Note**: When ModelMesh is deployed with the `--fvt` flag then the `modelmesh-minio-dev-examples`
image will be deployed instead. To build it, run the docker build command with the
`minio-fvt` target:

```sh
docker build --target minio-fvt -t kserve/modelmesh-minio-dev-examples:latest .
```

Push the newly built images to DockerHub:

```shell
docker push kserve/modelmesh-minio-examples:latest
docker push kserve/modelmesh-minio-dev-examples:latest
```

## Start the container

Start a "modelmesh-minio-examples" container:

```sh
docker run --rm --name "modelmesh-minio-examples" \
-u "1000" \
-p "9000:9000" \
-e "MINIO_ACCESS_KEY=AKIAIOSFODNN7EXAMPLE" \
-e "MINIO_SECRET_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
kserve/modelmesh-minio-examples:latest server /data1
```

## Test the image using the MinIO client

Install the [MinIO client](https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart), `mc`.

Create an alias `localminio` for an local instance:

```sh
mc alias set localminio http://localhost:9000 AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
```

List objects in the instance's bucket:

```sh
mc ls -r localminio/modelmesh-example-models/
```

### Stop and remove the docker container

To shut down the "modelmesh-minio-examples" docker container run the following
commands:

```sh
docker stop "modelmesh-minio-examples"
docker rm "modelmesh-minio-examples"
```
Binary file added minio_examples/fvt/keras/mnist.h5
Binary file not shown.
Empty file.
3 changes: 3 additions & 0 deletions minio_examples/fvt/lightgbm/mushroom-dup/model-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"implementation": "mlserver_lightgbm.LightGBMModel"
}
2,005 changes: 2,005 additions & 0 deletions minio_examples/fvt/lightgbm/mushroom-dup/model.bst

Large diffs are not rendered by default.

2,005 changes: 2,005 additions & 0 deletions minio_examples/fvt/lightgbm/mushroom.bst

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions minio_examples/fvt/lightgbm/mushroom/model-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"implementation": "mlserver_lightgbm.LightGBMModel"
}
2,005 changes: 2,005 additions & 0 deletions minio_examples/fvt/lightgbm/mushroom/model.bst

Large diffs are not rendered by default.

Binary file not shown.
Binary file added minio_examples/fvt/onnx/onnx-mnist/mnist-8.onnx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23 changes: 23 additions & 0 deletions minio_examples/fvt/onnx/onnx-test-model/config.pbtxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
platform: "onnxruntime_onnx"
max_batch_size: 32
input [
{
name: "input"
data_type: TYPE_FP32
dims: [3, 224, 224]
}
]
output [
{
name: "output"
data_type: TYPE_FP32
dims: [3]
label_filename: "test_labels.txt"
}
]
instance_group [
{
kind: KIND_AUTO
count: 1
}
]
3 changes: 3 additions & 0 deletions minio_examples/fvt/onnx/onnx-test-model/test_labels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class1
class2
class3
Binary file not shown.
2 changes: 2 additions & 0 deletions minio_examples/fvt/onnx/onnx-withschema-new/config.pbtxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
backend: "onnxruntime"
max_batch_size: 0
Binary file not shown.
2 changes: 2 additions & 0 deletions minio_examples/fvt/onnx/onnx-withschema/config.pbtxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
backend: "onnxruntime"
max_batch_size: 0
16 changes: 16 additions & 0 deletions minio_examples/fvt/onnx/schema/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"inputs": [
{
"name": "Input3",
"datatype": "FP32",
"shape": [1, 1, 28, 28]
}
],
"outputs": [
{
"name": "Plus214_Output_0",
"datatype": "FP32",
"shape": [1, 10]
}
]
}
Binary file added minio_examples/fvt/openvino/mnist-dup/mnist.bin
Binary file not shown.
79 changes: 79 additions & 0 deletions minio_examples/fvt/openvino/mnist-dup/mnist.mapping
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0"?>
<mapping>
<map>
<framework name="Input3" output_port_id="Input3" />
<IR name="Input3" output_port_id="0" />
</map>
<map>
<framework name="Parameter5" output_port_id="Parameter5" />
<IR name="Parameter5" output_port_id="0" />
</map>
<map>
<framework name="Convolution28" output_port_id="Convolution28_Output_0" />
<IR name="Convolution28" output_port_id="2" />
</map>
<map>
<framework name="Parameter6" output_port_id="Parameter6" />
<IR name="Parameter6" output_port_id="0" />
</map>
<map>
<framework name="Plus30" output_port_id="Plus30_Output_0" />
<IR name="Plus30" output_port_id="2" />
</map>
<map>
<framework name="ReLU32" output_port_id="ReLU32_Output_0" />
<IR name="ReLU32" output_port_id="1" />
</map>
<map>
<framework name="Pooling66" output_port_id="Pooling66_Output_0" />
<IR name="Pooling66" output_port_id="1" />
</map>
<map>
<framework name="Parameter87" output_port_id="Parameter87" />
<IR name="Parameter87" output_port_id="0" />
</map>
<map>
<framework name="Convolution110" output_port_id="Convolution110_Output_0" />
<IR name="Convolution110" output_port_id="2" />
</map>
<map>
<framework name="Parameter88" output_port_id="Parameter88" />
<IR name="Parameter88" output_port_id="0" />
</map>
<map>
<framework name="Plus112" output_port_id="Plus112_Output_0" />
<IR name="Plus112" output_port_id="2" />
</map>
<map>
<framework name="ReLU114" output_port_id="ReLU114_Output_0" />
<IR name="ReLU114" output_port_id="1" />
</map>
<map>
<framework name="Pooling160" output_port_id="Pooling160_Output_0" />
<IR name="Pooling160" output_port_id="1" />
</map>
<map>
<framework name="Pooling160_Output_0_reshape0_shape" output_port_id="Pooling160_Output_0_reshape0_shape" />
<IR name="Pooling160_Output_0_reshape0_shape" output_port_id="0" />
</map>
<map>
<framework name="Times212_reshape0" output_port_id="Pooling160_Output_0_reshape0" />
<IR name="Times212_reshape0" output_port_id="2" />
</map>
<map>
<framework name="Times212_reshape1" output_port_id="Parameter193_reshape1" />
<IR name="Times212_reshape1" output_port_id="0" />
</map>
<map>
<framework name="Times212" output_port_id="Times212_Output_0" />
<IR name="Times212" output_port_id="2" />
</map>
<map>
<framework name="Parameter194" output_port_id="Parameter194" />
<IR name="Parameter194" output_port_id="0" />
</map>
<map>
<framework name="Plus214_Output_0" output_port_id="Plus214_Output_0" />
<IR name="Plus214_Output_0" output_port_id="2" />
</map>
</mapping>
Loading