Chapter 3: Cloud Training (AWS, GCP, Azure)
Platform Comparison
| Feature | AWS SageMaker | GCP Vertex AI | Azure ML |
|---|---|---|---|
| Notebooks | ✅ | ✅ | ✅ |
| AutoML | ✅ | ✅ | ✅ |
| Pipelines | ✅ | ✅ | ✅ |
| Spot/Preemptible | ✅ | ✅ | ✅ |
| MLflow Integration | ✅ | ✅ | ✅ |
AWS SageMaker Example
import sagemaker
from sagemaker.pytorch import PyTorch
estimator = PyTorch(
entry_point='train.py',
source_dir='src/',
role=sagemaker.get_execution_role(),
instance_count=2,
instance_type='ml.p3.2xlarge',
framework_version='2.0',
py_version='py310',
hyperparameters={
'epochs': 10,
'batch-size': 32,
'learning-rate': 0.001
},
use_spot_instances=True,
max_wait=3600, # Max wait time for spot
checkpoint_s3_uri='s3://bucket/checkpoints/'
)
estimator.fit({'training': 's3://bucket/data/train/'})
Cost Optimization Tips
- Use spot/preemptible instances - 60-90% savings
- Right-size instances - Don't over-provision
- Auto-shutdown notebooks - Avoid idle charges
- Use checkpointing - Resume interrupted training
Next: Module 5 Quiz