Skip to content

upgrade notebook to SDK v2 #1576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"metadata": {},
"outputs": [],
"source": [
"!{sys.executable} -m pip install sagemaker-experiments"
"!{sys.executable} -m pip install sagemaker-experiments==0.1.24"
]
},
{
Expand All @@ -60,8 +60,12 @@
"metadata": {},
"outputs": [],
"source": [
"!{sys.executable} -m pip install torch\n",
"!{sys.executable} -m pip install torchvision"
"# pytorch version needs to be the same in both the notebook instance and the training job container \n",
"# https://github.com/pytorch/pytorch/issues/25214\n",
"!{sys.executable} -m pip install torch==1.1.0\n",
"!{sys.executable} -m pip install torchvision==0.3.0\n",
"!{sys.executable} -m pip install pillow==6.2.2 ",
"!{sys.executable} -m pip install --upgrade sagemaker",
]
},
{
Expand All @@ -73,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -82,7 +86,7 @@
"import boto3\n",
"import numpy as np\n",
"import pandas as pd\n",
"%config InlineBackend.figure_format = 'retina'\n",
"from IPython.display import set_matplotlib_formats\n",
"from matplotlib import pyplot as plt\n",
"from torchvision import datasets, transforms\n",
"\n",
Expand All @@ -94,7 +98,9 @@
"from smexperiments.experiment import Experiment\n",
"from smexperiments.trial import Trial\n",
"from smexperiments.trial_component import TrialComponent\n",
"from smexperiments.tracker import Tracker"
"from smexperiments.tracker import Tracker\n",
"\n",
"set_matplotlib_formats('retina')"
]
},
{
Expand Down Expand Up @@ -307,12 +313,13 @@
" # all input configurations, parameters, and metrics specified in estimator \n",
" # definition are automatically tracked\n",
" estimator = PyTorch(\n",
" py_version='py3',\n",
" entry_point='./mnist.py',\n",
" role=role,\n",
" sagemaker_session=sagemaker.Session(sagemaker_client=sm),\n",
" framework_version='1.1.0',\n",
" train_instance_count=1,\n",
" train_instance_type='ml.c4.xlarge',\n",
" instance_count=1,\n",
" instance_type='ml.c4.xlarge',\n",
" hyperparameters={\n",
" 'epochs': 2,\n",
" 'backend': 'gloo',\n",
Expand Down Expand Up @@ -470,6 +477,7 @@
" model_data, \n",
" role, \n",
" './mnist.py', \n",
" py_version='py3',\n",
" env=env, \n",
" sagemaker_session=sagemaker.Session(sagemaker_client=sm),\n",
" framework_version='1.1.0',\n",
Expand Down Expand Up @@ -497,39 +505,29 @@
"metadata": {},
"outputs": [],
"source": [
"predictor.delete_endpoint()\n",
"\n",
"def cleanup(experiment):\n",
" for trial_summary in experiment.list_trials():\n",
" trial = Trial.load(sagemaker_boto_client=sm, trial_name=trial_summary.trial_name)\n",
" for trial_component_summary in trial.list_trial_components():\n",
" tc = TrialComponent.load(\n",
" sagemaker_boto_client=sm,\n",
" trial_component_name=trial_component_summary.trial_component_name)\n",
" trial.remove_trial_component(tc)\n",
" try:\n",
" # comment out to keep trial components\n",
" tc.delete()\n",
" except:\n",
" # tc is associated with another trial\n",
" continue\n",
" # to prevent throttling\n",
" time.sleep(.5)\n",
" trial.delete()\n",
" experiment.delete()\n",
"\n",
"cleanup(mnist_experiment)"
"predictor.delete_endpoint()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"mnist_experiment.delete_all(action='--force')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Contact\n",
"Submit any questions or issues to https://github.com/aws/sagemaker-experiments/issues or mention @aws/sagemakerexperimentsadmin "
]
}
],
"metadata": {
"instance_type": "ml.t3.medium",
"kernelspec": {
"display_name": "Python 3 (Data Science)",
"language": "python",
Expand Down
Loading