Gradient Deployments
Get a high-level overview of Gradient Deployments including how to get started and advanced features.
Overview​
Gradient Deployments allows you to easily deploy your machine learning model as an API endpoint.
Deployments allow you to run container images and serve machine learning models using a high-performance, low-latency service with a RESTful API. Deployments are defined by a spec and can be managed through the web or CLI/SDK.
A deployment can be updated by changing the spec. Each new spec update will generate a new spec_id
under the same deployment_id
. Previous versions of the deployment spec can be viewed under the deployment objects history.
The best place to start learning how to deploy models on Gradient is the official Gradient Deployments Tutorial.
Deployment basics​
Once a deployment has started there are a few key characteristics:
deployment_id
- A unique id generated each time a new deployment object is created.
spec_id
- A unique id generated each time a deployment spec is created or updated. Each deployment object can have several associated spec_id
.
endpoint
- A public URL to receive API requests.
Create a Deployment​
Gradient Deployments can be created in the web or the CLI. When created in the web, the backend will submit a spec file that outlines specifications for a deployment.
How to create a deployment using the Gradient CLI​
You can create deployments using the Gradient CLI and linking an API key. Learn how to create an API key. You will also need an existing Project to run your deployment.
enabled: true
image: lucone83/streamlit-nginx
port: 8080
env:
- name: ENV
value: VAR
resources:
replicas: 1
instanceType: C4
- Create the deployment
gradient deployments create --name [deployment-name] --projectId [project-id] --spec deployment.yaml --apiKey [api-key]
- Check the status of your deployment via the CLI
gradient deployments get --id [deployment-id] --apiKey [api-key]
- View your running deployment in the web
Create an example Gradient Deployment​
Use the CLI to create this example deployment. Please keep in mind that a credit card on the workspace is necessary and this will charge the account until the deployment is turned off.
- In your favorite editor create a new file called
learn-gradient-deployment.yaml
and add the following code.
enabled: true
image: lucone83/streamlit-nginx
port: 8080
env:
- name: ENV
value: VAR
resources:
replicas: 1
instanceType: C4
- Copy the command below into your terminal. This will return the
deployment id
. Click here to set up the Gradient CLI.
gradient deployments create --name learn-gradient-deployment --projectId [projectID] --spec learn-gradient-deployment.yaml --apiKey [api-key]
- Check the deployment status from the console or using the CLI with the
deployment id
from the previous step.
gradient deployments get --id [deployment-id] --apiKey [api-key]
- Stop the deployment by updating
enabled
value tofalse
in the spec.
New spec:
enabled: false
image: lucone83/streamlit-nginx
port: 8080
env:
- name: ENV
value: VAR
resources:
replicas: 1
instanceType: C4
Terminal command:
gradient deployments update --id deployment-id --spec learn-gradient-deployment.yaml --apiKey [api-key]