Skip to content

Commit

Permalink
add gpu support (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall authored Nov 19, 2024
1 parent 9e67f9b commit c76a6b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
7 changes: 4 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ terraform {
}
google = {
source = "hashicorp/google"
version = "5.29.1"
version = "6.11.2"
}
}

Expand Down Expand Up @@ -88,10 +88,11 @@ module "whisper" {
image = "us-docker.pkg.dev/${var.project}/shared/scyllaridae-whisper:main",
port = 8080
liveness_probe = "/healthcheck"
memory = "4Gi"
cpu = "4000m"
memory = "16Gi"
gpus = 1
}
])
regions = ["us-central1"]
providers = {
google = google.default
docker = docker.local
Expand Down
17 changes: 11 additions & 6 deletions modules/cloudrun/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
google = {
source = "hashicorp/google"
version = "= 5.29.1"
version = "= 6.11.2"
}
}
}
Expand Down Expand Up @@ -45,7 +45,7 @@ resource "google_cloud_run_service" "cloudrun" {
"run.googleapis.com/execution-environment" : "gen2",
"autoscaling.knative.dev/minScale" : var.min_instances,
"autoscaling.knative.dev/maxScale" : var.max_instances,
"run.googleapis.com/cpu-throttling" : true,
"run.googleapis.com/cpu-throttling" : var.containers[0].gpus == "",
}
}
spec {
Expand Down Expand Up @@ -99,10 +99,15 @@ resource "google_cloud_run_service" "cloudrun" {
}

resources {
limits = {
cpu = containers.value.cpu
memory = containers.value.memory
}
limits = merge(
{
memory = containers.value.memory
},
containers.value.gpus != "" ? {
"nvidia.com/gpu" = containers.value.gpus
} : { cpu = containers.value.cpu
}
)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions modules/cloudrun/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ variable "containers" {
memory = optional(string, "512Mi")
cpu = optional(string, "1000m")
liveness_probe = optional(string, "")
gpus = optional(string, "")
}))
}

Expand Down

0 comments on commit c76a6b9

Please sign in to comment.