Workflows automate machine learning tasks, combining GPU instances with an expressive syntax to generate production-ready machine learning pipelines with a few lines of code.
Whether you are using Notebooks, Workflows, or Deployments, Gradient uses containers to provide a reproducible code execution environment.
In the case of notebooks, you can either use a preconfigured container or bring your own container. To learn more, see the Notebook Runtimes page.
For Workflows and Deployments, you can either use public containers or private containers to set up your environment. With public containers (for example tensorflow/tensorflow:2.7.0-gpu-jupyter
if you wanted to use a generic TensorFlow environment) Gradient takes care of everything once you specify that as the image
for your Workflow job. Learn more about Workflow specs on the Workflow specs page.
You can also use a private container in your Workflows and Deployments. Gradient can store and manage your private container registry credentials, which you can learn about below.
You can store credentials for future use in Gradient resources through the Containers tab in your team settings. Access your team settings by clicking on your user image in the top right of the console.
Within the Containers tab you can add new container registries as well as edit or delete your existing registries.
To create a new container registry connection, choose which container registry you are adding and click Next. This generates an entry form with the information necessary for that specific container registry.
Here are some examples for each container registry you can create and how it would work. If you do not see the desired container registry below then you can use the Other type.
This section explains how to create a custom Docker container that you can push to a container registry like Docker Hub, and load that container into Gradient through a notebook, workflow, or deployment.
You need a computer with DockerCE, NVIDIA-docker, and NVIDIA Drivers installed. If you don’t have an appropriate machine, you can use a Paperspace Linux machine.
From that machine, you need to log into your Docker Hub account using the following command in the terminal:
docker login -u <username> -p <password>
You can make your own Dockerfile from scratch or use another as a template, such as this example. For now, let’s follow this provided sample.
First, clone the repo to your machine and navigate to the corresponding directory in your terminal:
git clone https://github.com/gradient-ai/tensorflow-python && cd tensorflow-python
Open the Dockerfile in the IDE of your choice and make edits as necessary. The provided Dockerfile sampled above pulls from Docker Hub a Paperspace-made TensorFlow image designed to run TensorFlow 2.0 on Paperspace GPUs.
Once your Dockerfile is updated, save it, and navigate back to the terminal.
Now that the Dockerfile is created, navigate in your terminal to the same directory your Dockerfile exists and build the image by running:
docker build -t <Name of image> .
Example: docker build test-container
Once you have created the image, you need to tag it so that it can be pushed to your Docker Hub repository. Tag the image using the image id or image name from the image you created, your Docker Hub username, a name for the image, and a tag in the following format:
docker tag <Image ID/Image name> <Docker username>/<Image name>:<Tag>
Example: docker tag test-container paperspace/test-container:latest
Now that we have created and tagged our container, we can push it to Docker Hub and use it within Gradient resources. Use the following docker push
command to do so:
docker push <Docker username>/<Image name>:<Tag>
After you’ve pushed your custom container to Docker Hub, NGC, etc., or you found a public container that is already there, it’s time to pull it into Gradient!
To run your image using Gradient Notebooks, click the Advanced options toggle on the Notebook create page. Follow the rest of the steps here to create your Notebook.
To run a custom container using a Gradient Notebook, JupyterLab must be installed on the image. The following are commands you can run in your Dockerfile to ensure the Notebook runs properly.
Dockerfile requirements
RUN apt-get update && apt-get install -y python3 python3-pip
RUN pip install jupyterlab
(For more details, see http://jupyter.org/install)Specify the path of the container for example, paperspace/gradient-sdk
from within a Workflow step using image
. Learn more here.
If the image is public, specify the path to the image using the image
key. If the image is private, you need to specify the containerRegistry
, which you set up in the Create a New Container Registry Entry section of this document.