{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# BentoML Example: SKLearn to ONNX model\n", "\n", "\n", "**BentoML makes moving trained ML models to production easy:**\n", "\n", "* Package models trained with **any ML framework** and reproduce them for model serving in production\n", "* **Deploy anywhere** for online API serving or offline batch serving\n", "* High-Performance API model server with *adaptive micro-batching* support\n", "* Central hub for managing models and deployment process via Web UI and APIs\n", "* Modular and flexible design making it *adaptable to your infrastrcuture*\n", "\n", "BentoML is a framework for serving, managing, and deploying machine learning models. It is aiming to bridge the gap between Data Science and DevOps, and enable teams to deliver prediction services in a fast, repeatable, and scalable way.\n", "\n", "Before reading this example project, be sure to check out the [Getting started guide](https://github.com/bentoml/BentoML/blob/master/guides/quick-start/bentoml-quick-start-guide.ipynb) to learn about the basic concepts in BentoML.\n", "\n", "This example notebooks demonstrates how to build SK model and packed as ONNX model for BentoML\n", "\n", "![Impression](https://www.google-analytics.com/collect?v=1&tid=UA-112879361-3&cid=555&t=event&ec=onnx&ea=onnx-sk-iris-classifier&dt=onnx-sk-iris-classifier)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting skl2onnx\n", " Using cached skl2onnx-1.7.0-py2.py3-none-any.whl (191 kB)\n", "Requirement already satisfied: onnx in /opt/anaconda3/lib/python3.7/site-packages (1.7.0)\n", "Collecting onnxmltools\n", " Using cached onnxmltools-1.7.0-py2.py3-none-any.whl (252 kB)\n", "Requirement already satisfied: protobuf in /opt/anaconda3/lib/python3.7/site-packages (from skl2onnx) (3.11.3)\n", "Collecting onnxconverter-common>=1.5.1\n", " Using cached onnxconverter_common-1.7.0-py2.py3-none-any.whl (64 kB)\n", "Requirement already satisfied: scipy>=1.0 in /opt/anaconda3/lib/python3.7/site-packages (from skl2onnx) (1.3.1)\n", "Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from skl2onnx) (1.15.0)\n", "Requirement already satisfied: scikit-learn>=0.19 in /opt/anaconda3/lib/python3.7/site-packages (from skl2onnx) (0.21.3)\n", "Requirement already satisfied: numpy>=1.15 in /opt/anaconda3/lib/python3.7/site-packages (from skl2onnx) (1.18.5)\n", "Requirement already satisfied: typing-extensions>=3.6.2.1 in /opt/anaconda3/lib/python3.7/site-packages (from onnx) (3.7.4.2)\n", "Collecting keras2onnx\n", " Using cached keras2onnx-1.7.0-py3-none-any.whl (96 kB)\n", "Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.7/site-packages (from protobuf->skl2onnx) (49.1.0.post20200710)\n", "Requirement already satisfied: joblib>=0.11 in /opt/anaconda3/lib/python3.7/site-packages (from scikit-learn>=0.19->skl2onnx) (0.13.2)\n", "Requirement already satisfied: requests in /opt/anaconda3/lib/python3.7/site-packages (from keras2onnx->onnxmltools) (2.24.0)\n", "Collecting fire\n", " Using cached fire-0.3.1.tar.gz (81 kB)\n", "Requirement already satisfied: chardet<4,>=3.0.2 in /opt/anaconda3/lib/python3.7/site-packages (from requests->keras2onnx->onnxmltools) (3.0.4)\n", "Requirement already satisfied: idna<3,>=2.5 in /opt/anaconda3/lib/python3.7/site-packages (from requests->keras2onnx->onnxmltools) (2.10)\n", "Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.7/site-packages (from requests->keras2onnx->onnxmltools) (1.24.3)\n", "Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.7/site-packages (from requests->keras2onnx->onnxmltools) (2020.6.20)\n", "Collecting termcolor\n", " Downloading termcolor-1.1.0.tar.gz (3.9 kB)\n", "Building wheels for collected packages: fire, termcolor\n", " Building wheel for fire (setup.py) ... \u001b[?25ldone\n", "\u001b[?25h Created wheel for fire: filename=fire-0.3.1-py2.py3-none-any.whl size=111005 sha256=771d43d8451dfcbda6c1066b6e619b3f1ddec020d8ecc3fb0d8c0e70bbf8e526\n", " Stored in directory: /home/bentoml/.cache/pip/wheels/95/38/e1/8b62337a8ecf5728bdc1017e828f253f7a9cf25db999861bec\n", " Building wheel for termcolor (setup.py) ... \u001b[?25ldone\n", "\u001b[?25h Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4830 sha256=4551679660493ab6f79c2ab0add35ed6f744f524e43039ab340d2abc7d796707\n", " Stored in directory: /home/bentoml/.cache/pip/wheels/3f/e3/ec/8a8336ff196023622fbcb36de0c5a5c218cbb24111d1d4c7f2\n", "Successfully built fire termcolor\n", "Installing collected packages: onnxconverter-common, skl2onnx, termcolor, fire, keras2onnx, onnxmltools\n", "Successfully installed fire-0.3.1 keras2onnx-1.7.0 onnxconverter-common-1.7.0 onnxmltools-1.7.0 skl2onnx-1.7.0 termcolor-1.1.0\n" ] } ], "source": [ "!pip install -q bentoml \"skl2onnx==1.7.0\" \"onnx==1.7.0\" \"onnxmltools==1.7.0\"" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/usr/local/anaconda3/envs/dev-py3/lib/python3.7/site-packages/sklearn/linear_model/_logistic.py:762: ConvergenceWarning: lbfgs failed to converge (status=1):\n", "STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.\n", "\n", "Increase the number of iterations (max_iter) or scale the data as shown in:\n", " https://scikit-learn.org/stable/modules/preprocessing.html\n", "Please also refer to the documentation for alternative solver options:\n", " https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression\n", " extra_warning_msg=_LOGISTIC_SOLVER_CONVERGENCE_MSG)\n" ] }, { "data": { "text/plain": [ "LogisticRegression()" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from sklearn.datasets import load_iris\n", "from sklearn.model_selection import train_test_split\n", "iris = load_iris()\n", "X, y = iris.data, iris.target\n", "X_train, X_test, y_train, y_test = train_test_split(X, y)\n", "\n", "from sklearn.linear_model import LogisticRegression\n", "clr = LogisticRegression()\n", "clr.fit(X_train, y_train)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0])" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "clr.predict([[5.1, 3.5, 1.4, 0.2]])" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Writing iris_classifier_onnx.py\n" ] } ], "source": [ "%%writefile iris_classifier_onnx.py\n", "\n", "import numpy\n", "import bentoml\n", "from bentoml.adapters import DataframeInput\n", "from bentoml.frameworks.onnx import OnnxModelArtifact\n", "\n", "@bentoml.artifacts([OnnxModelArtifact('model')])\n", "@bentoml.env(infer_pip_packages=True)\n", "class IrisClassifierOnnx(bentoml.BentoService):\n", " \n", " @bentoml.api(input=DataframeInput(), batch=True)\n", " def predict(self, df):\n", " input_data = df.to_numpy().astype(numpy.float32)\n", " input_name = self.artifacts.model.get_inputs()[0].name\n", " output_name = self.artifacts.model.get_outputs()[0].name\n", " outputs = numpy.zeros(input_data.shape[0])\n", " for i in range(input_data.shape[0]):\n", " outputs[i] = self.artifacts.model.run([output_name], {input_name: input_data[i: i + 1]})[0]\n", " return outputs" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2020-09-22 14:32:58,569] WARNING - Using BentoML installed in `editable` model, the local BentoML repository including all code changes will be packaged together with saved bundle created, under the './bundled_pip_dependencies' directory of the saved bundle.\n", "[2020-09-22 14:32:58,902] INFO - Using default docker base image: `None` specified inBentoML config file or env var. User must make sure that the docker base image either has Python 3.7 or conda installed.\n", "[2020-09-22 14:33:01,032] INFO - Detected non-PyPI-released BentoML installed, copying local BentoML modulefiles to target saved bundle path..\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/usr/local/anaconda3/envs/dev-py3/lib/python3.7/site-packages/setuptools/dist.py:476: UserWarning: Normalizing '0.9.0.pre+3.gcebf2015' to '0.9.0rc0+3.gcebf2015'\n", " normalized_version,\n", "warning: no previously-included files matching '*~' found anywhere in distribution\n", "warning: no previously-included files matching '*.pyo' found anywhere in distribution\n", "warning: no previously-included files matching '.git' found anywhere in distribution\n", "warning: no previously-included files matching '.ipynb_checkpoints' found anywhere in distribution\n", "warning: no previously-included files matching '__pycache__' found anywhere in distribution\n", "no previously-included directories found matching 'e2e_tests'\n", "no previously-included directories found matching 'tests'\n", "no previously-included directories found matching 'benchmark'\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "UPDATING BentoML-0.9.0rc0+3.gcebf2015/bentoml/_version.py\n", "set BentoML-0.9.0rc0+3.gcebf2015/bentoml/_version.py to '0.9.0.pre+3.gcebf2015'\n", "[2020-09-22 14:33:06,941] INFO - BentoService bundle 'IrisClassifierOnnx:20200922143300_5EB8CF' saved to: /Users/bozhaoyu/bentoml/repository/IrisClassifierOnnx/20200922143300_5EB8CF\n" ] } ], "source": [ "from iris_classifier_onnx import IrisClassifierOnnx\n", "from skl2onnx.common.data_types import FloatTensorType\n", "import onnxmltools\n", "\n", "\n", "\n", "initial_type = [('float_input', FloatTensorType([None, 4]))]\n", "onnx_model = onnxmltools.convert_sklearn(clr, initial_types=initial_type)\n", "\n", "svc = IrisClassifierOnnx()\n", "svc.pack('model', onnx_model)\n", "\n", "saved_path = svc.save()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## REST API Model Serving\n", "\n", "\n", "To start a REST API model server with the BentoService saved above, use the bentoml serve command:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2020-08-04 09:58:22,230] INFO - Getting latest version IrisClassifierOnnx:20200804094903_8746D7\n", "[2020-08-04 09:58:22,230] INFO - Starting BentoML API server in development mode..\n", "[2020-08-04 09:58:23,377] WARNING - Using BentoML installed in `editable` model, the local BentoML repository including all code changes will be packaged together with saved bundle created, under the './bundled_pip_dependencies' directory of the saved bundle.\n", "[2020-08-04 09:58:23,405] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.8.1, but loading from BentoML version 0.8.3+47.g5daa71b\n", "[2020-08-04 09:58:23,406] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.4, but current environment version is 3.6.10.\n", "[2020-08-04 09:58:24,464] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.8.1, but loading from BentoML version 0.8.3+47.g5daa71b\n", "[2020-08-04 09:58:24,464] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.4, but current environment version is 3.6.10.\n", "[2020-08-04 09:58:24,466] INFO - Micro batch enabled for API `predict`\n", "[2020-08-04 09:58:24,466] INFO - Your system nofile limit is 10000, which means each instance of microbatch service is able to hold this number of connections at same time. You can increase the number of file descriptors for the server process, or launch more microbatch instances to accept more concurrent connection.\n", "[2020-08-04 09:58:24,475] INFO - Running micro batch service on :5000\n", " * Serving Flask app \"IrisClassifierOnnx\" (lazy loading)\n", " * Environment: production\n", "\u001b[31m WARNING: This is a development server. Do not use it in a production deployment.\u001b[0m\n", "\u001b[2m Use a production WSGI server instead.\u001b[0m\n", " * Debug mode: off\n", " * Running on http://127.0.0.1:40091/ (Press CTRL+C to quit)\n", "======== Running on http://0.0.0.0:5000 ========\n", "(Press CTRL+C to quit)\n", "[2020-08-04 09:58:27,265] INFO - Initializing onnxruntime InferenceSession from onnx file:'/home/bentoml/bentoml/repository/IrisClassifierOnnx/20200804094903_8746D7/IrisClassifierOnnx/artifacts/model.onnx'\n", "127.0.0.1 - - [04/Aug/2020 09:58:28] \"\u001b[37mPOST /predict HTTP/1.1\u001b[0m\" 200 -\n", "127.0.0.1 - - [04/Aug/2020 09:58:29] \"\u001b[37mPOST /predict HTTP/1.1\u001b[0m\" 200 -\n", "127.0.0.1 - - [04/Aug/2020 09:58:29] \"\u001b[37mPOST /predict HTTP/1.1\u001b[0m\" 200 -\n", "127.0.0.1 - - [04/Aug/2020 09:58:30] \"\u001b[37mPOST /predict HTTP/1.1\u001b[0m\" 200 -\n", "127.0.0.1 - - [04/Aug/2020 09:58:41] \"\u001b[37mPOST /predict HTTP/1.1\u001b[0m\" 200 -\n", "^C\n" ] } ], "source": [ "!bentoml serve IrisClassifierOnnx:latest --enable-microbatch" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you are running this notebook from Google Colab, you can start the dev server with `--run-with-ngrok` option, to gain acccess to the API endpoint via a public endpoint managed by [ngrok](https://ngrok.com/):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!bentoml serve IrisClassifierOnnx:latest --run-with-ngrok" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Send prediction requeset to the REST API server\n", "\n", "```\n", "curl -X POST \\\n", " http://localhost:5000/predict \\\n", " -H 'Content-Type: application/json' \\\n", " -d '[[5.1, 3.5, 1.4, 0.2]]'\n", "```\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Containerize model server with Docker\n", "\n", "\n", "One common way of distributing this model API server for production deployment, is via Docker containers. And BentoML provides a convenient way to do that.\n", "\n", "Note that docker is **not available in Google Colab**. You will need to download and run this notebook locally to try out this containerization with docker feature.\n", "\n", "If you already have docker configured, simply run the follow command to product a docker container serving the IrisClassifier prediction service created above:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2020-09-22 14:38:45,682] INFO - Getting latest version IrisClassifierOnnx:20200922143300_5EB8CF\n", "\u001b[39mFound Bento: /Users/bozhaoyu/bentoml/repository/IrisClassifierOnnx/20200922143300_5EB8CF\u001b[0m\n", "[2020-09-22 14:38:45,725] WARNING - Using BentoML installed in `editable` model, the local BentoML repository including all code changes will be packaged together with saved bundle created, under the './bundled_pip_dependencies' directory of the saved bundle.\n", "[2020-09-22 14:38:45,742] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015\n", "\u001b[39mTag not specified, using tag parsed from BentoService: 'irisclassifieronnx:20200922143300_5EB8CF'\u001b[0m\n", "Building Docker image irisclassifieronnx:20200922143300_5EB8CF from IrisClassifierOnnx:latest \n", "-we in here\n", "processed docker file\n", "(None, None)\n", "root in create archive /Users/bozhaoyu/bentoml/repository/IrisClassifierOnnx/20200922143300_5EB8CF ['Dockerfile', 'IrisClassifierOnnx', 'IrisClassifierOnnx/__init__.py', 'IrisClassifierOnnx/artifacts', 'IrisClassifierOnnx/artifacts/__init__.py', 'IrisClassifierOnnx/artifacts/model.onnx', 'IrisClassifierOnnx/bentoml.yml', 'IrisClassifierOnnx/iris_classifier_onnx.py', 'MANIFEST.in', 'README.md', 'bentoml-init.sh', 'bentoml.yml', 'bundled_pip_dependencies', 'bundled_pip_dependencies/BentoML-0.9.0rc0+3.gcebf2015.tar.gz', 'docker-entrypoint.sh', 'environment.yml', 'python_version', 'requirements.txt', 'setup.py']\n", "about to build\n", "about to upgrade params\n", "check each param and update\n", "if use config proxy\n", "if buildargs\n", "if shmsize\n", "if labels\n", "if cache from\n", "if target\n", "if network_mode\n", "if squash\n", "if extra hosts is not None\n", "if platform is not None\n", "if isolcation is not None\n", "if context is not None\n", "setting auth {'Content-Type': 'application/tar'}\n", "\b|docker build {'t': 'irisclassifieronnx:20200922143300_5EB8CF', 'remote': None, 'q': False, 'nocache': False, 'rm': False, 'forcerm': False, 'pull': False, 'dockerfile': (None, None)}\n", "\b\\docker response \n", "context closes\n", "print responses\n", "\u001b[39mStep 1/15 : FROM bentoml/model-server:0.9.0.pre\u001b[0m\n", "\u001b[39m ---> a25066aa8b0e\u001b[0m\n", "\u001b[39mStep 2/15 : ARG EXTRA_PIP_INSTALL_ARGS=\u001b[0m\n", "\u001b[39m ---> Using cache\u001b[0m\n", "\u001b[39m ---> fc6e47d06522\u001b[0m\n", "\u001b[39mStep 3/15 : ENV EXTRA_PIP_INSTALL_ARGS $EXTRA_PIP_INSTALL_ARGS\u001b[0m\n", "\u001b[39m ---> Using cache\u001b[0m\n", "\u001b[39m ---> db8172e98571\u001b[0m\n", "\u001b[39mStep 4/15 : COPY environment.yml requirements.txt setup.sh* bentoml-init.sh python_version* /bento/\u001b[0m\n", "\b\\\u001b[39m ---> 8c3896cf0c52\u001b[0m\n", "\u001b[39mStep 5/15 : WORKDIR /bento\u001b[0m\n", "\b-\u001b[39m ---> Running in dfa90bd500df\u001b[0m\n", "\b/\u001b[39m ---> 728e3aac9702\u001b[0m\n", "\u001b[39mStep 6/15 : RUN chmod +x /bento/bentoml-init.sh\u001b[0m\n", "\u001b[39m ---> Running in 41b3849a6c04\u001b[0m\n", "\b\\\u001b[39m ---> b0dd49ef9cf4\u001b[0m\n", "\u001b[39mStep 7/15 : RUN if [ -f /bento/bentoml-init.sh ]; then bash -c /bento/bentoml-init.sh; fi\u001b[0m\n", "\u001b[39m ---> Running in 3ebbaf28821e\u001b[0m\n", "\b|\u001b[39m\u001b[91m+++ dirname /bento/bentoml-init.sh\n", "++ cd /bento\n", "++ pwd -P\n", "\u001b[0m\u001b[0m\n", "\u001b[39m\u001b[91m+ SAVED_BUNDLE_PATH=/bento\n", "+ cd /bento\n", "+ '[' -f ./setup.sh ']'\n", "\u001b[0m\u001b[0m\n", "\u001b[39m\u001b[91m+ '[' -f ./python_version ']'\n", "\u001b[0m\u001b[0m\n", "\u001b[39m\u001b[91m++ cat ./python_version\n", "\u001b[0m\u001b[0m\n", "\u001b[39m\u001b[91m+ PY_VERSION_SAVED=3.7.3\n", "+ DESIRED_PY_VERSION=3.7\n", "\u001b[0m\u001b[0m\n", "\u001b[39m\u001b[91m++ python -c 'import sys; print(f\"{sys.version_info.major}.{sys.version_info.minor}\")'\n", "\u001b[0m\u001b[0m\n", "\u001b[39mPython Version in docker base image 3.7 matches requirement python=3.7. Skipping.\u001b[0m\n", "\u001b[39m\u001b[91m+ CURRENT_PY_VERSION=3.7\n", "+ [[ 3.7 == \\3\\.\\7 ]]\n", "+ echo 'Python Version in docker base image 3.7 matches requirement python=3.7. Skipping.'\n", "+ command -v conda\n", "\u001b[0m\u001b[0m\n", "\u001b[39mUpdating conda base environment with environment.yml\u001b[0m\n", "\u001b[39m\u001b[91m+ echo 'Updating conda base environment with environment.yml'\n", "+ conda env update -n base -f ./environment.yml\n", "\u001b[0m\u001b[0m\n", "\b|\u001b[39mCollecting package metadata (repodata.json): ...working... \u001b[0m\n", "\b-\u001b[39mdone\n", "Solving environment: ...working... \u001b[0m\n", "\b-\u001b[39mdone\u001b[0m\n", "\b/\u001b[39m\n", "Downloading and Extracting Packages\n", "cffi-1.14.3 | 223 KB | | 0% \u001b[0m\n", "cffi-1.14.3 | 223 KB | 7 | 7% \u001b[0m\n", "cffi-1.14.3 | 223 KB | ########## | 100% \u001b[0m\n", "\u001b[39m\n", "ca-certificates-2020 | 145 KB | | 0% \u001b[0m\n", "ca-certificates-2020 | 145 KB | ########## | 100% \u001b[0m\n", "\u001b[39m\n", "openssl-1.1.1h | 2.1 MB | | 0% \u001b[0m\n", "openssl-1.1.1h | 2.1 MB | ##3 | 24% \u001b[0m\n", "openssl-1.1.1h | 2.1 MB | #########3 | 94% \u001b[0m\n", "openssl-1.1.1h | 2.1 MB | ########## | 100% \u001b[0m\n", "\u001b[39m\n", "certifi-2020.6.20 | 151 KB | | 0% \u001b[0m\n", "certifi-2020.6.20 | 151 KB | ########## | 100% \u001b[0m\n", "\u001b[39m\n", "python_abi-3.7 | 4 KB | | 0% \u001b[0m\n", "python_abi-3.7 | 4 KB | ########## | 100% \u001b[0m\n", "\u001b[39m\n", "libffi-3.2.1 | 47 KB | | 0% \u001b[0m\n", "libffi-3.2.1 | 47 KB | ########## | 100% \u001b[0m\n", "\u001b[39m\n", "pip-20.2.3 | 1.1 MB | | 0% \u001b[0m\n", "pip-20.2.3 | 1.1 MB | #########7 | 98% \u001b[0m\n", "pip-20.2.3 | 1.1 MB | ########## | 100% \n", "Preparing transaction: ...working... \u001b[0m\n", "\b-\u001b[39mdone\u001b[0m\n", "\u001b[39mVerifying transaction: ...working... \u001b[0m\n", "\b\\\u001b[39mdone\u001b[0m\n", "\u001b[39mExecuting transaction: ...working... \u001b[0m\n", "\b\\\u001b[39mdone\u001b[0m\n", "\b/\u001b[39m#\n", "# To activate this environment, use\n", "#\n", "# $ conda activate base\n", "#\n", "# To deactivate an active environment, use\n", "#\n", "# $ conda deactivate\u001b[0m\n", "\b-\u001b[39m\u001b[91m+ pip install -r ./requirements.txt --no-cache-dir\n", "\u001b[0m\u001b[0m\n", "\b/\u001b[39mRequirement already satisfied: bentoml==0.9.0.pre in /opt/conda/lib/python3.7/site-packages (from -r ./requirements.txt (line 1)) (0.9.0rc0)\u001b[0m\n", "\b\\\u001b[39mCollecting pandas==0.24.2\u001b[0m\n", "\b/\u001b[39m Downloading pandas-0.24.2-cp37-cp37m-manylinux1_x86_64.whl (10.1 MB)\u001b[0m\n", "\b/\u001b[39mCollecting onnxruntime==1.3.0\u001b[0m\n", "\b|\u001b[39m Downloading onnxruntime-1.3.0-cp37-cp37m-manylinux1_x86_64.whl (3.9 MB)\u001b[0m\n", "\b/\u001b[39mCollecting numpy==1.18.4\u001b[0m\n", "\u001b[39m Downloading numpy-1.18.4-cp37-cp37m-manylinux1_x86_64.whl (20.2 MB)\u001b[0m\n", "\b-\u001b[39mRequirement already satisfied: sqlalchemy-utils<0.36.8 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.36.7)\u001b[0m\n", "\b/\u001b[39mRequirement already satisfied: multidict in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (4.7.6)\u001b[0m\n", "\u001b[39mRequirement already satisfied: configparser in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (5.0.0)\u001b[0m\n", "\b|\u001b[39mRequirement already satisfied: psutil in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (5.7.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: humanfriendly in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (8.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: boto3 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.15.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: certifi in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2020.6.20)\u001b[0m\n", "\u001b[39mRequirement already satisfied: protobuf>=3.6.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.13.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: aiohttp in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.6.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: requests in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.24.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: prometheus-client in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.8.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: flask in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: cerberus in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.3.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: sqlalchemy>=1.3.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.3.19)\u001b[0m\n", "\b\\\u001b[39mRequirement already satisfied: packaging in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (20.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied: click>=7.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (7.1.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: py-zipkin in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.20.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: ruamel.yaml>=0.15.0 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.15.87)\u001b[0m\n", "\u001b[39mRequirement already satisfied: python-dateutil<3.0.0,>=2.7.3 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.8.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied: gunicorn in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (20.0.4)\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[39mRequirement already satisfied: python-json-logger in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.1.11)\u001b[0m\n", "\u001b[39mRequirement already satisfied: docker in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (4.3.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied: grpcio<=1.27.2 in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.27.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: tabulate in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.8.7)\u001b[0m\n", "\u001b[39mRequirement already satisfied: alembic in /opt/conda/lib/python3.7/site-packages (from bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.4.3)\u001b[0m\n", "\b/\u001b[39mCollecting pytz>=2011k\u001b[0m\n", "\u001b[39m Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)\u001b[0m\n", "\b\\\u001b[39mCollecting onnx>=1.2.3\u001b[0m\n", "\u001b[39m Downloading onnx-1.7.0-cp37-cp37m-manylinux1_x86_64.whl (7.4 MB)\u001b[0m\n", "\b-\u001b[39mRequirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from sqlalchemy-utils<0.36.8->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.15.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: botocore<1.19.0,>=1.18.2 in /opt/conda/lib/python3.7/site-packages (from boto3->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.18.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: jmespath<1.0.0,>=0.7.1 in /opt/conda/lib/python3.7/site-packages (from boto3->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.10.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: s3transfer<0.4.0,>=0.3.0 in /opt/conda/lib/python3.7/site-packages (from boto3->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.3.3)\u001b[0m\n", "\u001b[39mRequirement already satisfied: setuptools in /opt/conda/lib/python3.7/site-packages (from protobuf>=3.6.0->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (49.6.0.post20200814)\u001b[0m\n", "\u001b[39mRequirement already satisfied: yarl<2.0,>=1.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.5.1)\u001b[0m\n", "\b/\u001b[39mRequirement already satisfied: async-timeout<4.0,>=3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.0.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied: attrs>=17.3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (20.2.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: chardet<4.0,>=2.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.0.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied: idna<3,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.10)\u001b[0m\n", "\u001b[39mRequirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.25.10)\u001b[0m\n", "\u001b[39mRequirement already satisfied: Werkzeug>=0.15 in /opt/conda/lib/python3.7/site-packages (from flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.0.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied: Jinja2>=2.10.1 in /opt/conda/lib/python3.7/site-packages (from flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.11.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied: itsdangerous>=0.24 in /opt/conda/lib/python3.7/site-packages (from flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: pyparsing>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from packaging->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (2.4.7)\u001b[0m\n", "\u001b[39mRequirement already satisfied: thriftpy2>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from py-zipkin->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.4.11)\u001b[0m\n", "\u001b[39mRequirement already satisfied: websocket-client>=0.32.0 in /opt/conda/lib/python3.7/site-packages (from docker->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (0.57.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied: Mako in /opt/conda/lib/python3.7/site-packages (from alembic->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.3)\u001b[0m\n", "\u001b[39mRequirement already satisfied: python-editor>=0.3 in /opt/conda/lib/python3.7/site-packages (from alembic->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.0.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied: typing-extensions>=3.6.2.1 in /opt/conda/lib/python3.7/site-packages (from onnx>=1.2.3->onnxruntime==1.3.0->-r ./requirements.txt (line 3)) (3.7.4.3)\u001b[0m\n", "\u001b[39mRequirement already satisfied: MarkupSafe>=0.23 in /opt/conda/lib/python3.7/site-packages (from Jinja2>=2.10.1->flask->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (1.1.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied: ply<4.0,>=3.4 in /opt/conda/lib/python3.7/site-packages (from thriftpy2>=0.4.0->py-zipkin->bentoml==0.9.0.pre->-r ./requirements.txt (line 1)) (3.11)\u001b[0m\n", "\b\\\u001b[39mInstalling collected packages: numpy, pytz, pandas, onnx, onnxruntime\n", " Attempting uninstall: numpy\u001b[0m\n", "\u001b[39m Found existing installation: numpy 1.19.2\u001b[0m\n", "\b/\u001b[39m Uninstalling numpy-1.19.2:\u001b[0m\n", "\b\\\u001b[39m Successfully uninstalled numpy-1.19.2\u001b[0m\n", "\b-\u001b[39mSuccessfully installed numpy-1.18.4 onnx-1.7.0 onnxruntime-1.3.0 pandas-0.24.2 pytz-2020.1\u001b[0m\n", "\b\\\u001b[39m ---> 866c51f54760\u001b[0m\n", "\u001b[39mStep 8/15 : COPY . /bento\u001b[0m\n", "\b/\u001b[39m ---> 6e11b086aa71\u001b[0m\n", "\u001b[39mStep 9/15 : RUN if [ -d /bento/bundled_pip_dependencies ]; then pip install -U bundled_pip_dependencies/* ;fi\u001b[0m\n", "\u001b[39m ---> Running in 675f3fde37a6\u001b[0m\n", "\b-\u001b[39mProcessing ./bundled_pip_dependencies/BentoML-0.9.0rc0+3.gcebf2015.tar.gz\u001b[0m\n", "\b-\u001b[39m Installing build dependencies: started\u001b[0m\n", "\b-\u001b[39m Installing build dependencies: finished with status 'done'\u001b[0m\n", "\u001b[39m Getting requirements to build wheel: started\u001b[0m\n", "\b/\u001b[39m Getting requirements to build wheel: finished with status 'done'\u001b[0m\n", "\u001b[39m Preparing wheel metadata: started\u001b[0m\n", "\b\\\u001b[39m Preparing wheel metadata: finished with status 'done'\u001b[0m\n", "\b/\u001b[39mRequirement already satisfied, skipping upgrade: protobuf>=3.6.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (3.13.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: py-zipkin in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.20.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: requests in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (2.24.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: gunicorn in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (20.0.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: grpcio<=1.27.2 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.27.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: python-json-logger in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.1.11)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: packaging in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (20.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: click>=7.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (7.1.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: alembic in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.4.3)\u001b[0m\n", "\b|\u001b[39mRequirement already satisfied, skipping upgrade: psutil in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (5.7.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: sqlalchemy>=1.3.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.3.19)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: multidict in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (4.7.6)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: aiohttp in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (3.6.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: humanfriendly in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (8.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: flask in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.1.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: prometheus-client in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.8.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: sqlalchemy-utils<0.36.8 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.36.7)\u001b[0m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\b\\\u001b[39mRequirement already satisfied, skipping upgrade: cerberus in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.3.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: boto3 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.15.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: configparser in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (5.0.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: python-dateutil<3.0.0,>=2.7.3 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (2.8.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: docker in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (4.3.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: ruamel.yaml>=0.15.0 in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.15.87)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: numpy in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (1.18.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: tabulate in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (0.8.7)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: certifi in /opt/conda/lib/python3.7/site-packages (from BentoML==0.9.0rc0+3.gcebf2015) (2020.6.20)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: setuptools in /opt/conda/lib/python3.7/site-packages (from protobuf>=3.6.0->BentoML==0.9.0rc0+3.gcebf2015) (49.6.0.post20200814)\u001b[0m\n", "\b-\u001b[39mRequirement already satisfied, skipping upgrade: six>=1.9 in /opt/conda/lib/python3.7/site-packages (from protobuf>=3.6.0->BentoML==0.9.0rc0+3.gcebf2015) (1.15.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: thriftpy2>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from py-zipkin->BentoML==0.9.0rc0+3.gcebf2015) (0.4.11)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.9.0rc0+3.gcebf2015) (3.0.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.9.0rc0+3.gcebf2015) (1.25.10)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: idna<3,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests->BentoML==0.9.0rc0+3.gcebf2015) (2.10)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: pyparsing>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from packaging->BentoML==0.9.0rc0+3.gcebf2015) (2.4.7)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: Mako in /opt/conda/lib/python3.7/site-packages (from alembic->BentoML==0.9.0rc0+3.gcebf2015) (1.1.3)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: python-editor>=0.3 in /opt/conda/lib/python3.7/site-packages (from alembic->BentoML==0.9.0rc0+3.gcebf2015) (1.0.4)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: yarl<2.0,>=1.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (1.5.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: async-timeout<4.0,>=3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (3.0.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: attrs>=17.3.0 in /opt/conda/lib/python3.7/site-packages (from aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (20.2.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: Werkzeug>=0.15 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.9.0rc0+3.gcebf2015) (1.0.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: itsdangerous>=0.24 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.9.0rc0+3.gcebf2015) (1.1.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: Jinja2>=2.10.1 in /opt/conda/lib/python3.7/site-packages (from flask->BentoML==0.9.0rc0+3.gcebf2015) (2.11.2)\u001b[0m\n", "\b/\u001b[39mRequirement already satisfied, skipping upgrade: botocore<1.19.0,>=1.18.2 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.9.0rc0+3.gcebf2015) (1.18.2)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: jmespath<1.0.0,>=0.7.1 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.9.0rc0+3.gcebf2015) (0.10.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: s3transfer<0.4.0,>=0.3.0 in /opt/conda/lib/python3.7/site-packages (from boto3->BentoML==0.9.0rc0+3.gcebf2015) (0.3.3)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: websocket-client>=0.32.0 in /opt/conda/lib/python3.7/site-packages (from docker->BentoML==0.9.0rc0+3.gcebf2015) (0.57.0)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: ply<4.0,>=3.4 in /opt/conda/lib/python3.7/site-packages (from thriftpy2>=0.4.0->py-zipkin->BentoML==0.9.0rc0+3.gcebf2015) (3.11)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: MarkupSafe>=0.9.2 in /opt/conda/lib/python3.7/site-packages (from Mako->alembic->BentoML==0.9.0rc0+3.gcebf2015) (1.1.1)\u001b[0m\n", "\u001b[39mRequirement already satisfied, skipping upgrade: typing-extensions>=3.7.4; python_version < \"3.8\" in /opt/conda/lib/python3.7/site-packages (from yarl<2.0,>=1.0->aiohttp->BentoML==0.9.0rc0+3.gcebf2015) (3.7.4.3)\u001b[0m\n", "\u001b[39mBuilding wheels for collected packages: BentoML\u001b[0m\n", "\u001b[39m Building wheel for BentoML (PEP 517): started\u001b[0m\n", "\b\\\u001b[39m Building wheel for BentoML (PEP 517): finished with status 'done'\u001b[0m\n", "\u001b[39m Created wheel for BentoML: filename=BentoML-0.9.0rc0+3.gcebf2015-py3-none-any.whl size=3064091 sha256=b065620707c341cb307a75ee66e4c24eafeb59170d1bc3c344f040dcad703f83\n", " Stored in directory: /root/.cache/pip/wheels/a0/45/41/62152db705af4ff47e7a3d6abf6247986eef4aa1b94a58d3b9\u001b[0m\n", "\u001b[39mSuccessfully built BentoML\u001b[0m\n", "\b\\\u001b[39mInstalling collected packages: BentoML\n", " Attempting uninstall: BentoML\u001b[0m\n", "\u001b[39m Found existing installation: BentoML 0.9.0rc0\u001b[0m\n", "\b-\u001b[39m Uninstalling BentoML-0.9.0rc0:\u001b[0m\n", "\b\\\u001b[39m Successfully uninstalled BentoML-0.9.0rc0\u001b[0m\n", "\b-\u001b[39mSuccessfully installed BentoML-0.9.0rc0+3.gcebf2015\u001b[0m\n", "\b/\u001b[39m ---> 9d4f82cb1019\u001b[0m\n", "\u001b[39mStep 10/15 : ENV PORT 5000\u001b[0m\n", "\u001b[39m ---> Running in 676f60e8ba7c\u001b[0m\n", "\b|\u001b[39m ---> 572602250521\u001b[0m\n", "\u001b[39mStep 11/15 : EXPOSE $PORT\u001b[0m\n", "\u001b[39m ---> Running in e16a57365266\u001b[0m\n", "\b-\u001b[39m ---> 9b17a261cfb5\u001b[0m\n", "\u001b[39mStep 12/15 : COPY docker-entrypoint.sh /usr/local/bin/\u001b[0m\n", "\b/\u001b[39m ---> e86df949cff8\u001b[0m\n", "\u001b[39mStep 13/15 : RUN chmod +x /usr/local/bin/docker-entrypoint.sh\u001b[0m\n", "\b|\u001b[39m ---> Running in 1fa5f562e6d0\u001b[0m\n", "\b-\u001b[39m ---> 9633179ac813\u001b[0m\n", "\u001b[39mStep 14/15 : ENTRYPOINT [ \"docker-entrypoint.sh\" ]\u001b[0m\n", "\u001b[39m ---> Running in 33c5e3e62cab\u001b[0m\n", "\b/\u001b[39m ---> c858376192ca\u001b[0m\n", "\u001b[39mStep 15/15 : CMD [\"bentoml\", \"serve-gunicorn\", \"/bento\"]\u001b[0m\n", "\b|\u001b[39m ---> Running in dd023c74d8f9\u001b[0m\n", "\u001b[39m ---> f2eab90cb68d\u001b[0m\n", "\u001b[39mSuccessfully built f2eab90cb68d\u001b[0m\n", "\b\\\u001b[39mSuccessfully tagged irisclassifieronnx:20200922143300_5EB8CF\u001b[0m\n", "\u001b[32mFinished building irisclassifieronnx:20200922143300_5EB8CF from IrisClassifierOnnx:latest\u001b[0m\n" ] } ], "source": [ "!bentoml containerize IrisClassifierOnnx:latest" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2020-09-22 21:40:47,259] INFO - Starting BentoML API server in production mode..\n", "[2020-09-22 21:40:47,615] INFO - get_gunicorn_num_of_workers: 3, calculated by cpu count\n", "[2020-09-22 21:40:47 +0000] [1] [INFO] Starting gunicorn 20.0.4\n", "[2020-09-22 21:40:47 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)\n", "[2020-09-22 21:40:47 +0000] [1] [INFO] Using worker: sync\n", "[2020-09-22 21:40:47 +0000] [11] [INFO] Booting worker with pid: 11\n", "[2020-09-22 21:40:47 +0000] [12] [INFO] Booting worker with pid: 12\n", "[2020-09-22 21:40:47 +0000] [13] [INFO] Booting worker with pid: 13\n", "[2020-09-22 21:40:47,877] WARNING - Using BentoML not from official PyPI release. In order to find the same version of BentoML when deploying your BentoService, you must set the 'core/bentoml_deploy_version' config to a http/git location of your BentoML fork, e.g.: 'bentoml_deploy_version = git+https://github.com/{username}/bentoml.git@{branch}'\n", "[2020-09-22 21:40:47,888] WARNING - Using BentoML not from official PyPI release. In order to find the same version of BentoML when deploying your BentoService, you must set the 'core/bentoml_deploy_version' config to a http/git location of your BentoML fork, e.g.: 'bentoml_deploy_version = git+https://github.com/{username}/bentoml.git@{branch}'\n", "[2020-09-22 21:40:47,909] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015\n", "[2020-09-22 21:40:47,910] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.3, but current environment version is 3.7.6.\n", "[2020-09-22 21:40:47,915] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015\n", "[2020-09-22 21:40:47,916] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.3, but current environment version is 3.7.6.\n", "[2020-09-22 21:40:47,983] WARNING - Using BentoML not from official PyPI release. In order to find the same version of BentoML when deploying your BentoService, you must set the 'core/bentoml_deploy_version' config to a http/git location of your BentoML fork, e.g.: 'bentoml_deploy_version = git+https://github.com/{username}/bentoml.git@{branch}'\n", "[2020-09-22 21:40:48,010] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015\n", "[2020-09-22 21:40:48,010] WARNING - Saved BentoService Python version mismatch: loading BentoService bundle created with Python version 3.7.3, but current environment version is 3.7.6.\n", "^C\n", "[2020-09-22 21:40:51 +0000] [1] [INFO] Handling signal: int\n", "[2020-09-22 21:40:51 +0000] [11] [INFO] Worker exiting (pid: 11)\n", "[2020-09-22 21:40:51 +0000] [13] [INFO] Worker exiting (pid: 13)\n", "[2020-09-22 21:40:51 +0000] [12] [INFO] Worker exiting (pid: 12)\n" ] } ], "source": [ "!docker run --rm -p 5000:5000 irisclassifieronnx:20200922143300_5EB8CF" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load saved BentoService\n", "\n", "bentoml.load is the API for loading a BentoML packaged model in python:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from bentoml import load\n", "\n", "\n", "svc = load(saved_path)\n", "\n", "print(svc.predict([[5.1, 3.5, 1.4, 0.2]]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Launch inference job from CLI\n", "\n", "BentoML cli supports loading and running a packaged model from CLI. With the DataframeInput adapter, the CLI command supports reading input Dataframe data from CLI argument or local csv or json files:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[2020-09-22 14:41:28,131] INFO - Getting latest version IrisClassifierOnnx:20200922143300_5EB8CF\n", "[2020-09-22 14:41:28,177] WARNING - Using BentoML installed in `editable` model, the local BentoML repository including all code changes will be packaged together with saved bundle created, under the './bundled_pip_dependencies' directory of the saved bundle.\n", "[2020-09-22 14:41:28,192] WARNING - Saved BentoService bundle version mismatch: loading BentoService bundle create with BentoML version 0.9.0.pre, but loading from BentoML version 0.9.0.pre+3.gcebf2015\n", "[2020-09-22 14:41:28,584] INFO - Using default docker base image: `None` specified inBentoML config file or env var. User must make sure that the docker base image either has Python 3.7 or conda installed.\n", "[2020-09-22 14:41:29,074] INFO - Initializing onnxruntime InferenceSession from onnx file:'/Users/bozhaoyu/bentoml/repository/IrisClassifierOnnx/20200922143300_5EB8CF/IrisClassifierOnnx/artifacts/model.onnx'\n", "[2020-09-22 14:41:33,065] INFO - {'service_name': 'IrisClassifierOnnx', 'service_version': '20200922143300_5EB8CF', 'api': 'predict', 'task': {'data': {}, 'task_id': '1c20a573-fe40-44b2-b28b-7dd907927996', 'batch': 2, 'cli_args': ('--input', '[[5.1, 3.5, 1.4, 0.2], [5.1, 3.5, 1.4, 0.2]]')}, 'result': {'data': '[0.0, 0.0]', 'http_status': 200, 'http_headers': (('Content-Type', 'application/json'),)}, 'request_id': '1c20a573-fe40-44b2-b28b-7dd907927996'}\n", "[0.0, 0.0]\n" ] } ], "source": [ "!bentoml run IrisClassifierOnnx:latest predict --input '[[5.1, 3.5, 1.4, 0.2], [5.1, 3.5, 1.4, 0.2]]'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Deployment Options\n", "\n", "If you are at a small team with limited engineering or DevOps resources, try out automated deployment with BentoML CLI, currently supporting AWS Lambda, AWS SageMaker, and Azure Functions:\n", "- [AWS Lambda Deployment Guide](https://docs.bentoml.org/en/latest/deployment/aws_lambda.html)\n", "- [AWS SageMaker Deployment Guide](https://docs.bentoml.org/en/latest/deployment/aws_sagemaker.html)\n", "- [Azure Functions Deployment Guide](https://docs.bentoml.org/en/latest/deployment/azure_functions.html)\n", "\n", "If the cloud platform you are working with is not on the list above, try out these step-by-step guide on manually deploying BentoML packaged model to cloud platforms:\n", "- [AWS ECS Deployment](https://docs.bentoml.org/en/latest/deployment/aws_ecs.html)\n", "- [Google Cloud Run Deployment](https://docs.bentoml.org/en/latest/deployment/google_cloud_run.html)\n", "- [Azure container instance Deployment](https://docs.bentoml.org/en/latest/deployment/azure_container_instance.html)\n", "- [Heroku Deployment](https://docs.bentoml.org/en/latest/deployment/heroku.html)\n", "\n", "Lastly, if you have a DevOps or ML Engineering team who's operating a Kubernetes or OpenShift cluster, use the following guides as references for implementating your deployment strategy:\n", "- [Kubernetes Deployment](https://docs.bentoml.org/en/latest/deployment/kubernetes.html)\n", "- [Knative Deployment](https://docs.bentoml.org/en/latest/deployment/knative.html)\n", "- [Kubeflow Deployment](https://docs.bentoml.org/en/latest/deployment/kubeflow.html)\n", "- [KFServing Deployment](https://docs.bentoml.org/en/latest/deployment/kfserving.html)\n", "- [Clipper.ai Deployment Guide](https://docs.bentoml.org/en/latest/deployment/clipper.html)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 4 }