Set up for Ray on Vertex AI

Before you begin with Ray on Vertex AI, follow the steps to set up your Google project and Vertex AI SDK for Python:

  1. Follow the steps at Set up a project and a development environment to set up billing for your project, install the gcloud CLI and enable the Vertex AI API.

    Enable the Vertex AI API

  2. Prerequisite: You should know how to develop programs using open source Ray.

  3. The Ray on Vertex AI SDK for Python used here is a version of the Vertex AI SDK for Python that includes the functionality of the Ray Client, Ray BigQuery connector, Ray cluster management on Vertex AI, and predictions on Vertex AI.

    • If you're using Ray on Vertex AI in the Google Cloud console, a Colab Enterprise notebook guides you through the Vertex AI SDK for Python installation process after you create a Ray cluster.

    • If you're using Ray on Vertex AI in the Vertex AI Workbench or other interactive Python environment, install the Vertex AI SDK for Python:

      # The latest image in the Ray cluster includes Ray 2.9
      # The latest supported Python version is Python 3.10.
      $ pip install google-cloud-aiplatform[ray]

      After you install the SDK, restart the kernel before you import packages.

  4. (Optional) If you plan to read from BigQuery, you need to create a new BigQuery dataset or use an existing dataset.

  5. (Optional) To mitigate the risk of data exfiltration from Vertex AI, you can enable VPC Service Controls and specify a VPC network when you create a cluster. For more information, see VPC Service Controls with Vertex AI.

    If you enable VPC Service Controls, you won't be able to reach resources outside the perimeter, such as files in a Cloud Storage bucket.

  6. (Optional) To use a custom container image, host it on Artifact Registry. A custom image lets you add Python dependencies that aren't included with the prebuilt container images. To build custom images, see Packing your software in the Docker documentation.

  7. (Optional) If you specify a VPC network when creating a Ray cluster on Vertex AI, it's recommended that you have one auto mode VPC network in your project. You may encounter issues if you use a custom mode VPC network or use multiple VPC networks to create clusters in the same project.

Secure your clusters

Follow Ray best practices and guidelines, including running trusted code on trusted networks, to secure your Ray workloads. Deployment of in your cloud instances falls under the model of shared responsibility.

For more information about Google Cloud best practices, see the GCP-2024-020 security bulletin.

Supported locations

The Feature availability table for Custom model training lists the available locations for Ray on Vertex AI.

What's next