Skip to content

Instantly share code, notes, and snippets.

@dice89
Created October 31, 2018 14:57
Show Gist options
  • Save dice89/daed4c48f972db649d2b7efd8795d156 to your computer and use it in GitHub Desktop.
Save dice89/daed4c48f972db649d2b7efd8795d156 to your computer and use it in GitHub Desktop.
Create GPU enable Instance with Terraform
resource "google_compute_instance" "gpu-vm" {
count = 1
name = "gpu-vm"
machine_type = "n1-standard-4" // 1 CPU 16 Gig of RAM
zone = "${var.region}" // Call it from variable "region"
tags = ["http"]
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1604-lts"
size = 50 // 50 GB Storage
}
}
network_interface {
network = "default"
access_config {
// Ephemeral IP - leaving this block empty will generate a new external IP and assign it to the machine
}
}
guest_accelerator{
type = "nvidia-tesla-k80" // Type of GPU attahced
count = 1 // Num of GPU attached
}
scheduling{
on_host_maintenance = "TERMINATE" // Need to terminate GPU on maintenance
}
metadata_startup_script = "${file("start-up-script.sh")}" // Here we will add the env setup
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment