I see on this page, deploying a model to sagemaker is very easy with a few lines of python
This issue is version control and envrironment control. My team is using terraform to manage cloud resources and would like this be setup with terraform and not just some arbitrary python code.
absn
May 23, 2024, 11:28pm
2
Hi
I used these two pages to help me do that:
# ------------------------------------------------------------------------------
# Local configurations
# ------------------------------------------------------------------------------
locals {
framework_version = var.pytorch_version != null ? var.pytorch_version : var.tensorflow_version
repository_name = var.pytorch_version != null ? "huggingface-pytorch-inference" : "huggingface-tensorflow-inference"
device = length(regexall("^ml\\.[g|p{1,3}\\.$]", var.instance_type)) > 0 ? "gpu" : "cpu"
image_key = "${local.framework_version}-${local.device}"
pytorch_image_tag = {
"1.7.1-gpu" = "1.7.1-transformers${var.transformers_version}-gpu-py36-cu110-ubuntu18.04"
"1.7.1-cpu" = "1.7.1-transformers${var.transformers_version}-cpu-py36-ubuntu18.04"
"1.8.1-gpu" = "1.8.1-transformers${var.transformers_version}-gpu-py36-cu111-ubuntu18.04"
"1.8.1-cpu" = "1.8.1-transformers${var.transformers_version}-cpu-py36-ubuntu18.04"
"1.9.1-gpu" = "1.9.1-transformers${var.transformers_version}-gpu-py38-cu111-ubuntu20.04"
"1.9.1-cpu" = "1.9.1-transformers${var.transformers_version}-cpu-py38-ubuntu20.04"
"1.10.2-cpu" = "1.10.2-transformers${var.transformers_version}-cpu-py38-ubuntu20.04"
"1.10.2-gpu" = "1.10.2-transformers${var.transformers_version}-gpu-py38-cu113-ubuntu20.04"
This file has been truncated. show original
in the end my terraform became something like this:
resource "aws_sagemaker_model" "mymodel" {
name = "mymodel"
execution_role_arn = ...
primary_container {
image = "763104351884.dkr.ecr.ap-southeast-2.amazonaws.com/huggingface-pytorch-tgi-inference:2.1.1-tgi2.0.0-gpu-py310-cu121-ubuntu22.04-v2.0"
environment = {
HF_TASK = "question-answering"
HF_MODEL_ID = "meta-llama/Meta-Llama-3-8B-Instruct"
HF_API_TOKEN = "mytoken"
}
}
}
hope that helps