如果您打算使用 Vertex AI SDK for Python,請確認初始化用戶端的服務帳戶具備 Vertex AI 服務代理 (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 的互動式殼層環境,可讓您透過網路瀏覽器管理專案和資源。 前往 Cloud Shell
- 在 Cloud Shell 中,將目前的專案設為您的 Google Cloud專案 ID,並儲存在
projectid
殼層變數中: 請將 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:
gcloud services enable iam.googleapis.com
compute.googleapis.com notebooks.googleapis.com storage.googleapis.com aiplatform.googleapis.com -
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
PROJECT_ID
with your project ID. -
Replace
USER_IDENTIFIER
with the identifier for your user account. For example,user:myemail@example.com
. - Replace
ROLE
with each individual role.
Vertex AI 使用者 ( - Replace
將 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
roles/aiplatform.user
) IAM 角色可提供使用 Vertex AI 中所有資源的存取權。儲存空間管理員 (roles/storage.admin
) 可讓您將文件的訓練資料集儲存在 Cloud Storage 中。建立 Cloud Storage 值區並複製範例資料集
建立 Cloud Storage 值區,以儲存用於訓練 AutoML 模型的文件。
後續步驟
請參閱本教學課程的下一頁,瞭解如何使用 Vertex AI 控制台建立文字分類資料集,並匯入複製至 Cloud Storage 值區的文件。