בדף הזה מוסבר איך להגדיר את הפרויקט ב- Google Cloud כדי להשתמש ב-Gemini Enterprise Agent Platform, ואיך להוריד קוד TensorFlow לאימון. בנוסף, תורידו קוד לאפליקציית אינטרנט שמקבלת חיזויים.
המדריך הזה כולל כמה דפים:הגדרת הפרויקט והסביבה.
בכל דף מניחים שכבר ביצעתם את ההוראות מהדפים הקודמים של המדריך.
לפני שמתחילים
במדריך הזה משתמשים במסוף Google Cloud וב-Cloud Shell כדי ליצור אינטראקציה עם Google Cloud. במקום Cloud Shell, אתם יכולים להשתמש במעטפת Bash אחרת שמותקן בה Google Cloud CLI.
- נכנסים לחשבון Google Cloud . אנחנו ממליצים למשתמשים חדשים ב- Google Cloud ליצור חשבון כדי שיוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
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.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Gemini Enterprise Agent Platform and Cloud Run functions APIs, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
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.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Gemini Enterprise Agent Platform and Cloud Run functions APIs, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
מפעילים את Cloud Shell במסוף Google Cloud .
בחלק התחתון של מסוף Google Cloud יתחיל סשן של Cloud Shell ותופיע הודעה של שורת הפקודה. Cloud Shell היא סביבת מעטפת שבה ה-CLI של Google Cloud מותקן ומוגדרים ערכים לפרויקט הקיים. הסשן יופעל תוך כמה שניות.
-
אם לא מופיע
(PROJECT_ID)$בהנחיה של Cloud Shell (כאשר PROJECT_ID מוחלף ב Google Cloud מזהה הפרויקט), מריצים את הפקודה הבאה כדי להגדיר את Cloud Shell להשתמש בפרויקט:gcloud config set project PROJECT_ID
יצירת קטגוריה של Cloud Storage
יוצרים קטגוריה אזורית של Cloud Storage באזור us-central1, כדי להשתמש בה בהמשך המדריך. במהלך המדריך, תשתמשו בקטגוריה לכמה מטרות:
- אחסון קוד אימון ש-Agent Platform ישתמש בו במשימת אימון בהתאמה אישית.
- אחסון פריטי המידע שנוצרו במשימת האימון בהתאמה אישית.
- לארח את אפליקציית האינטרנט שמקבלת חיזויים מנקודת הקצה של Agent Platform.
כדי ליצור את הקטגוריה של Cloud Storage, מריצים את הפקודה הבאה בסשן של Cloud Shell:
gcloud storage buckets create gs://BUCKET_NAME --project=PROJECT_ID --location=us-central1
מחליפים את מה שכתוב בשדות הבאים:
- PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
- BUCKET_NAME: השם שבחרתם לקטגוריה. לדוגמה,
hello_custom_PROJECT_ID. מידע על הדרישות בנוגע לשמות של קטגוריות
הורדת קוד לדוגמה
מורידים קוד לדוגמה לשימוש בשאר חלקי המדריך.
gcloud storage cp gs://cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz - | tar -xzv
כדי להציג את קובצי הקוד לדוגמה, מריצים את הפקודה הבאה:
ls -lpR hello-custom-sample
בספרייה hello-custom-sample יש ארבעה פריטים:
trainer/: ספרייה של קוד TensorFlow Keras לאימון המודל לסיווג פרחים.
setup.py: קובץ תצורה לאריזת הספרייהtrainer/להפצה של קוד מקור ב-Python ש-Agent Platform יכולה להשתמש בה.
function/: ספרייה של קוד Python לפונקציית Cloud Run שיכולה לקבל בקשות חיזוי מדפדפן אינטרנט ולעבד אותן מראש, לשלוח אותן ל-Agent Platform, לעבד את התגובות לחיזוי ולשלוח אותן בחזרה לדפדפן.
webapp/: ספרייה עם קוד ותגי עיצוב לאפליקציית אינטרנט שמקבלת חיזויים לסיווג פרחים מ-Agent Platform.
המאמרים הבאים
כדי להריץ משימת אימון בהתאמה אישית ב-Agent Platform, פועלים לפי ההוראות בדף הבא במדריך.