mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
Fixed the deployment quota check and modified the documentation.
PiperOrigin-RevId: 832174331
This commit is contained in:
committed by
Copybara-Service
parent
9e96a3da67
commit
646532ea69
@@ -128,7 +128,7 @@
|
||||
" platform: str,\n",
|
||||
" machine_type: str,\n",
|
||||
" accelerator_type: str,\n",
|
||||
" accelerator_count,\n",
|
||||
" accelerator_count: int,\n",
|
||||
" service_account: str = None,\n",
|
||||
" use_dedicated_endpoint: bool = False,\n",
|
||||
" min_replica_count: int = 1,\n",
|
||||
@@ -141,7 +141,7 @@
|
||||
" model_type: The model type to deploy, either MAMMUT or OWLVIT.\n",
|
||||
" model_mode: The model mode to deploy, e.g. COMBINED, IMAGE_ONLY or\n",
|
||||
" TEXT_ONLY.\n",
|
||||
" platform: The deployment platform, CPU, NVIDIA_L4 or NVIDIA_A100_80GB.\n",
|
||||
" platform: The deployment platform, either \"cpu\" or \"gpu\".\n",
|
||||
" machine_type: The instance machine type to use, see\n",
|
||||
" https://cloud.google.com/compute/docs/machine-resource\n",
|
||||
" accelerator_type: The GPU type to deploy, defaults to NVIDIA_L4, see\n",
|
||||
@@ -150,13 +150,15 @@
|
||||
" \"\"\"\n",
|
||||
" model_id, model_name, model_path = MODEL_CONFIGS[model_type]\n",
|
||||
"\n",
|
||||
" common_util.check_quota(\n",
|
||||
" project_id=PROJECT_ID,\n",
|
||||
" region=REGION,\n",
|
||||
" accelerator_type=accelerator_type,\n",
|
||||
" accelerator_count=accelerator_count,\n",
|
||||
" is_for_training=False,\n",
|
||||
" )\n",
|
||||
" if platform != \"cpu\":\n",
|
||||
" # Check quota only when using accelerators (GPU).\n",
|
||||
" common_util.check_quota(\n",
|
||||
" project_id=PROJECT_ID,\n",
|
||||
" region=REGION,\n",
|
||||
" accelerator_type=accelerator_type,\n",
|
||||
" accelerator_count=accelerator_count,\n",
|
||||
" is_for_training=False,\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" model = aiplatform.Model.upload(\n",
|
||||
" display_name=f\"{name}-model\",\n",
|
||||
@@ -227,23 +229,6 @@
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"cellView": "form",
|
||||
"id": "OXApz2t7YCfZ"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title Cleanup Resources\n",
|
||||
"# @markdown Delete the experiment models and endpoints to recycle the resources\n",
|
||||
"# @markdown and avoid unnecessary continuous charges that may incur.\n",
|
||||
"\n",
|
||||
"endpoint.delete(force=True)\n",
|
||||
"model.delete()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
@@ -274,9 +259,6 @@
|
||||
"source": [
|
||||
"# @title Inference setup & utils.\n",
|
||||
"\n",
|
||||
"# @markdown If you've just deployed a new endpoint you can use it directly,\n",
|
||||
"# @markdown otherwise specify an endpoint id to override it.\n",
|
||||
"\n",
|
||||
"import base64\n",
|
||||
"import io\n",
|
||||
"\n",
|
||||
@@ -289,7 +271,10 @@
|
||||
" return base64.b64encode(arr_bytes.getvalue()).decode(\"utf-8\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Override the endpoint, if kept empty uses the recently deployed endpoint.\n",
|
||||
"# @markdown **(Optional)** Override the endpoint id.\n",
|
||||
"# @markdown *Note: If kept empty uses the recently deployed endpoint.*\n",
|
||||
"# @markdown *Note: Make sure to use the endpoid id from the previous cell output*\n",
|
||||
"# @markdown * (Not the endpoint name used above)*\n",
|
||||
"ENDPOINT_ID = \"\" # @param { 'type': 'string' }\n",
|
||||
"use_dedicated_endpoint = True # @param { 'type' : 'boolean' }\n",
|
||||
"\n",
|
||||
@@ -410,6 +395,23 @@
|
||||
")\n",
|
||||
"print(result)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"cellView": "form",
|
||||
"id": "quCzxT0WB_Ts"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# @title Cleanup Resources\n",
|
||||
"# @markdown Delete the experiment models and endpoints to recycle the resources\n",
|
||||
"# @markdown and avoid unnecessary continuous charges that may incur.\n",
|
||||
"\n",
|
||||
"endpoint.delete(force=True)\n",
|
||||
"model.delete()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in New Issue
Block a user