园地由预部署的 Vertex AI 在线预测端点提供支持,不会产生费用。打开支持的模型对应的模型卡片后,您可以使用试用面板,通过发送文本提示来快速测试模型的功能。您还可以设置一些最常见的参数,例如温度和输出 token 数量。园地仅限文本输入和输出。
启动空间后,您将获得一个可正常运行的 Web 应用,该应用已准备就绪可供使用,与部署模型并构建应用以使用模型端点相比,所需的手动工作量要少得多。Model Garden 会在 Vertex AI 中部署您选择的模型,并在一个 Cloud Run 实例上部署使用所部署模型端点的示例应用。该应用还可以使用现有端点或 MaaS 端点。
如需启动模型,请打开支持的模型对应的模型卡片,然后在试用空间面板中,点击某个空间以启动它。您需要为部署所用的机器以及托管应用的 Cloud Run 实例付费。
准备工作
本教程要求您设置 Google Cloud 项目并启用 Vertex AI API。
- 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.
-
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
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
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. -
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
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
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. 在 Google Cloud 控制台中,前往支持的模型的模型卡片,例如 Gemma 2 模型卡片。
在试用面板中:
- 对于区域,接受默认值或选择您的区域。
- 对于端点,选择演示园地。
- 在提示框中,输入
Why is the sky blue?
。 - 展开高级选项部分,然后查看默认参数。
点击提交。输出会出现在“提交”按钮下方。
- BLIP 图片标注
- BLIP VQA
- BLIP2
- Flux
- Gemma 2
- Gemma 3
- Gemini 2.5 Flash
- Gemini 2.5 Pro
- Instant ID
- Llama 3.2
- Llama 3.3
- Llama 4
- Llama 3.2 90B
- Llama 4 Maverick 17B-128E
- LLaVA 1.5 和 LLaVA-NeXT
- Mistral 自行托管(7B 和 Nemo)
- PaliGemma 1 和 2
- Phi-3
- Phi-4
- Qwen2
- Stable Diffusion Inpainting
- Stable Diffusion v2.1
- Stable Diffusion XL LCM
- Stable Diffusion XL Lightning
- Stable Diffusion XL
- DeepSeek R1 (0528)
- Cloud Run Admin API (
run.googleapis.com
) - Artifact Registry API (
artifactregistry.googleapis.com
) - Cloud Build API (
cloudbuild.googleapis.com
) - Cloud Logging API (
logging.googleapis.com
) - Vertex AI Service Agent (
roles/aiplatform.serviceAgent
) - Cloud Build Service Account (
roles/cloudbuild.builds.builder
) storage.buckets.create
run.services.create
artifactregistry.repositories.create
run.services.setIamPolicy
在 Google Cloud 控制台中,前往 Model Garden 以查看模型的模型卡片。
选择要使用的模型。支持的模型具有试用空间面板,例如 Gemma 3 模型卡片。
点击 rocket_launch 运行以启动空间。
- 您可以选择需要进行身份验证(通过 Identity-Aware Proxy)或允许公开访问。如需了解详情,请参阅为首次部署启用 API 并授予权限。
- 点击创建新服务以开始部署。您可以在模型卡片中监控部署状态。
当空间状态变为准备就绪后,点击它即可查看有关部署的详细信息。
为了提供基本保护,Web 应用需要一个密钥,该密钥在提交提示时必须附加到网址中。此密钥在密钥字段中提供。
- 点击打开可开始使用应用。您可以在应用内向模型发送提示并查看其回答。
您可以共享网址,以便其他人也可以试用应用。
- 如需关闭对应用的访问权限,请点击访问权限控制字段中的 修改。
在 Cloud Run 应用的安全标签页中,选择需要进行身份验证,然后点击保存。应用便再也无法通过相应网址访问。访问相应网址会导致 403 错误(禁止访问)。
在 Google Cloud 控制台中,查看 Cloud Run 服务列表:
找到要删除的服务,然后选择该服务。
点击 delete 删除。这将删除服务的所有修订版本。
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
试用园地
试用空间
您可以启动包含 Gemini、Gemma、Llama 和 Stable Diffusion 等模型的空间。以下列表是支持的内容的示例:
IAM 权限
除了使用 Vertex AI 所需的现有权限之外,您还必须拥有以下权限才能启动空间:
操作 | 所需权限 | 用途 |
---|---|---|
启用其他 API | serviceusage.services.enable |
启用以下 API:
|
授予服务账号权限 | resourcemanager.projects.setIamPolicy |
向 Compute Engine 默认服务账号授予以下角色:
|
部署特定权限 |
|
在部署期间,一组源代码将上传到 Cloud Storage,然后部署到 Cloud Run,并创建一个新服务。需要具备 artifactregistry.repositories.create 才能为容器映像创建仓库。需要具备 run.services.setIamPolicy 才能使服务可公开访问。
|
如果您是项目的所有者,则无需执行其他操作,只需按照 Vertex AI Studio 中的指南操作即可。如果您不是项目的所有者,请让项目管理员执行前两项操作,然后向您授予 Editor (roles/editor
) 和 Cloud Run Admin (roles/run.admin
) 角色。
启动空间
启动空间,以测试和尝试来自示例 Gradio 应用的模型。
清理
为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。
删除空间
如需清理空间,您必须删除模型资源和 Cloud Run 上的示例应用资源。
删除模型资源
在 Gradio 应用中,您可以删除模型端点以清理 Vertex AI 资源。然后,您需要删除 Cloud Run 服务,以停止并删除 Gradio 应用。
如需手动删除 Vertex AI 资源,请参阅取消部署模型并删除资源。
删除 Cloud Run 服务
删除与服务相关的资源,包括服务的所有修订版本。删除服务不会删除 Artifact Registry 中的容器映像等项目。如需了解详情,请参阅 Cloud Run 文档中的管理服务。
删除项目
为了避免产生费用,最简单的方法是删除您为本教程创建的项目。
要删除项目,请执行以下操作:
后续步骤
查看 Model Garden 概览。