Online services based on Kubeflow or Seldon

Updated at:

The Kubeflow service in a DataScience cluster includes the Seldon Core component to provide online services for models. These services are based on Kubernetes, so you do not need to manage the related O&M tasks. You can use the provided dsdemo code to deploy models, such as TensorFlow, PyTorch, and Python models, to Seldon.

Prerequisites

  • You have created a DataScience cluster and selected the Kubeflow service. For more information, see Create a cluster.
  • You have completed the Keras API training. For more information, see Kubeflow-based training example.
  • Download the dsdemo code. If you have a Data Science cluster, search for the DingTalk group ID 32497587 and join the group to get the code.

Procedure

Important This example uses a model exported from Keras API training. For more information, see Kubeflow-based training example.
  1. Connect to the cluster using the Secure Shell (SSH) protocol. For more information, see Log on to a cluster.
  2. Run the following command to navigate to the mnist_from_pvcmodel folder.
    cd dsdemo/kubeflow_samples/serving/seldon/tf/mnist_from_pvcmodel/
  3. Run the following command to install seldon_core.
    sudo pip3.7 install seldon_core
  4. If necessary, configure the mnist_grpc.yaml file.
    apiVersion: machinelearning.seldon.io/v1alpha2
    kind: SeldonDeployment
    metadata:
      name: tfserving
    spec:
      name: mnist
      predictors:
      - graph:
          children: []
          implementation: TENSORFLOW_SERVER
          modelUri: "pvc://strategy-volume/saved_model/master/"
          name: mnist-model
          parameters:
            - name: signature_name
              type: STRING
              value: serving_default
            - name: model_name
              type: STRING
              value: mnist-model
            - name: model_input
              type: STRING
              value: images
            - name: model_output
              type: STRING
              value: scores
        name: default
        replicas: 1
  5. Run the following command to obtain the IP address of the istio-gateway.
    kubectl get svc istio-ingressgateway -n istio-system
    The output is similar to the following.
    # kubectl get svc istio-ingressgateway -n istio-system
    NAME                   TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                                                                                      AGE
    istio-ingressgateway   NodePort   10.104.**.**   <none>        15020:31872/TCP,80:31380/TCP,443:31390/TCP,31400:31400/TCP,15029:30016/TCP,15030:30264/TCP,15031:31961/TCP,15032:31309/TCP,15443:31254/TCP   86m
    Note CLUSTER-IP is the IP address of the istio-gateway.
  6. Predict using the gRPC or REST protocol.
    Note If necessary, modify the minikube_ambassador_endpoint address in the predict_rest.py or predict_grpc.py file. Change the address to the istio-gateway IP address that you obtained in Step 5.
    • To predict using the gRPC protocol:
      python3.7 predict_grpc.py
    • To predict using the REST protocol:
      python3.7 predict_rest.py
    The output is similar to the following.
    Response:
    {'data': {'names': ['t:0', 't:1', 't:2', 't:3', 't:4', 't:5', 't:6', 't:7', 't:8', 't:9'], 'tensor': {'shape': [1, 10], 'values': [0.0191311873, 9.02173269e-09, 0.000745186175, 0.000349402311, 3.86572756e-05, 0.000118751872, 0.00138262415, 1.31301803e-07, 0.978211641, 2.23898933e-05]}}, 'meta': {}}
    You can use this method to deploy models, such as TensorFlow, PyTorch, and Python models, in Seldon to enable online services.

Feedback

If you have questions about using a Data Science cluster, contact our technical support engineers. You are also welcome to search for the DingTalk group ID 32497587 to join our group for feedback and discussion.