概念
Containers for ML: images, ECR and own containers
Prebuilt images, extending them, own containers, and Amazon ECR.
このレッスンはまだ翻訳されていないため、英語で表示しています。
- 1Build the image and push it to Amazon ECR.
- 2SageMaker AI pulls the image with the execution role and runs it.
Start command
- Training
- train
- Inference
- serve
Input
- Training
- /opt/ml/input/data/channel
- Inference
- POST /invocations
Model files
- Training
- Write to /opt/ml/model
- Inference
- Read from /opt/ml/model
Web server
- Training
- None needed
- Inference
- Port 8080, GET /ping
Failure
- Training
- Write /opt/ml/output/failure
- Inference
- /ping not 200
| Item | Training | Inference |
|---|---|---|
| Start command | train | serve |
| Input | /opt/ml/input/data/channel | POST /invocations |
| Model files | Write to /opt/ml/model | Read from /opt/ml/model |
| Web server | None needed | Port 8080, GET /ping |
| Failure | Write /opt/ml/output/failure | /ping not 200 |
1 / 2
Start command
- Training
- train
- Inference
- serve
Input
- Training
- /opt/ml/input/data/channel
- Inference
- POST /invocations
Model files
- Training
- Write to /opt/ml/model
- Inference
- Read from /opt/ml/model
| Item | Training | Inference |
|---|---|---|
| Start command | train | serve |
| Input | /opt/ml/input/data/channel | POST /invocations |
| Model files | Write to /opt/ml/model | Read from /opt/ml/model |
2 / 2
Web server
- Training
- None needed
- Inference
- Port 8080, GET /ping
Failure
- Training
- Write /opt/ml/output/failure
- Inference
- /ping not 200
| Item | Training | Inference |
|---|---|---|
| Web server | None needed | Port 8080, GET /ping |
| Failure | Write /opt/ml/output/failure | /ping not 200 |
概要
Start with a prebuilt AWS Deep Learning Container for PyTorch, TensorFlow or Hugging Face. It comes with the framework, the drivers and the SageMaker toolkit. To add a library, extend the image: write a Dockerfile that starts FROM the prebuilt image and installs what you need. If only a Python package is missing, script mode with a requirements file avoids a rebuild. Build your own image only when no prebuilt one fits.
概要
An own container follows a contract. For training, SageMaker AI runs the image with the argument train. It mounts data under /opt/ml/input/data/ one folder per channel, and hyperparameters under /opt/ml/input/config. Your code writes the model to /opt/ml/model and a failure reason to /opt/ml/output/failure. For inference, SageMaker AI runs the image with serve, puts the extracted model artifacts in /opt/ml/model, and calls your web server on port 8080: GET /ping must return 200 when healthy, and POST /invocations returns predictions. Requests are limited to 25 MB and 60 seconds.
概要
Push the image to Amazon ECR: log in with aws ecr get-login-password, then docker build, tag and push. SageMaker AI pulls it with the execution role, which needs ecr:GetAuthorizationToken, ecr:BatchGetImage and ecr:GetDownloadUrlForLayer. Turn on image scanning in ECR, on push or continuously with Amazon Inspector, to find known vulnerabilities.
覚えること
- Prebuilt Deep Learning Containers cover the main frameworks.
- Extend a prebuilt image with FROM and install extra libraries. Script mode can add packages without a rebuild.
- Training: run with train, data in /opt/ml/input/data, model to /opt/ml/model, errors to /opt/ml/output/failure.
- Inference: run with serve, port 8080, GET /ping, POST /invocations.
覚えること
- The execution role needs ECR pull permissions. Turn on ECR image scanning.
試験では
- “Add one extra Python library to a PyTorch training job” points to extending the prebuilt image, or script mode with requirements.
- “Endpoint fails its health check with a custom container” points to /ping not returning 200 on port 8080.
- “Training job cannot pull the image from ECR” points to missing ECR permissions on the execution role.
- “Find known vulnerabilities in the image” points to ECR image scanning.
このタスクの内容 · 3.2
- Provisioned vs on-demand resources
- IaC for ML: CloudFormation, CDK and Service Catalog
- Containers for ML: images, ECR and own containers
- ECS, EKS and Batch for ML workloads
- SageMaker endpoints in a VPC
- Auto scaling endpoints and choosing metrics
- Scaling GPU and LLM workloads
Knowledge Bases
- Retrieval pipelines
- Agent state and memory management
- Agentic workflow infrastructure