1

我有一个公司请求编写一个 terraform 脚本来部署来自 GCP 市场的计算引擎映像?这很可能是深度学习图像。有人可以帮忙吗?

示例图片 - https://console.cloud.google.com/marketplace/details/click-to-deploy-images/deeplearning?q=compute%20engine%20images&id=8857b4a3-f60f-40b2-9b32-22b4428fd256

4

1 回答 1

2

请在此处查看以下示例

resource "random_id" "instance_id" {
  byte_length = 8
}

resource "google_compute_instance" "default" {
  name         = "vm-${random_id.instance_id.hex}"
  machine_type = var.instance_type
  zone         = var.zone

  boot_disk {
    initialize_params {
      image = "deeplearning-platform-release/tf-ent-latest-gpu" # TensorFlow Enterprise
      size  = 50                                                // 50 GB Storage
    }
  }

  network_interface {
    network = "default"
    access_config {}
  }

  guest_accelerator {
    type  = var.gpu_type
    count = var.gpu_count
  }

  scheduling {
    automatic_restart   = true
    on_host_maintenance = "TERMINATE"
  }

  metadata = {
    install-nvidia-driver = "True"
    proxy-mode            = "service_account"
  }

  tags = ["deeplearning-vm"]

  service_account {
    scopes = ["https://www.googleapis.com/auth/cloud-platform"]
  }
}

我最近还在 Terraform 中添加了对 AI Platform Notebooks 的支持

于 2020-07-04T06:12:28.460 回答