Skip to content

Commit e4b34b5

Browse files
committed
Use regional images for Kmeans notebooks
1 parent 51aaffa commit e4b34b5

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

sagemaker-python-sdk/1P_kmeans_highlevel/kmeans_mnist.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"\n",
4444
"Here we set up the linkage and authentication to AWS services. There are three parts to this:\n",
4545
"\n",
46-
"1. The credentials and region for the account that's running training. Upload the credentials in the normal AWS credentials file format using the jupyter upload feature. The region must always be `us-west-2` during the Beta program.\n",
46+
"1. The credentials and region for the account that's running training. Upload the credentials in the normal AWS credentials file format using the jupyter upload feature.\n",
4747
"2. The roles used to give learning and hosting access to your data. See the documentation for how to specify these.\n",
4848
"3. The S3 bucket that you want to use for training and model data.\n",
4949
"\n",
@@ -292,9 +292,10 @@
292292
"metadata": {},
293293
"outputs": [],
294294
"source": [
295-
"import sagemaker\n",
295+
"# Uncomment and run to delete\n",
296296
"\n",
297-
"sagemaker.Session().delete_endpoint(kmeans_predictor.endpoint)"
297+
"#import sagemaker\n",
298+
"#sagemaker.Session().delete_endpoint(kmeans_predictor.endpoint)"
298299
]
299300
},
300301
{

sagemaker-python-sdk/1P_kmeans_lowlevel/kmeans_mnist_lowlevel.ipynb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@
174174
"After setting training parameters, we kick off training, and poll for status until training is completed, which in this example, takes between 7 and 11 minutes."
175175
]
176176
},
177+
{
178+
"cell_type": "code",
179+
"execution_count": null,
180+
"metadata": {},
181+
"outputs": [],
182+
"source": [
183+
"image"
184+
]
185+
},
177186
{
178187
"cell_type": "code",
179188
"execution_count": null,
@@ -187,10 +196,13 @@
187196
"job_name = 'kmeans-lowlevel-' + strftime(\"%Y-%m-%d-%H-%M-%S\", gmtime())\n",
188197
"print(\"Training job\", job_name)\n",
189198
"\n",
199+
"region = !aws configure get region\n",
200+
"image = '174872318107.dkr.ecr.{}.amazonaws.com/kmeans:1'.format(region[0])\n",
201+
"\n",
190202
"create_training_params = \\\n",
191203
"{\n",
192204
" \"AlgorithmSpecification\": {\n",
193-
" \"TrainingImage\": \"174872318107.dkr.ecr.us-west-2.amazonaws.com/kmeans:1\",\n",
205+
" \"TrainingImage\": image,\n",
194206
" \"TrainingInputMode\": \"File\"\n",
195207
" },\n",
196208
" \"RoleArn\": role,\n",
@@ -278,7 +290,7 @@
278290
"model_data = info['ModelArtifacts']['S3ModelArtifacts']\n",
279291
"\n",
280292
"primary_container = {\n",
281-
" 'Image': \"174872318107.dkr.ecr.us-west-2.amazonaws.com/kmeans:1\",\n",
293+
" 'Image': image,\n",
282294
" 'ModelDataUrl': model_data\n",
283295
"}\n",
284296
"\n",

0 commit comments

Comments
 (0)