Google Cloud VertexAI
How to execute individual steps in Vertex AI
The Vertex step operator is a step operator flavor provided with the ZenML
gcp
integration that uses Vertex AI to execute individual steps of ZenML pipelines.You should use the Vertex step operator if:
- Create a service account with the right permissions to create Vertex AI jobs (
roles/aiplatform.admin
) and push to the container registry (roles/storage.admin
).
To use the Vertex step operator, we need:
- The ZenML
gcp
integration installed. If you haven't done so, runzenml integration install gcp - (Optional) A machine type that we want to execute our steps on (this defaults to
n1-standard-4
). See here for a list of available machine types. - A remote artifact store as part of your stack. This is needed so that both your orchestration environment and VertexAI can read and write step artifacts. Check out the documentation page of the artifact store you want to use for more information on how to set that up and configure authentication for it.
We can then register the step operator and use it in our active stack:
zenml step-operator register <NAME> \
--flavor=vertex \
--project=<GCP_PROJECT> \
--region=<REGION> \
--service_account_path=<SERVICE_ACCOUNT_PATH> \
# --machine_type=<MACHINE_TYPE> # optionally specify the type of machine to run on
# Add the step operator to the active stack
zenml stack update -s <NAME>
Once you added the step operator to your active stack, you can use it to execute individual steps of your pipeline by specifying it in the
@step
decorator as follows:from zenml.steps import step
@step(step_operator=<NAME>)
def trainer(...) -> ...:
"""Train a model."""
# This step will be executed in Vertex.
ZenML will build a Docker image called
<CONTAINER_REGISTRY_URI>/zenml:<PIPELINE_NAME>
which includes your code and use it to run your steps in Vertex AI. Check out this page if you want to learn more about how ZenML builds these images and how you can customize them.For additional configuration of the Vertex step operator, you can pass
VertexStepOperatorSettings
when defining or running your pipeline. Check out the API docs for a full list of available attributes and this docs page for more information on how to specify settings.For more information and a full list of configurable attributes of the Vertex step operator, check out the API Docs.
Note that if you wish to use this step operator to run steps on a GPU, you will need to follow the instructions on this page to ensure that it works. It requires adding some extra settings customization and is essential to enable CUDA for the GPU to give its full acceleration.
Last modified 2d ago