Hello 表格数据:设置项目和环境

本教程将引导您完成在 Google Cloud 控制台中训练表格数据模型并从该模型获取预测结果所需的步骤。如果您计划使用 Vertex AI SDK for Python,请确保初始化客户端的服务账号具有 Vertex AI Service Agent (roles/aiplatform.serviceAgent) IAM 角色。

在本教程的这一部分,您将设置 Google Cloud 项目以使用 Vertex AI 和 Cloud Storage 存储桶(用于存储训练 AutoML 模型的文档)。

设置您的项目和环境

  1. In the Google Cloud console, go to the project selector page.

    Go to project selector

  2. 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 (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
  3. Verify that billing is enabled for your Google Cloud project.

  4. 打开 Cloud Shell。 Cloud Shell 是 Google Cloud 的交互式 Shell 环境,可让您通过网络浏览器管理项目和资源。
  5. 转到 Cloud Shell
  6. 在 Cloud Shell 中,将当前项目设置为您的 Google Cloud 项目 ID,并将其存储在 projectid shell 变量中:
      gcloud config set project PROJECT_ID &&
      projectid=PROJECT_ID &&
      echo $projectid
    PROJECT_ID 替换为您的项目 ID。您可以在 Google Cloud 控制台中找到项目 ID。如需了解详情,请参阅查找项目 ID
  7. Enable the IAM, Compute Engine, Notebooks, Cloud Storage, and Vertex AI APIs:

    Roles required to enable APIs

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

    gcloud services enable iam.googleapis.com  compute.googleapis.com notebooks.googleapis.com storage.googleapis.com aiplatform.googleapis.com
  8. Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/aiplatform.user, roles/storage.admin

    gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE

    Replace the following:

    • PROJECT_ID: your project ID.
    • USER_IDENTIFIER: the identifier for your user account—for example, myemail@example.com.
    • ROLE: the IAM role that you grant to your user account.
  9. Vertex AI User (roles/aiplatform.user) IAM 角色提供使用 Vertex AI 中所有资源的权限。借助 Storage Admin (roles/storage.admin) 角色,您可以将文档的训练数据集存储在 Cloud Storage 中。

后续步骤

按照本教程的下一页操作,创建表格数据集并训练分类模型。