SageMaker Containers

raw JSON →
2.8.6.post2 verified Mon Apr 27 auth: no python deprecated

Open source library for creating containers to run on Amazon SageMaker. Version 2.8.6.post2. This library is deprecated and no longer actively maintained; users should migrate to the SageMaker Training Toolkit and Inference Toolkit.

pip install sagemaker-containers
error ModuleNotFoundError: No module named 'sagemaker_containers'
cause Package not installed or environment misconfigured (e.g., running outside SageMaker).
fix
Run 'pip install sagemaker-containers' inside the container.
error AttributeError: module 'sagemaker_containers' has no attribute 'beta'
cause The beta subpackage was removed or renamed in newer releases of the replacement toolkit.
fix
Use 'from sagemaker_training import environment' instead.
error ImportError: cannot import name 'training_env' from 'sagemaker_containers.beta.framework'
cause Typo or incorrect subpackage path.
fix
Correct import: 'from sagemaker_containers.beta import framework' then use 'framework.training_env()'.
deprecated This library is deprecated. Use sagemaker-training-toolkit or sagemaker-inference-toolkit instead.
fix Replace imports: 'sagemaker_containers' -> 'sagemaker_training' for training, or 'sagemaker_inference' for inference.
gotcha The beta subpackage (sagemaker_containers.beta) is not stable and may change.
fix Avoid relying on beta subpackages; use the stable sagemaker_training toolkit.
gotcha Python 2 support was dropped in later versions. Version 2.8.2 mentioned creating __init__ for Python 2 protobuf import, but newer releases do not support Python 2.
fix Use Python 3.6+ for versions after 2.8.2.

Initialize a SageMaker container environment and print the current host.

import sagemaker_containers

# Example: create a training environment
from sagemaker_containers.beta import framework

env = framework.training_env()
print(env.current_host, env.hosts)

# Note: This library is deprecated. Prefer sagemaker-training-toolkit for training containers.