From 9fefca16b45e25808af2547fc0db6ac3f1d00f12 Mon Sep 17 00:00:00 2001 From: askubis Date: Wed, 29 Nov 2023 18:50:12 +0100 Subject: [PATCH] feat(compute): Instance Template with GPUs example (#534) * Added example for Zonal MIGs * Update compute/zonal_instance_group_manager/main.tf Co-authored-by: Sampath Kumar * Update compute/zonal_instance_group_manager/main.tf Co-authored-by: Sampath Kumar * Update compute/zonal_instance_group_manager/main.tf Co-authored-by: Sampath Kumar * changed base instance name for instances in the mig * added example for instance template with GPU --------- Co-authored-by: Sampath Kumar Co-authored-by: Sampath Kumar --- compute/instance_template_with_gpu/main.tf | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 compute/instance_template_with_gpu/main.tf diff --git a/compute/instance_template_with_gpu/main.tf b/compute/instance_template_with_gpu/main.tf new file mode 100644 index 000000000..03643379a --- /dev/null +++ b/compute/instance_template_with_gpu/main.tf @@ -0,0 +1,51 @@ +/** + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Made to resemble + * gcloud compute instance-templates create gpu-template \ + * --machine-type n1-standard-2 \ + * --boot-disk-size 250GB \ + * --accelerator type=nvidia-tesla-t4,count=1 \ + * --image-family debian-11 \ + * --image-project debian-cloud \ + * --maintenance-policy TERMINATE \ + * --restart-on-failure +*/ + +# [START compute_template_gpu] +resource "google_compute_instance_template" "default" { + name = "gpu-template" + machine_type = "n1-standard-2" + + disk { + source_image = "debian-cloud/debian-11" + disk_size_gb = 250 + } + + network_interface { + network = "default" + } + guest_accelerator { + type = "nvidia-tesla-t4" + count = 1 + } + scheduling { + automatic_restart = true + on_host_maintenance = "TERMINATE" + } + +} +# [END compute_template_gpu]