‹ All MLA-C01 questions

MLA-C01 Practice Question 56: External Model Artifact Packaging

AWS Certified Machine Learning Engineer – Associate (MLA-C01) · Test 6 · question 6 of 10

Model Developmentmedium

A data scientist trained a scikit-learn model on a laptop and saved it as model.joblib, along with an inference.py script that loads it. To host it, an engineer uploaded both files to s3://ml-models/churn/ and called CreateModel with the SageMaker AI prebuilt scikit-learn inference container, setting ModelDataUrl to s3://ml-models/churn/model.joblib. Endpoint creation fails, and the container logs show that the model directory /opt/ml/model is empty.

What should the engineer do to host the existing model?

Select one answer
Show answer and explanation

Answer:

  • C. Package the model file and inference code into one model.tar.gz archive, upload it to S3, and point ModelDataUrl at that archive

SageMaker AI hosting expects model artifacts as a single compressed tar file. ModelDataUrl must point to a tar.gz file, or SageMaker AI does not download it, which is why /opt/ml/model is empty. A model trained inside SageMaker AI is saved in this format automatically. A model trained elsewhere has to be packaged that way by hand, and SageMaker AI then decompresses the archive into /opt/ml/model before the container starts. With the archive in place, the prebuilt scikit-learn container can load the existing model as it is (option C).

- A is wrong because retraining is unnecessary. The model is already trained, and the only problem is how its artifact is packaged. - B is wrong because it would work, but it takes on building and maintaining a custom image to get around a packaging mistake, when the prebuilt container already serves scikit-learn models. - D is wrong because the file format of the model is not the issue. A single .onnx file is still not a tar.gz archive, so it would be skipped in exactly the same way.

Reference: Custom Inference Code with Hosting Services - How SageMaker AI Loads Your Model Artifacts

Practice Test 6 ›

Study guides for MLA-C01