{"id":3796,"library":"sagemaker-train","title":"SageMaker Training (Deprecated)","description":"This library, `sagemaker-train`, is deprecated and no longer maintained. It previously provided functionalities for defining and running training jobs on Amazon SageMaker. Users are strongly advised to migrate to the main `sagemaker` Python SDK (also known as `sagemaker-python-sdk`) for all SageMaker interactions, including training, which offers comprehensive and actively developed features. The last stable version of `sagemaker-train` is 1.7.1.","status":"deprecated","version":"1.7.1","language":"en","source_language":"en","source_url":"https://github.com/aws/sagemaker-python-sdk","tags":["aws","sagemaker","ml","training","deprecated","sdk","python"],"install":[{"cmd":"pip install sagemaker-train","lang":"bash","label":"Install deprecated library (NOT RECOMMENDED)"},{"cmd":"pip install sagemaker","lang":"bash","label":"Install recommended replacement (SageMaker Python SDK)"}],"dependencies":[],"imports":[{"note":"The `Estimator` class and related training components have been fully integrated into the main `sagemaker` Python SDK. The `sagemaker_train` module is deprecated.","wrong":"from sagemaker_train.estimator import Estimator","symbol":"Estimator","correct":"from sagemaker.estimator import Estimator"}],"quickstart":{"code":"import sagemaker\nfrom sagemaker.pytorch import PyTorch\nimport os\n\n# --- THIS IS A REPLACEMENT EXAMPLE FOR THE DEPRECATED `sagemaker-train` LIBRARY ---\n# It demonstrates how to train a model using the recommended `sagemaker` SDK.\n\n# 1. Configure SageMaker session and IAM role\nsagemaker_session = sagemaker.Session()\n# IMPORTANT: Replace with your actual AWS IAM role ARN for SageMaker execution.\n# This role grants SageMaker permissions to access resources like S3 and ECR.\n# Example: \"arn:aws:iam::123456789012:role/SageMakerExecutionRole\"\nrole = os.environ.get('SAGEMAKER_ROLE_ARN', 'arn:aws:iam::123456789012:role/SageMakerExecutionRole')\nif '123456789012' in role:\n    print(\"WARNING: Placeholder IAM role ARN detected. Please replace 'SAGEMAKER_ROLE_ARN' \"\n          \"with your actual SageMaker execution role ARN to run this code on AWS.\")\n\n# 2. Create a dummy local training script for demonstration purposes.\n# In a real scenario, this would be your actual training script (e.g., train.py).\nscript_path = 'my_training_script.py'\nwith open(script_path, 'w') as f:\n    f.write(\"\"\"\nimport argparse, os, logging\nif __name__ == '__main__':\n    parser = argparse.ArgumentParser()\n    parser.add_argument('--epochs', type=int, default=1)\n    args = parser.parse_args()\n    logging.basicConfig(level=logging.INFO)\n    logging.info(f\"Starting dummy training for {args.epochs} epochs.\")\n    # SageMaker automatically sets SM_MODEL_DIR for model artifacts\n    model_output_path = os.environ.get('SM_MODEL_DIR')\n    if model_output_path:\n        with open(os.path.join(model_output_path, 'model.txt'), 'w') as mf:\n            mf.write('dummy_model_content')\n    logging.info(\"Dummy training finished.\")\n\"\"\")\n\n# 3. Define the Estimator for your training job.\n# This example uses a PyTorch Estimator. Other framework estimators (TensorFlow, SKLearn, etc.)\n# are also available in the sagemaker SDK.\npytorch_estimator = PyTorch(\n    entry_point=script_path,\n    role=role,\n    instance_count=1,\n    instance_type='ml.m5.large', # Choose an appropriate SageMaker instance type\n    framework_version='1.13.1',  # Specify your desired PyTorch version\n    py_version='py39',          # Specify your desired Python version\n    hyperparameters={'epochs': 2},\n    sagemaker_session=sagemaker_session\n)\n\nprint(f\"Estimator configured for script: {script_path}\")\nprint(\"To start a training job on SageMaker, uncomment the line below:\")\n# pytorch_estimator.fit() \n\n# Optional: Clean up the dummy script\n# os.remove(script_path)\n","lang":"python","description":"This quickstart demonstrates how to initiate a training job using the recommended `sagemaker` Python SDK. It creates a simple training script and configures a PyTorch Estimator to run it on SageMaker. Ensure you replace the placeholder IAM role ARN with your actual SageMaker execution role and adjust instance types/framework versions as needed."},"warnings":[{"fix":"Migrate all existing code to use the `sagemaker` (sagemaker-python-sdk) library. Update import statements (e.g., `from sagemaker_train.estimator import Estimator` to `from sagemaker.estimator import Estimator`) and consult the SageMaker Python SDK documentation for up-to-date API usage.","message":"The `sagemaker-train` library is officially deprecated and is no longer being maintained or updated. Its functionalities have been absorbed into the main `sagemaker` Python SDK.","severity":"breaking","affected_versions":"All versions (since the deprecation announcement)"},{"fix":"Immediately replace `sagemaker-train` with the actively maintained `sagemaker` SDK to ensure security, stability, and access to the latest features. Review your `requirements.txt` or `pyproject.toml` to remove the deprecated dependency.","message":"Using deprecated and unmaintained libraries like `sagemaker-train` can lead to security vulnerabilities, compatibility issues with newer Python versions or AWS services, and lack of support for new SageMaker features.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}