AWS sagemaker documentation change
Summary
Added SageMaker Python SDK v3 example for warm pools with persistent caching. Updated environment variable documentation link and maintained legacy v2 content.
Security assessment
Changes focus on SDK version updates and cache configuration examples. The persistent cache directory is for performance optimization, not security. No security vulnerabilities or features are addressed.
Diff
diff --git a/sagemaker/latest/dg/train-warm-pools.md b/sagemaker/latest/dg/train-warm-pools.md index fcc2a52dc..4ef243596 100644 --- a//sagemaker/latest/dg/train-warm-pools.md +++ b//sagemaker/latest/dg/train-warm-pools.md @@ -148,0 +149,44 @@ The following code example shows you how to set up a warm pool and use persisten +SageMaker Python SDK v3 + + + + from sagemaker.train import ModelTrainer + from sagemaker.train.configs import Compute, SourceCode + from sagemaker.core.helper.session_helper import Session, get_execution_role + from sagemaker.core import image_uris + + # Creates a SageMaker session and gets execution role + session = Session() + role = get_execution_role() + + # Retrieve the TensorFlow training image + training_image = image_uris.retrieve( + framework="tensorflow", region=session.boto_region_name, + version="2.2", py_version="py37", + instance_type="ml.g4dn.xlarge", image_scope="training" + ) + + # Creates an example ModelTrainer with warm pool enabled + model_trainer = ModelTrainer( + training_image=training_image, + source_code=SourceCode(source_dir='code', entry_script='my-training-script.py'), + role=role, + compute=Compute( + instance_type='ml.g4dn.xlarge', + instance_count=1, + volume_size_in_gb=250, + keep_alive_period_in_seconds=1800, + ), + hyperparameters={ + "batch-size": "512", + "epochs": "1", + "learning-rate": "1e-3", + "beta_1": "0.9", + "beta_2": "0.999", + }, + environment={"PIP_CACHE_DIR": "/opt/ml/sagemaker/warmpoolcache/pip"} + ) + +SageMaker Python SDK v2 (Legacy) + + @@ -178 +222 @@ The following code example shows you how to set up a warm pool and use persisten -In the previous code example, using the [environment](https://sagemaker.readthedocs.io/en/stable/api/training/estimators.html#estimators) parameter exports the environment variable `PIP_CACHE_DIRECTORY` to point to the directory `/opt/ml/sagemaker/warmpoolcache/pip`. Exporting this environment variable will change where pip stores its cache to the new location. Any directory, including nested directories, that you create inside the persistent cache directory will be available for re-use during a subsequent training run. In the previous code example, a directory called `pip` is changed to be the default location to cache any dependencies installed using pip. +In the previous code example, using the [environment](https://sagemaker.readthedocs.io/en/stable/api/sagemaker_train.html) parameter exports the environment variable `PIP_CACHE_DIRECTORY` to point to the directory `/opt/ml/sagemaker/warmpoolcache/pip`. Exporting this environment variable will change where pip stores its cache to the new location. Any directory, including nested directories, that you create inside the persistent cache directory will be available for re-use during a subsequent training run. In the previous code example, a directory called `pip` is changed to be the default location to cache any dependencies installed using pip.