ladderlore
请求新指南
  • 输入服务名称,例如 S3 或 IAM。

概念

Containers for ML: images, ECR and own containers

Prebuilt images, extending them, own containers, and Amazon ECR.

本课尚未翻译,暂以英文显示。

Dockerfile and code
Amazon ECR
Training job or endpoint
Image scan
  1. 1Build the image and push it to Amazon ECR.
  2. 2SageMaker AI pulls the image with the execution role and runs it.
From code to a running job. SageMaker AI pulls from ECR with the execution role.
  • 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
The own-container contract.

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

2 / 2

  • Web server

    Training
    None needed
    Inference
    Port 8080, GET /ping
  • Failure

    Training
    Write /opt/ml/output/failure
    Inference
    /ping not 200
The own-container contract.

是什么

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.