This lab is a tutorial on how to create a toy model and deploy it. You create a sklearn random forest model by training it on synthetic data. You create a model artifact and save it into the Model Catalog. Then deploy the model using the Model Deployment service. This is done programmatically with the OCI Python SDK. Then a sample data set is sent to the deployed model for inference.
The notebook makes connections to other OCI resources. This is done using resource principals. If you have not configured your tenancy to use resource principals then you can do so using the instructions that are here. Alternatively, you can use API keys. The preferred method for authentication is resource principals.
Your notebook needs internet access.
- Open a Data Science Notebook session (i.e. JupyterLab).
- Open a file terminal by clicking on File -> New -> Terminal.
- In the terminal run the following commands:
odsc conda install -s pytorch18_p37_cpu_v1
to install the PyTorch for CPU Python 3.7 conda.conda activate /home/datascience/conda/pytorch18_p37_cpu_v1
to activate the conda.pip install oci
to install the OCI Python SDK.
- Copy the
model-deployment.ipynb
into the notebook session. - Open the notebook.
- Change the notebook kernel to
Python [conda env:pytorch18_p37_cpu_v1]
. - Read the notebook and execute each cell.
Note:
- Read through the notebook and look for value place holders. These place holders are denoted by angle brackets surrounding some text. For example,
deployment_name = "<your-deployment-name>"
. You would replace<your-deployment-name>
with the actual name of your deployment, such asdeployment_name = "My Test Model Deployment"
. - By default, logs are not emitted to the Logging service. However, you can set it up yourself by creating custom logs for both predict and access logs.