By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
(SageMaker Built-in, TensorFlow, PyTorch, Hugging Face, MXNet)
Deep Learning (DL) on AWS enables scalable training and deployment of neural networks for tasks like computer vision, NLP, and recommendation systems. AWS SageMaker provides managed infrastructure for frameworks like TensorFlow, PyTorch, Hugging Face, and MXNet, eliminating the need to manage clusters. Real-world scenario: A fintech company deploys a fine-tuned Hugging Face BERT model on SageMaker to detect fraudulent transactions in real time, using SageMaker Endpoints for low-latency inference and SageMaker Model Monitor to track drift.
ml.p3.8xlarge
smdistributed
763104351884.dkr.ecr.us-east-1.amazonaws.com/tensorflow-training:2.10.0-gpu-py39
torch.distributed
huggingface-pytorch-inference:1.13.1-transformers4.26.0-gpu-py39
distilbert-base-uncased
Or bring your own fine-tuned model (e.g., from Hugging Face Hub).
Package the Model for SageMaker
inference.py
model_fn
input_fn
predict_fn
output_fn
Example: python def model_fn(model_dir): from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained(model_dir) return model
python def model_fn(model_dir): from transformers import AutoModelForSequenceClassification model = AutoModelForSequenceClassification.from_pretrained(model_dir) return model
Create a SageMaker Model
Define the Model object: python from sagemaker.huggingface import HuggingFaceModel huggingface_model = HuggingFaceModel( model_data="s3://your-bucket/model.tar.gz", role=role, transformers_version="4.26.0", pytorch_version="1.13.1", py_version="py39" )
Model
python from sagemaker.huggingface import HuggingFaceModel huggingface_model = HuggingFaceModel( model_data="s3://your-bucket/model.tar.gz", role=role, transformers_version="4.26.0", pytorch_version="1.13.1", py_version="py39" )
Deploy to an Endpoint
huggingface_model.deploy()
ml.g4dn.xlarge
Enable auto-scaling via Application Auto Scaling: python from sagemaker import get_execution_role role = get_execution_role() predictor = huggingface_model.deploy( initial_instance_count=1, instance_type="ml.g4dn.xlarge", endpoint_name="hf-endpoint" )
python from sagemaker import get_execution_role role = get_execution_role() predictor = huggingface_model.deploy( initial_instance_count=1, instance_type="ml.g4dn.xlarge", endpoint_name="hf-endpoint" )
Monitor for Drift
Set up CloudWatch Alarms for latency/errors.
Optimize for Cost
ml.m5.large
ml.p3
ml.g4dn
m5
distribution
Estimator
distribution={"smdistributed": {"dataparallel": {"enabled": True}}}
transformers
pytorch
Hugging Face: Use for NLP tasks (e.g., text classification, summarization). Not for tabular data.
Distributed Training Gotchas
smdistributed.dataparallel
Model Parallelism: Splits layers across GPUs (use smdistributed.modelparallel). Exam loves this distinction!
smdistributed.modelparallel
Endpoint Cost Optimization
Multi-Model Endpoints (MMEs): Share a single endpoint across multiple models (e.g., A/B testing).
Model Monitoring
Answer: SageMaker Real-Time Endpoint with GPU instance (e.g., ml.g4dn.xlarge). Auto-scaling can handle the load, and GPUs reduce latency for transformer models.
A company wants to train a ResNet50 model on 100TB of images with 100 GPUs. Which SageMaker feature enables this?
Answer: SageMaker Distributed Training with smdistributed.dataparallel. This shards batches across GPUs for scalable training.
An ML engineer notices their PyTorch model’s inference latency is 500ms, but the SLA requires <200ms. What’s the fastest way to fix this?
763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:1.12.0-gpu-py38
transformers_version
pytorch_version
py_version
HuggingFaceModel
ml_c5
ml_c5.neo
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.