Working with custom images
Create a custom Docker image with libraries and packages 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 pre-selected open-source libraries, as well as selected IBM libraries. Building custom images enables you to optimize the standard software configuration of a runtime for your application needs. Custom images can also be used in air-gapped environments with requirements which forbid exposing any operations to the Internet.
Note: The way you create a custom image depends on whether you are building a an image for Python models and functions or an SPSS image. For details, refer to Creating a Watson Machine Learning custom image.
Notes:
- Images created in Cloud Pak for Data version 3.5 are no longer compatible with images created in Cloud Pak for Data version 4.0. It is recommended to download a new base image (for details, refer to Downloading the Watson Machine Learning base image). If, for some reason, you have to use a custom image created in Cloud Pak for Data 3.5, refer to Updating a custom image. Note: Updating the custom image will increase the image size by > 7GB+, depending on the number of files. Therefore it is recommended to use a fresh Cloud Pak for Data 4.0 base image.
- Custom images created prior to 4.0.6 release are not compatible with the 4.0.6 or later releases. You must rebuild custom images based on the new base images published in the current release. Perform these steps to continue to use existing custom
image based deployments in 4.0.6 or later releases.
- Download the latest base image shipped in CPD 4.0.6.
- Rebuild the image with required libraries.
- Upload the rebuilt image to local cpd registry.
- Update the existing runtime-definition file with the new image.
- Perform online or batch scoring on existing deployment. There is no need to create a fresh deployment if you have an existing deployment for the model that uses a custom image created in a previous release.
Training the model
If you want to train your SPSS model using a custom image, you can start with Building custom images to install ODBC drivers.
If you want to train your Python models or functions using 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, you will need to 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 supported with latest custom images (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 frameworks supported with deprecated custom images (wml-deployment-runtime-py37-2
and wml-deployment-runtime-py38-1
).
Framework | Versions | Online | Batch |
---|---|---|---|
Scikit-learn | 0.23 | Yes | Yes |
XGBoost | 1.3 | Yes | Yes |
TensorFlow | 2.4 | Yes | Yes |
PyTorch | 1.7 | Yes | Yes |
Python function | 0.1 | Yes | Programmatic only Inline payload only |
Python scripts | 1.0 | No | Yes |
Here are the supported frameworks for the SPSS base image under wml-deployment-runtime-spss-server.json
:
Framework | Versions | Online | Batch |
---|---|---|---|
Scikit-learn | 18.2 | No | Yes |
Creating a Watson Machine Learning custom image
These are the high-level steps for creating a custom image for Watson Machine Learning and making it available for deployments.
Required role: You must be an admin of the Cloud Pak for Data instance to download a runtime definition and register a runtime definition for a new image. You must have root privileges on your machine to execute the commands that build a custom image.
Prerequisite: Download the base image for the runtime image that you want to customize. Refer to Downloading the base image.
Prepare to build a new image:
- SPSS only: Get the registry URL to use for Docker commands and in scripts. The SPSS Modeler runtime images are stored in a Docker image registry. In Cloud Pak for Data, you can only use an external registry outside of the Cloud Pak for Data OpenShift cluster. To use that registry, you need the URL to the external registry that was used during the installation of Cloud Pak for Data. You use the same URL for all commands and in all scripts that you run.
- SPSS only: Download the configuration file for the SPSS Deployment runtime image that you want to customize. Refer to Downloading the configuration file for SPSS.
- SPSS and Python: Download the image.
Follow these steps to create and register a custom image:
- Add customizations, build a new image, and push the image to the container registry. For details, refer to Creating and uploading a custom image.
- Create a new base software specification for the custom image,
base_sw_spec
, that will be surfaced for deploying assets. - Create the new runtime definition file for the custom image, which maps the
base_sw_spec
to the custom_image.
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 the 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 package and libraries installed by you 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 (There might be multiple deployment managers)
oc logs wml-deployment-manager-0 > rm.log
Parent topic: Managing frameworks and software specifications