Hello custom training: Set up your project and environment

This page walks through setting up your Google Cloud project to useVertex AI and downloading some TensorFlow code for training. You willalso download code for a web app that gets predictions.

This tutorial has several pages:

  1. Setting up your project and environment.

  2. Training a custom image classificationmodel.

  3. Serving predictions from a custom image classificationmodel.

  4. Cleaning up your project.

Each page assumes that you have already performed the instructions from theprevious pages of the tutorial.

Before you begin

Throughout this tutorial, use Google Cloud console andCloud Shell to interact with Google Cloud. Alternatively,instead of Cloud Shell, youcan use another Bash shell with theGoogle Cloud CLI installed.

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Vertex AI and Cloud Run functions APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the Vertex AI and Cloud Run functions APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  8. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, aCloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  9. If Cloud Shell does not display(PROJECT_ID)$ in its prompt (wherePROJECT_ID is replaced by your Google Cloud project ID), then run the following command to configure Cloud Shell to use your project:

    gcloudconfigsetprojectPROJECT_ID

Create a Cloud Storage bucket

Create a regionalCloud Storage bucket in theus-central1region to use for the rest of this tutorial. As you follow the tutorial, use thebucket for several purposes:

  • Store training code for Vertex AI to use in a custom trainingjob.
  • Store the model artifacts that your custom training job outputs.
  • Host the web app that gets predictions from yourVertex AI endpoint.

To create the Cloud Storage bucket, run the following command in yourCloud Shell session:

gcloudstoragebucketscreategs://BUCKET_NAME--project=PROJECT_ID--location=us-central1

Replace the following:

  • PROJECT_ID: The ID of your Google Cloud project.
  • BUCKET_NAME: A name that you choose for your bucket. For example,hello_custom_PROJECT_ID. Learn aboutrequirements for bucketnames.

Download sample code

Download sample code to use for the rest of the tutorial.

gcloudstoragecpgs://cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz-|tar-xzv

To optionally view the sample code files, run the following command:

ls-lpRhello-custom-sample

Thehello-custom-sample directory has four items:

  • trainer/: A directory of TensorFlow Keras code for training the flowerclassification model.

  • setup.py: A configuration file for packaging thetrainer/ directory intoa Python source distribution that Vertex AI can use.

  • function/: A directory of Python code for aCloud Run function that can receive and preprocessprediction requests from a web browser, send them to Vertex AI,process the prediction responses, and send them back to the browser.

  • webapp/: A directory with code and markup for a web app that gets flowerclassification predictions from Vertex AI.

What's next

Follow thenext page of this tutorial to run a customtraining job on Vertex AI.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-24 UTC.