Skip to content

Commit 646532e

Browse files
vertex-mg-botcopybara-github
authored andcommitted
Fixed the deployment quota check and modified the documentation.
PiperOrigin-RevId: 832174331
1 parent 9e96a3d commit 646532e

1 file changed

Lines changed: 32 additions & 30 deletions

File tree

notebooks/community/model_garden/model_garden_remote_sensing_deployment.ipynb

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
" platform: str,\n",
129129
" machine_type: str,\n",
130130
" accelerator_type: str,\n",
131-
" accelerator_count,\n",
131+
" accelerator_count: int,\n",
132132
" service_account: str = None,\n",
133133
" use_dedicated_endpoint: bool = False,\n",
134134
" min_replica_count: int = 1,\n",
@@ -141,7 +141,7 @@
141141
" model_type: The model type to deploy, either MAMMUT or OWLVIT.\n",
142142
" model_mode: The model mode to deploy, e.g. COMBINED, IMAGE_ONLY or\n",
143143
" TEXT_ONLY.\n",
144-
" platform: The deployment platform, CPU, NVIDIA_L4 or NVIDIA_A100_80GB.\n",
144+
" platform: The deployment platform, either \"cpu\" or \"gpu\".\n",
145145
" machine_type: The instance machine type to use, see\n",
146146
" https://cloud.google.com/compute/docs/machine-resource\n",
147147
" accelerator_type: The GPU type to deploy, defaults to NVIDIA_L4, see\n",
@@ -150,13 +150,15 @@
150150
" \"\"\"\n",
151151
" model_id, model_name, model_path = MODEL_CONFIGS[model_type]\n",
152152
"\n",
153-
" common_util.check_quota(\n",
154-
" project_id=PROJECT_ID,\n",
155-
" region=REGION,\n",
156-
" accelerator_type=accelerator_type,\n",
157-
" accelerator_count=accelerator_count,\n",
158-
" is_for_training=False,\n",
159-
" )\n",
153+
" if platform != \"cpu\":\n",
154+
" # Check quota only when using accelerators (GPU).\n",
155+
" common_util.check_quota(\n",
156+
" project_id=PROJECT_ID,\n",
157+
" region=REGION,\n",
158+
" accelerator_type=accelerator_type,\n",
159+
" accelerator_count=accelerator_count,\n",
160+
" is_for_training=False,\n",
161+
" )\n",
160162
"\n",
161163
" model = aiplatform.Model.upload(\n",
162164
" display_name=f\"{name}-model\",\n",
@@ -227,23 +229,6 @@
227229
")"
228230
]
229231
},
230-
{
231-
"cell_type": "code",
232-
"execution_count": null,
233-
"metadata": {
234-
"cellView": "form",
235-
"id": "OXApz2t7YCfZ"
236-
},
237-
"outputs": [],
238-
"source": [
239-
"# @title Cleanup Resources\n",
240-
"# @markdown Delete the experiment models and endpoints to recycle the resources\n",
241-
"# @markdown and avoid unnecessary continuous charges that may incur.\n",
242-
"\n",
243-
"endpoint.delete(force=True)\n",
244-
"model.delete()"
245-
]
246-
},
247232
{
248233
"cell_type": "markdown",
249234
"metadata": {
@@ -274,9 +259,6 @@
274259
"source": [
275260
"# @title Inference setup & utils.\n",
276261
"\n",
277-
"# @markdown If you've just deployed a new endpoint you can use it directly,\n",
278-
"# @markdown otherwise specify an endpoint id to override it.\n",
279-
"\n",
280262
"import base64\n",
281263
"import io\n",
282264
"\n",
@@ -289,7 +271,10 @@
289271
" return base64.b64encode(arr_bytes.getvalue()).decode(\"utf-8\")\n",
290272
"\n",
291273
"\n",
292-
"# Override the endpoint, if kept empty uses the recently deployed endpoint.\n",
274+
"# @markdown **(Optional)** Override the endpoint id.\n",
275+
"# @markdown *Note: If kept empty uses the recently deployed endpoint.*\n",
276+
"# @markdown *Note: Make sure to use the endpoid id from the previous cell output*\n",
277+
"# @markdown * (Not the endpoint name used above)*\n",
293278
"ENDPOINT_ID = \"\" # @param { 'type': 'string' }\n",
294279
"use_dedicated_endpoint = True # @param { 'type' : 'boolean' }\n",
295280
"\n",
@@ -410,6 +395,23 @@
410395
")\n",
411396
"print(result)"
412397
]
398+
},
399+
{
400+
"cell_type": "code",
401+
"execution_count": null,
402+
"metadata": {
403+
"cellView": "form",
404+
"id": "quCzxT0WB_Ts"
405+
},
406+
"outputs": [],
407+
"source": [
408+
"# @title Cleanup Resources\n",
409+
"# @markdown Delete the experiment models and endpoints to recycle the resources\n",
410+
"# @markdown and avoid unnecessary continuous charges that may incur.\n",
411+
"\n",
412+
"endpoint.delete(force=True)\n",
413+
"model.delete()"
414+
]
413415
}
414416
],
415417
"metadata": {

0 commit comments

Comments
 (0)