Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions sagemaker-core/example_notebooks/get_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@
"metadata": {},
"outputs": [],
"source": [
"image = '141502667606.dkr.ecr.eu-west-1.amazonaws.com/sagemaker-xgboost:1.7-1'"
"from sagemaker.core import image_uris\n",
"\n",
"image = image_uris.retrieve(\n",
" framework=\"xgboost\",\n",
" region=region,\n",
" version='1.7-1'\n",
")"
]
},
{
Expand Down Expand Up @@ -687,7 +693,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "temp_env",
"language": "python",
"name": "python3"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,13 @@
"metadata": {},
"outputs": [],
"source": [
"# Image name is hardcoded here\n",
"# Image name can be programatically got by using sagemaker package and calling image_uris.retrieve\n",
"# Since that is a high level abstraction that has multiple dependencies, the image URIs functionalities will live in sagemaker (V2)\n",
"from sagemaker.core import image_uris\n",
"\n",
"image = \"433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest\""
"image = image_uris.retrieve(\n",
" framework=\"xgboost\",\n",
" region=region,\n",
" version='latest'\n",
")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,13 @@
"metadata": {},
"outputs": [],
"source": [
"# Image name is hardcoded here\n",
"# Image name can be programatically got by using sagemaker package and calling image_uris.retrieve\n",
"# Since that is a high level abstraction that has multiple dependencies, the image URIs functionalities will live in sagemaker (V2)\n",
"from sagemaker.core import image_uris\n",
"\n",
"image = \"433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest\""
"image = image_uris.retrieve(\n",
" framework=\"xgboost\",\n",
" region=region,\n",
" version='latest'\n",
")"
]
},
{
Expand Down
10 changes: 6 additions & 4 deletions sagemaker-core/example_notebooks/sagemaker_core_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,13 @@
"metadata": {},
"outputs": [],
"source": [
"# Image name is hardcoded here\n",
"# Image name can be programatically got by using sagemaker package and calling image_uris.retrieve\n",
"# Since that is a high level abstraction that has multiple dependencies, the image URIs functionalities will live in sagemaker (V2)\n",
"from sagemaker.core import image_uris\n",
"\n",
"image = \"433757028032.dkr.ecr.us-west-2.amazonaws.com/xgboost:latest\""
"image = image_uris.retrieve(\n",
" framework=\"xgboost\",\n",
" region=region,\n",
" version='latest'\n",
")"
]
},
{
Expand Down
2,391 changes: 19 additions & 2,372 deletions sagemaker-train/example_notebooks/evaluate/benchmark_demo.ipynb

Large diffs are not rendered by default.

1,522 changes: 19 additions & 1,503 deletions sagemaker-train/example_notebooks/evaluate/custom_scorer_demo.ipynb

Large diffs are not rendered by default.

2,061 changes: 17 additions & 2,044 deletions sagemaker-train/example_notebooks/evaluate/llm_as_judge_demo.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v3-examples/inference-examples/optimize-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"MODEL_ID = \"meta-textgeneration-llama-3-8b-instruct\"\n",
"MODEL_NAME_PREFIX = \"jumpstart-optimize-example\"\n",
"ENDPOINT_NAME_PREFIX = \"jumpstart-optimize-example-endpoint\"\n",
"AWS_ACCOUNT_ID = \"593793038179\"\n",
"AWS_REGION = \"us-east-2\"\n",
"AWS_ACCOUNT_ID = Session.account_id()\n",
"AWS_REGION = Session.boto_region_name\n",
"\n",
"# Generate unique identifiers\n",
"unique_id = str(uuid.uuid4())[:8]\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"TRAINING_JOB_PREFIX = \"e2e-v3-pytorch\"\n",
"\n",
"# AWS Configuration\n",
"AWS_REGION = \"us-west-2\"\n",
"AWS_REGION = Session.boto_region_name\n",
"PYTORCH_TRAINING_IMAGE = f\"763104351884.dkr.ecr.{AWS_REGION}.amazonaws.com/pytorch-training:1.13.1-cpu-py39\"\n",
"\n",
"# Generate unique identifiers\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Install from local SDK for development (includes fixes for MLflow path resolution issues)\n",
"%pip install -e ../../sagemaker-core -e ../../sagemaker-train -e ../../sagemaker-serve -e ../../sagemaker-mlops -e ../../. \"mlflow==3.4.0\" --upgrade"
"# Install fix for MLflow path resolution issues\n",
"%pip install mlflow==3.4.0"
]
},
{
Expand All @@ -62,6 +62,7 @@
"source": [
"import uuid\n",
"from sagemaker.core import image_uris\n",
"from sagemaker.core.helper.session_helper import Session\n",
"\n",
"# =============================================================================\n",
"# MLflow Configuration - UPDATE THIS WITH YOUR TRACKING SERVER ARN\n",
Expand All @@ -70,7 +71,7 @@
"MLFLOW_TRACKING_ARN = \"XXXXX\"\n",
"\n",
"# AWS Configuration\n",
"AWS_REGION = \"us-east-1\"\n",
"AWS_REGION = Session.boto_region_name\n",
"\n",
"# Get PyTorch training image dynamically\n",
"PYTORCH_TRAINING_IMAGE = image_uris.retrieve(\n",
Expand Down Expand Up @@ -556,7 +557,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "py3.10.14",
"language": "python",
"name": "python3"
},
Expand All @@ -570,7 +571,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.14"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@
"from sagemaker.core import image_uris\n",
"import boto3\n",
"\n",
"sagemaker_session = Session()\n",
"role = get_execution_role()\n",
"region = sagemaker_session.boto_region_name\n",
"\n",
"image_uri = image_uris.retrieve(\n",
" framework=\"xgboost\",\n",
" region=\"us-east-1\",\n",
" region=region,\n",
" version=\"1.0-1\",\n",
" py_version=\"py3\",\n",
" instance_type=\"ml.m5.xlarge\",\n",
")\n",
"sagemaker_session = Session()\n",
"role = get_execution_role()"
")"
]
},
{
Expand Down Expand Up @@ -181,7 +183,7 @@
"# approve the version before creating model\n",
"\n",
"# There is a gap that API response for a versioned model package doesn't include model_package_name\n",
"sagemaker_client = boto3.client('sagemaker', region_name='us-east-1')\n",
"sagemaker_client = boto3.client('sagemaker', region_name=region)\n",
"sagemaker_client.update_model_package(\n",
" ModelPackageArn=registered_model_package_arn,\n",
" ModelApprovalStatus=\"Approved\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@
"## Setup and Dependencies"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "84cf410f",
"metadata": {},
"outputs": [],
"source": [
"!pip install --upgrade sagemaker --quiet # restart the kernel after running this cell"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
183 changes: 183 additions & 0 deletions v3-examples/sagemaker_v3_setup.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# SageMaker Python SDK v3+ Setup\n",
"\n",
"This notebook helps you upgrade to SageMaker Python SDK v3+ and verify the installation.\n",
"\n",
"**⚠️ Important:** After running this notebook, restart your kernel before using SageMaker v3."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 1: Check Current Version"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip show sagemaker | grep Version"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2: Install/Upgrade\n",
"\n",
"Choose **ONE** of the following methods:"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Method 1: Standard Upgrade (Try this first)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install --upgrade sagemaker"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Method 2: Force Reinstall (If Method 1 fails)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install --force-reinstall --no-cache-dir sagemaker"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Method 3: Clean Uninstall + Reinstall (If residual files exist)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip uninstall -y sagemaker sagemaker-core sagemaker-train sagemaker-serve sagemaker-mlops\n",
"!pip cache purge\n",
"!pip install sagemaker"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 3: Restart Kernel\n",
"\n",
"**⚠️ REQUIRED:** Click **Kernel → Restart Kernel** in the menu above, then continue to Step 4."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 4: Verify Installation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip show sagemaker | grep Version"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 5: Verify Core Components"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" from sagemaker.core.helper.session_helper import Session\n",
" from sagemaker.train import ModelTrainer\n",
" from sagemaker.serve import ModelBuilder\n",
" from sagemaker.mlops.workflow.pipeline import Pipeline\n",
" print(\"✓ Core v3 modules imported successfully\")\n",
" \n",
" session = Session()\n",
" print(f\"✓ Session created - Region: {session.boto_region_name}\")\n",
" print(f\"✓ Default bucket: {session.default_bucket()}\")\n",
" \n",
"except ImportError as e:\n",
" print(f\"✗ Import failed: {e}\")\n",
" print(\"Try Method 3 (Clean Uninstall + Reinstall)\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Troubleshooting\n",
"\n",
"### Version still shows v2.x after upgrade\n",
"1. Restart kernel (Kernel → Restart Kernel)\n",
"2. Use Method 3 (Clean Uninstall + Reinstall)\n",
"\n",
"### Import errors after upgrade\n",
"Clear Python cache and restart kernel:\n",
"```python\n",
"!find . -type d -name __pycache__ -exec rm -r {} +\n",
"!find . -type f -name '*.pyc' -delete\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# SageMaker V3 Distributed Local Training Example\n",
"\n",
"This notebook demonstrates how to run distributed training locally using SageMaker V3 ModelTrainer with multiple Docker containers."
"This notebook demonstrates how to run distributed training locally using SageMaker V3 ModelTrainer with multiple Docker containers. Note: This notebook will not run in SageMaker Studio. "
]
},
{
Expand Down
3 changes: 2 additions & 1 deletion v3-examples/training-examples/local-training-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"source": [
"# SageMaker V3 Local Training Example\n",
"\n",
"This notebook demonstrates how to use SageMaker V3 ModelTrainer in Local Container mode for testing training jobs in Docker containers locally."
"This notebook demonstrates how to use SageMaker V3 ModelTrainer in Local Container mode for testing training jobs in Docker containers locally. \n",
"Note: This notebook will not run in SageMaker Studio. "
]
},
{
Expand Down
Loading