|
128 | 128 | " platform: str,\n", |
129 | 129 | " machine_type: str,\n", |
130 | 130 | " accelerator_type: str,\n", |
131 | | - " accelerator_count,\n", |
| 131 | + " accelerator_count: int,\n", |
132 | 132 | " service_account: str = None,\n", |
133 | 133 | " use_dedicated_endpoint: bool = False,\n", |
134 | 134 | " min_replica_count: int = 1,\n", |
|
141 | 141 | " model_type: The model type to deploy, either MAMMUT or OWLVIT.\n", |
142 | 142 | " model_mode: The model mode to deploy, e.g. COMBINED, IMAGE_ONLY or\n", |
143 | 143 | " 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", |
145 | 145 | " machine_type: The instance machine type to use, see\n", |
146 | 146 | " https://cloud.google.com/compute/docs/machine-resource\n", |
147 | 147 | " accelerator_type: The GPU type to deploy, defaults to NVIDIA_L4, see\n", |
|
150 | 150 | " \"\"\"\n", |
151 | 151 | " model_id, model_name, model_path = MODEL_CONFIGS[model_type]\n", |
152 | 152 | "\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", |
160 | 162 | "\n", |
161 | 163 | " model = aiplatform.Model.upload(\n", |
162 | 164 | " display_name=f\"{name}-model\",\n", |
|
227 | 229 | ")" |
228 | 230 | ] |
229 | 231 | }, |
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 | | - }, |
247 | 232 | { |
248 | 233 | "cell_type": "markdown", |
249 | 234 | "metadata": { |
|
274 | 259 | "source": [ |
275 | 260 | "# @title Inference setup & utils.\n", |
276 | 261 | "\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", |
280 | 262 | "import base64\n", |
281 | 263 | "import io\n", |
282 | 264 | "\n", |
|
289 | 271 | " return base64.b64encode(arr_bytes.getvalue()).decode(\"utf-8\")\n", |
290 | 272 | "\n", |
291 | 273 | "\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", |
293 | 278 | "ENDPOINT_ID = \"\" # @param { 'type': 'string' }\n", |
294 | 279 | "use_dedicated_endpoint = True # @param { 'type' : 'boolean' }\n", |
295 | 280 | "\n", |
|
410 | 395 | ")\n", |
411 | 396 | "print(result)" |
412 | 397 | ] |
| 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 | + ] |
413 | 415 | } |
414 | 416 | ], |
415 | 417 | "metadata": { |
|
0 commit comments