Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 1. Storing models
You must store your model before you can deploy it. You can store a model in an S3 bucket, URI or Open Container Initiative (OCI) containers.
1.1. Using OCI containers for model storage Link kopierenLink in die Zwischenablage kopiert!
As an alternative to storing a model in an S3 bucket or URI, you can upload models to Open Container Initiative (OCI) containers. Deploying models from OCI containers is also known as modelcars in KServe.
Using OCI containers for model storage can help you:
- Reduce startup times by avoiding downloading the same model multiple times.
- Reduce disk space usage by reducing the number of models downloaded locally.
- Improve model performance by allowing pre-fetched images.
Using OCI containers for model storage involves the following tasks:
- Storing a model in an OCI image.
Deploying a model from an OCI image by using either the user interface or the command line interface. To deploy a model by using:
- The user interface, see Deploying models on the single-model serving platform.
- The command line interface, see Deploying a model stored in an OCI image by using the CLI.
1.2. Storing a model in an OCI image Link kopierenLink in die Zwischenablage kopiert!
You can store a model in an OCI image. The following procedure uses the example of storing a MobileNet v2-7 model in ONNX format.
Prerequisites
- You have a model in the ONNX format. The example in this procedure uses the MobileNet v2-7 model in ONNX format.
- You have installed the Podman tool.
Procedure
In a terminal window on your local machine, create a temporary directory for storing both the model and the support files that you need to create the OCI image:
cd $(mktemp -d)
cd $(mktemp -d)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
models
folder inside the temporary directory:mkdir -p models/1
mkdir -p models/1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis example command specifies the subdirectory
1
because OpenVINO requires numbered subdirectories for model versioning. If you are not using OpenVINO, you do not need to create the1
subdirectory to use OCI container images.Download the model and support files:
DOWNLOAD_URL=https://github.com/onnx/models/raw/main/validated/vision/classification/mobilenet/model/mobilenetv2-7.onnx curl -L $DOWNLOAD_URL -O --output-dir models/1/
DOWNLOAD_URL=https://github.com/onnx/models/raw/main/validated/vision/classification/mobilenet/model/mobilenetv2-7.onnx curl -L $DOWNLOAD_URL -O --output-dir models/1/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
tree
command to confirm that the model files are located in the directory structure as expected:tree
tree
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
tree
command should return a directory structure similar to the following example:. ├── Containerfile └── models └── 1 └── mobilenetv2-7.onnx
. ├── Containerfile └── models └── 1 └── mobilenetv2-7.onnx
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a Docker file named
Containerfile
:Note-
Specify a base image that provides a shell. In the following example,
ubi9-micro
is the base container image. You cannot specify an empty image that does not provide a shell, such asscratch
, because KServe uses the shell to ensure the model files are accessible to the model server. - Change the ownership of the copied model files and grant read permissions to the root group to ensure that the model server can access the files. OpenShift runs containers with a random user ID and the root group ID.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Specify a base image that provides a shell. In the following example,
Use
podman build
commands to create the OCI container image and upload it to a registry. The following commands use Quay as the registry.NoteIf your repository is private, ensure that you are authenticated to the registry before uploading your container image.
podman build --format=oci -t quay.io/<user_name>/<repository_name>:<tag_name> . podman push quay.io/<user_name>/<repository_name>:<tag_name>
podman build --format=oci -t quay.io/<user_name>/<repository_name>:<tag_name> . podman push quay.io/<user_name>/<repository_name>:<tag_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow