如果您计划使用 Python 版 Vertex AI SDK,请确保初始化客户端的服务账号具有 Vertex AI Service Agent (roles/aiplatform.serviceAgent
) IAM 角色。
在本教程的这一部分,您将设置 Google Cloud 项目以使用 Vertex AI 和 Cloud Storage 存储桶(用于存储训练 AutoML 模型的文档)。
本教程包含多个页面:
设置项目和环境。
每个页面均假定您已经按照本教程中之前页面的说明操作。
设置您的项目和环境
在使用 Vertex AI 功能之前,完成以下步骤。
-
In the Google Cloud console, go to the project selector page.
-
Select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
- 打开 Cloud Shell。 Cloud Shell 是 Google Cloud 的互动式 shell 环境,可让您通过网络浏览器管理项目和资源。 转到 Cloud Shell
- 在 Cloud Shell 中,将当前项目设置为您的 Google Cloud项目 ID,并将其存储在
projectid
shell 变量中: 将 PROJECT_ID 替换为您的项目 ID。您可以在 Google Cloud 控制台中找到项目 ID。如需了解详情,请参阅查找项目 ID。gcloud config set project PROJECT_ID && projectid=PROJECT_ID && echo $projectid
-
Enable the IAM, Compute Engine, Notebooks, Cloud Storage, and Vertex AI APIs.
-
Make sure that you have the following role or roles on the project: roles/aiplatform.user, roles/storage.admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
前往 IAM - 选择项目。
- 点击 授予访问权限。
-
在新的主账号字段中,输入您的用户标识符。 这通常是 Google 账号的电子邮件地址。
- 在选择角色列表中,选择一个角色。
- 如需授予其他角色,请点击 添加其他角色,然后添加其他各个角色。
- 点击 Save(保存)。
roles/aiplatform.user
) IAM 角色提供使用 Vertex AI 中所有资源的权限。借助 Storage Admin (roles/storage.admin
),您可以将文档的训练数据集存储在 Cloud Storage 中。创建 Cloud Storage 存储桶并复制示例数据集
创建一个 Cloud Storage 存储桶以存储用于训练 AutoML 模型的文档。
将 PROJECT_ID 变量设置为您的项目 ID。
export PROJECT_ID=PROJECT_ID
设置 BUCKET 变量,您将使用此变量创建 Cloud Storage 存储桶。
export BUCKET=${PROJECT_ID}-lcm
使用
BUCKET
变量在us-central1
区域中创建 Cloud Storage 存储桶。gcloud storage buckets create gs://${BUCKET}/ --project=${PROJECT_ID} --location=us-central1
将
happiness.csv
示例训练数据集复制到存储桶中。gcloud storage cp gs://cloud-ml-data/NL-classification/happiness.csv gs://${BUCKET}/text/ --recursive
后续步骤
按照本教程的下一页操作,使用 Vertex AI 控制台创建文字分类数据集,并将复制的文档导入 Cloud Storage 存储桶。
-