Working with custom images
Create a custom Docker image with libraries and packages that are required for your deployments, then use the custom image to deploy your Watson Machine Learning assets.
You can build custom images based on deployment runtime images available in IBM Watson Machine Learning. The images contain preselected open source libraries and selected IBM libraries. By building custom images, you can optimize the standard software configuration of a runtime for your application needs. You can also use custom images in air-gapped environments with requirements that forbid to expose any operations to the internet.
Note: The way that you create a custom image depends on whether you are building an image for Python-based models and functions or an SPSS image. For details, refer to Creating a custom image.
Notes:
These custom image types are not compatible with 4.5.0 or later releases of Cloud Pak for Data:
- Images that were created in Cloud Pak for Data version 3.5
- Images that were created before the 4.0.6 release of Cloud Pak for Data 4.x
If your custom image belongs to one of these categories, you must rebuild your image. Use the new base images published in the current release.
Rebuilding an existing image
- Download the latest base image.
- Rebuild the image with required libraries.
- Upload the rebuilt image to local Cloud Pak for Data registry.
- Update the existing runtime-definition file with the new image.
- Perform online or batch scoring on the existing deployment.
Note: If your deployed model uses a custom image that was created in one of previous releases of Cloud Pak for Data, you don't have to create a fresh deployment.
Training the model
If you want to train your SPSS model that uses a custom image, you can start with Building custom images to install ODBC drivers.
If you want to train your Python models or functions that use a custom image, you can start with Creating and training with custom image for Watson Studio. The Watson Studio image cannot be used for deployment in Watson Machine Learning, though. For deployment, create a custom image for Watson Machine Learning, as described in Creating a Watson Machine Learning custom image.
Supported frameworks for custom images
This table lists frameworks that are supported by the latest runtime image (wml-deployment-runtime-py39-1
).
Framework | Versions | Online | Batch |
---|---|---|---|
Scikit-learn | 1.0 | Yes | Yes |
XGBoost | 1.5 | Yes | Yes |
TensorFlow | 2.7 | Yes | Yes |
PyTorch | 1.10 | Yes | Yes |
Python function | 0.1 | Yes | Programmatic only Inline payload only |
Python scripts | 1.0 | No | Yes |
This table lists the supported frameworks for the SPSS base image under wml-deployment-runtime-spss-server.json
:
Framework | Versions | Online | Batch |
---|---|---|---|
SPSS | 18.2 | No | Yes |
Creating and registering a custom image
Required role: You must be a Cloud Pak for Data cluster administrator to create and register a custom image.
Follow these steps to create and register a custom image:
- Preparing to build a new image
- Adding customizations and building a new image
- Pushing the image to the container server
- Changing and uploading the configuration file
Using the image for deployments
To use the custom image, follow these steps:
- Save the trained model that you want to deploy with the custom image to Watson Machine Learning
- Deploy the model
This sample Python notebook shows how to use the custom image to deploy a Python function.
Additional considerations
If you use custom images, you must consider the following aspects:
- Custom images for deployment can only be built for Python with CPU environments.
- It is your responsibility to ensure that all updates that are made to the available runtime images in Watson Machine Learning, including all security updates, are also made to your custom images. Watch out for new fix packs or any related information. When new versions of Cloud Pak for Data are released, consider rebuilding all of your custom images.
- Watson Machine Learning custom images can’t be used in Watson Studio or Data Refinery. They can only be used in Watson Machine Learning.
- Watson Machine Learning uses
uwsgi
to run the deployment server. It is your responsibility to ensure that additional packages and libraries that you install do not breakuwsgi
. -
Watson Machine Learning custom images have this prefix pattern:
wml-dep-<od/bd>-<framework><version>-ci-*
To get the list of custom images, enter:oc get pods | grep "wml-dep" | grep "-ci-"
-
After you install any package for Watson Machine Learning, make it available to
wmlfuser:condausers
. - User Python code/packages copied to the container have read/write permissions for all users.
-
Pod spawning is taken care of by the deployment manager:
oc get pods | grep wml-deployment-manager
Therefore, pod spawning errors are more often captured in the deployment manager log.
oc logs wml-deployment-manager-0 > rm.log
Parent topic: Deploying and managing models