{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[33mWARNING: Skipping torchvison as it is not installed.\u001b[0m\n", "yes: standard output: Broken pipe\n" ] } ], "source": [ "!yes | pip uninstall torchvison\n", "!pip install -qU torchvision" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# MNIST Training using PyTorch" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook. \n", "\n", "![This us-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-west-2/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "---" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Contents\n", "\n", "1. [Background](#Background)\n", "1. [Setup](#Setup)\n", "1. [Data](#Data)\n", "1. [Train](#Train)\n", "1. [Host](#Host)\n", "\n", "---\n", "\n", "## Background\n", "\n", "MNIST is a widely used dataset for handwritten digit classification. It consists of 70,000 labeled 28x28 pixel grayscale images of hand-written digits. The dataset is split into 60,000 training images and 10,000 test images. There are 10 classes (one for each of the 10 digits). This tutorial will show how to train and test an MNIST model on SageMaker using PyTorch.\n", "\n", "For more information about the PyTorch in SageMaker, please visit [sagemaker-pytorch-containers](https://github.com/aws/sagemaker-pytorch-containers) and [sagemaker-python-sdk](https://github.com/aws/sagemaker-python-sdk) github repositories.\n", "\n", "---\n", "\n", "## Setup\n", "\n", "_This notebook was created and tested on an ml.m4.xlarge notebook instance._\n", "\n", "Let's start by creating a SageMaker session and specifying:\n", "\n", "- The S3 bucket and prefix that you want to use for training and model data. This should be within the same region as the Notebook Instance, training, and hosting.\n", "- The IAM role arn used to give training and hosting access to your data. See the documentation for how to create these. Note, if more than one role is required for notebook instances, training, and/or hosting, please replace the `sagemaker.get_execution_role()` with a the appropriate full IAM role arn string(s).\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import sagemaker\n", "\n", "sagemaker_session = sagemaker.Session()\n", "region = sagemaker_session.boto_region_name\n", "\n", "bucket = sagemaker_session.default_bucket()\n", "prefix = \"sagemaker/DEMO-pytorch-mnist\"\n", "\n", "role = sagemaker.get_execution_role()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Data\n", "### Getting the data\n", "\n" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Dataset MNIST\n", " Number of datapoints: 60000\n", " Root location: data\n", " Split: Train\n", " StandardTransform\n", "Transform: Compose(\n", " ToTensor()\n", " Normalize(mean=(0.1307,), std=(0.3081,))\n", " )" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from torchvision.datasets import MNIST\n", "from torchvision import transforms\n", "\n", "MNIST.mirrors = [\n", " f\"https://sagemaker-example-files-prod-{region}.s3.amazonaws.com/datasets/image/MNIST/\"\n", "]\n", "\n", "MNIST(\n", " \"data\",\n", " download=True,\n", " transform=transforms.Compose(\n", " [transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]\n", " ),\n", ")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Uploading the data to S3\n", "We are going to use the `sagemaker.Session.upload_data` function to upload our datasets to an S3 location. The return value inputs identifies the location -- we will use later when we start the training job.\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "input spec (in this case, just an S3 path): s3://sagemaker-us-west-2-688520471316/sagemaker/DEMO-pytorch-mnist\n" ] } ], "source": [ "inputs = sagemaker_session.upload_data(path=\"data\", bucket=bucket, key_prefix=prefix)\n", "print(\"input spec (in this case, just an S3 path): {}\".format(inputs))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Train\n", "### Training script\n", "The `mnist.py` script provides all the code we need for training and hosting a SageMaker model (`model_fn` function to load a model).\n", "The training script is very similar to a training script you might run outside of SageMaker, but you can access useful properties about the training environment through various environment variables, such as:\n", "\n", "* `SM_MODEL_DIR`: A string representing the path to the directory to write model artifacts to.\n", " These artifacts are uploaded to S3 for model hosting.\n", "* `SM_NUM_GPUS`: The number of gpus available in the current container.\n", "* `SM_CURRENT_HOST`: The name of the current container on the container network.\n", "* `SM_HOSTS`: JSON encoded list containing all the hosts .\n", "\n", "Supposing one input channel, 'training', was used in the call to the PyTorch estimator's `fit()` method, the following will be set, following the format `SM_CHANNEL_[channel_name]`:\n", "\n", "* `SM_CHANNEL_TRAINING`: A string representing the path to the directory containing data in the 'training' channel.\n", "\n", "For more information about training environment variables, please visit [SageMaker Containers](https://github.com/aws/sagemaker-containers).\n", "\n", "A typical training script loads data from the input channels, configures training with hyperparameters, trains a model, and saves a model to `model_dir` so that it can be hosted later. Hyperparameters are passed to your script as arguments and can be retrieved with an `argparse.ArgumentParser` instance.\n", "\n", "Because the SageMaker imports the training script, you should put your training code in a main guard (``if __name__=='__main__':``) if you are using the same script to host your model as we do in this example, so that SageMaker does not inadvertently run your training code at the wrong point in execution.\n", "\n", "For example, the script run by this notebook:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!pygmentize mnist.py" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Run training in SageMaker\n", "\n", "The `PyTorch` class allows us to run our training function as a training job on SageMaker infrastructure. We need to configure it with our training script, an IAM role, the number of training instances, the training instance type, and hyperparameters. In this case we are going to run our training job on 2 ```ml.c4.xlarge``` instances. But this example can be ran on one or multiple, cpu or gpu instances ([full list of available instances](https://aws.amazon.com/sagemaker/pricing/instance-types/)). The hyperparameters parameter is a dict of values that will be passed to your training script -- you can see how to access these values in the `mnist.py` script above.\n" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "from sagemaker.pytorch import PyTorch\n", "\n", "estimator = PyTorch(\n", " entry_point=\"mnist.py\",\n", " role=role,\n", " py_version=\"py38\",\n", " framework_version=\"1.11.0\",\n", " instance_count=2,\n", " instance_type=\"ml.c5.2xlarge\",\n", " hyperparameters={\"epochs\": 1, \"backend\": \"gloo\"},\n", ")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "After we've constructed our `PyTorch` object, we can fit it using the data we uploaded to S3. SageMaker makes sure our data is available in the local filesystem, so our training script can simply read the data from disk.\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2021-06-04 21:20:49 Starting - Starting the training job...\n", "2021-06-04 21:20:50 Starting - Launching requested ML instancesProfilerReport-1622841649: InProgress\n", "......\n", "2021-06-04 21:22:17 Starting - Preparing the instances for training.........\n", "2021-06-04 21:23:48 Downloading - Downloading input data\n", "2021-06-04 21:23:48 Training - Downloading the training image...\n", "2021-06-04 21:24:20 Uploading - Uploading generated training model\u001b[34mbash: cannot set terminal process group (-1): Inappropriate ioctl for device\u001b[0m\n", "\u001b[34mbash: no job control in this shell\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,228 sagemaker-training-toolkit INFO Imported framework sagemaker_pytorch_container.training\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,230 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,239 sagemaker_pytorch_container.training INFO Block until all host DNS lookups succeed.\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,246 sagemaker_pytorch_container.training INFO Invoking user training script.\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,636 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,647 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,658 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[34m2021-06-04 21:24:05,667 sagemaker-training-toolkit INFO Invoking user script\n", "\u001b[0m\n", "\u001b[34mTraining Env:\n", "\u001b[0m\n", "\u001b[34m{\n", " \"additional_framework_parameters\": {},\n", " \"channel_input_dirs\": {\n", " \"training\": \"/opt/ml/input/data/training\"\n", " },\n", " \"current_host\": \"algo-1\",\n", " \"framework_module\": \"sagemaker_pytorch_container.training:main\",\n", " \"hosts\": [\n", " \"algo-1\",\n", " \"algo-2\"\n", " ],\n", " \"hyperparameters\": {\n", " \"backend\": \"gloo\",\n", " \"epochs\": 1\n", " },\n", " \"input_config_dir\": \"/opt/ml/input/config\",\n", " \"input_data_config\": {\n", " \"training\": {\n", " \"TrainingInputMode\": \"File\",\n", " \"S3DistributionType\": \"FullyReplicated\",\n", " \"RecordWrapperType\": \"None\"\n", " }\n", " },\n", " \"input_dir\": \"/opt/ml/input\",\n", " \"is_master\": true,\n", " \"job_name\": \"pytorch-training-2021-06-04-21-20-48-860\",\n", " \"log_level\": 20,\n", " \"master_hostname\": \"algo-1\",\n", " \"model_dir\": \"/opt/ml/model\",\n", " \"module_dir\": \"s3://sagemaker-us-west-2-688520471316/pytorch-training-2021-06-04-21-20-48-860/source/sourcedir.tar.gz\",\n", " \"module_name\": \"mnist\",\n", " \"network_interface_name\": \"eth0\",\n", " \"num_cpus\": 8,\n", " \"num_gpus\": 0,\n", " \"output_data_dir\": \"/opt/ml/output/data\",\n", " \"output_dir\": \"/opt/ml/output\",\n", " \"output_intermediate_dir\": \"/opt/ml/output/intermediate\",\n", " \"resource_config\": {\n", " \"current_host\": \"algo-1\",\n", " \"hosts\": [\n", " \"algo-1\",\n", " \"algo-2\"\n", " ],\n", " \"network_interface_name\": \"eth0\"\n", " },\n", " \"user_entry_point\": \"mnist.py\"\u001b[0m\n", "\u001b[34m}\n", "\u001b[0m\n", "\u001b[34mEnvironment variables:\n", "\u001b[0m\n", "\u001b[34mSM_HOSTS=[\"algo-1\",\"algo-2\"]\u001b[0m\n", "\u001b[34mSM_NETWORK_INTERFACE_NAME=eth0\u001b[0m\n", "\u001b[34mSM_HPS={\"backend\":\"gloo\",\"epochs\":1}\u001b[0m\n", "\u001b[34mSM_USER_ENTRY_POINT=mnist.py\u001b[0m\n", "\u001b[34mSM_FRAMEWORK_PARAMS={}\u001b[0m\n", "\u001b[34mSM_RESOURCE_CONFIG={\"current_host\":\"algo-1\",\"hosts\":[\"algo-1\",\"algo-2\"],\"network_interface_name\":\"eth0\"}\u001b[0m\n", "\u001b[34mSM_INPUT_DATA_CONFIG={\"training\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"}}\u001b[0m\n", "\u001b[34mSM_OUTPUT_DATA_DIR=/opt/ml/output/data\u001b[0m\n", "\u001b[34mSM_CHANNELS=[\"training\"]\u001b[0m\n", "\u001b[34mSM_CURRENT_HOST=algo-1\u001b[0m\n", "\u001b[34mSM_MODULE_NAME=mnist\u001b[0m\n", "\u001b[34mSM_LOG_LEVEL=20\u001b[0m\n", "\u001b[34mSM_FRAMEWORK_MODULE=sagemaker_pytorch_container.training:main\u001b[0m\n", "\u001b[34mSM_INPUT_DIR=/opt/ml/input\u001b[0m\n", "\u001b[34mSM_INPUT_CONFIG_DIR=/opt/ml/input/config\u001b[0m\n", "\u001b[34mSM_OUTPUT_DIR=/opt/ml/output\u001b[0m\n", "\u001b[34mSM_NUM_CPUS=8\u001b[0m\n", "\u001b[34mSM_NUM_GPUS=0\u001b[0m\n", "\u001b[34mSM_MODEL_DIR=/opt/ml/model\u001b[0m\n", "\u001b[34mSM_MODULE_DIR=s3://sagemaker-us-west-2-688520471316/pytorch-training-2021-06-04-21-20-48-860/source/sourcedir.tar.gz\u001b[0m\n", "\u001b[34mSM_TRAINING_ENV={\"additional_framework_parameters\":{},\"channel_input_dirs\":{\"training\":\"/opt/ml/input/data/training\"},\"current_host\":\"algo-1\",\"framework_module\":\"sagemaker_pytorch_container.training:main\",\"hosts\":[\"algo-1\",\"algo-2\"],\"hyperparameters\":{\"backend\":\"gloo\",\"epochs\":1},\"input_config_dir\":\"/opt/ml/input/config\",\"input_data_config\":{\"training\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"}},\"input_dir\":\"/opt/ml/input\",\"is_master\":true,\"job_name\":\"pytorch-training-2021-06-04-21-20-48-860\",\"log_level\":20,\"master_hostname\":\"algo-1\",\"model_dir\":\"/opt/ml/model\",\"module_dir\":\"s3://sagemaker-us-west-2-688520471316/pytorch-training-2021-06-04-21-20-48-860/source/sourcedir.tar.gz\",\"module_name\":\"mnist\",\"network_interface_name\":\"eth0\",\"num_cpus\":8,\"num_gpus\":0,\"output_data_dir\":\"/opt/ml/output/data\",\"output_dir\":\"/opt/ml/output\",\"output_intermediate_dir\":\"/opt/ml/output/intermediate\",\"resource_config\":{\"current_host\":\"algo-1\",\"hosts\":[\"algo-1\",\"algo-2\"],\"network_interface_name\":\"eth0\"},\"user_entry_point\":\"mnist.py\"}\u001b[0m\n", "\u001b[34mSM_USER_ARGS=[\"--backend\",\"gloo\",\"--epochs\",\"1\"]\u001b[0m\n", "\u001b[34mSM_OUTPUT_INTERMEDIATE_DIR=/opt/ml/output/intermediate\u001b[0m\n", "\u001b[34mSM_CHANNEL_TRAINING=/opt/ml/input/data/training\u001b[0m\n", "\u001b[34mSM_HP_BACKEND=gloo\u001b[0m\n", "\u001b[34mSM_HP_EPOCHS=1\u001b[0m\n", "\u001b[34mPYTHONPATH=/opt/ml/code:/opt/conda/bin:/opt/conda/lib/python36.zip:/opt/conda/lib/python3.6:/opt/conda/lib/python3.6/lib-dynload:/opt/conda/lib/python3.6/site-packages\n", "\u001b[0m\n", "\u001b[34mInvoking script with the following command:\n", "\u001b[0m\n", "\u001b[34m/opt/conda/bin/python3.6 mnist.py --backend gloo --epochs 1\n", "\n", "\u001b[0m\n", "\u001b[34mDistributed training - True\u001b[0m\n", "\u001b[34mNumber of gpus available - 0\u001b[0m\n", "\u001b[35mbash: cannot set terminal process group (-1): Inappropriate ioctl for device\u001b[0m\n", "\u001b[35mbash: no job control in this shell\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,062 sagemaker-training-toolkit INFO Imported framework sagemaker_pytorch_container.training\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,064 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,073 sagemaker_pytorch_container.training INFO Block until all host DNS lookups succeed.\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,081 sagemaker_pytorch_container.training INFO Invoking user training script.\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,485 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,496 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,506 sagemaker-training-toolkit INFO No GPUs detected (normal if no gpus installed)\u001b[0m\n", "\u001b[35m2021-06-04 21:24:05,515 sagemaker-training-toolkit INFO Invoking user script\n", "\u001b[0m\n", "\u001b[35mTraining Env:\n", "\u001b[0m\n", "\u001b[35m{\n", " \"additional_framework_parameters\": {},\n", " \"channel_input_dirs\": {\n", " \"training\": \"/opt/ml/input/data/training\"\n", " },\n", " \"current_host\": \"algo-2\",\n", " \"framework_module\": \"sagemaker_pytorch_container.training:main\",\n", " \"hosts\": [\n", " \"algo-1\",\n", " \"algo-2\"\n", " ],\n", " \"hyperparameters\": {\n", " \"backend\": \"gloo\",\n", " \"epochs\": 1\n", " },\n", " \"input_config_dir\": \"/opt/ml/input/config\",\n", " \"input_data_config\": {\n", " \"training\": {\n", " \"TrainingInputMode\": \"File\",\n", " \"S3DistributionType\": \"FullyReplicated\",\n", " \"RecordWrapperType\": \"None\"\n", " }\n", " },\n", " \"input_dir\": \"/opt/ml/input\",\n", " \"is_master\": false,\n", " \"job_name\": \"pytorch-training-2021-06-04-21-20-48-860\",\n", " \"log_level\": 20,\n", " \"master_hostname\": \"algo-1\",\n", " \"model_dir\": \"/opt/ml/model\",\n", " \"module_dir\": \"s3://sagemaker-us-west-2-688520471316/pytorch-training-2021-06-04-21-20-48-860/source/sourcedir.tar.gz\",\n", " \"module_name\": \"mnist\",\n", " \"network_interface_name\": \"eth0\",\n", " \"num_cpus\": 8,\n", " \"num_gpus\": 0,\n", " \"output_data_dir\": \"/opt/ml/output/data\",\n", " \"output_dir\": \"/opt/ml/output\",\n", " \"output_intermediate_dir\": \"/opt/ml/output/intermediate\",\n", " \"resource_config\": {\n", " \"current_host\": \"algo-2\",\n", " \"hosts\": [\n", " \"algo-1\",\n", " \"algo-2\"\n", " ],\n", " \"network_interface_name\": \"eth0\"\n", " },\n", " \"user_entry_point\": \"mnist.py\"\u001b[0m\n", "\u001b[35m}\n", "\u001b[0m\n", "\u001b[35mEnvironment variables:\n", "\u001b[0m\n", "\u001b[35mSM_HOSTS=[\"algo-1\",\"algo-2\"]\u001b[0m\n", "\u001b[35mSM_NETWORK_INTERFACE_NAME=eth0\u001b[0m\n", "\u001b[35mSM_HPS={\"backend\":\"gloo\",\"epochs\":1}\u001b[0m\n", "\u001b[35mSM_USER_ENTRY_POINT=mnist.py\u001b[0m\n", "\u001b[35mSM_FRAMEWORK_PARAMS={}\u001b[0m\n", "\u001b[35mSM_RESOURCE_CONFIG={\"current_host\":\"algo-2\",\"hosts\":[\"algo-1\",\"algo-2\"],\"network_interface_name\":\"eth0\"}\u001b[0m\n", "\u001b[35mSM_INPUT_DATA_CONFIG={\"training\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"}}\u001b[0m\n", "\u001b[35mSM_OUTPUT_DATA_DIR=/opt/ml/output/data\u001b[0m\n", "\u001b[35mSM_CHANNELS=[\"training\"]\u001b[0m\n", "\u001b[35mSM_CURRENT_HOST=algo-2\u001b[0m\n", "\u001b[35mSM_MODULE_NAME=mnist\u001b[0m\n", "\u001b[35mSM_LOG_LEVEL=20\u001b[0m\n", "\u001b[35mSM_FRAMEWORK_MODULE=sagemaker_pytorch_container.training:main\u001b[0m\n", "\u001b[35mSM_INPUT_DIR=/opt/ml/input\u001b[0m\n", "\u001b[35mSM_INPUT_CONFIG_DIR=/opt/ml/input/config\u001b[0m\n", "\u001b[35mSM_OUTPUT_DIR=/opt/ml/output\u001b[0m\n", "\u001b[35mSM_NUM_CPUS=8\u001b[0m\n", "\u001b[35mSM_NUM_GPUS=0\u001b[0m\n", "\u001b[35mSM_MODEL_DIR=/opt/ml/model\u001b[0m\n", "\u001b[35mSM_MODULE_DIR=s3://sagemaker-us-west-2-688520471316/pytorch-training-2021-06-04-21-20-48-860/source/sourcedir.tar.gz\u001b[0m\n", "\u001b[35mSM_TRAINING_ENV={\"additional_framework_parameters\":{},\"channel_input_dirs\":{\"training\":\"/opt/ml/input/data/training\"},\"current_host\":\"algo-2\",\"framework_module\":\"sagemaker_pytorch_container.training:main\",\"hosts\":[\"algo-1\",\"algo-2\"],\"hyperparameters\":{\"backend\":\"gloo\",\"epochs\":1},\"input_config_dir\":\"/opt/ml/input/config\",\"input_data_config\":{\"training\":{\"RecordWrapperType\":\"None\",\"S3DistributionType\":\"FullyReplicated\",\"TrainingInputMode\":\"File\"}},\"input_dir\":\"/opt/ml/input\",\"is_master\":false,\"job_name\":\"pytorch-training-2021-06-04-21-20-48-860\",\"log_level\":20,\"master_hostname\":\"algo-1\",\"model_dir\":\"/opt/ml/model\",\"module_dir\":\"s3://sagemaker-us-west-2-688520471316/pytorch-training-2021-06-04-21-20-48-860/source/sourcedir.tar.gz\",\"module_name\":\"mnist\",\"network_interface_name\":\"eth0\",\"num_cpus\":8,\"num_gpus\":0,\"output_data_dir\":\"/opt/ml/output/data\",\"output_dir\":\"/opt/ml/output\",\"output_intermediate_dir\":\"/opt/ml/output/intermediate\",\"resource_config\":{\"current_host\":\"algo-2\",\"hosts\":[\"algo-1\",\"algo-2\"],\"network_interface_name\":\"eth0\"},\"user_entry_point\":\"mnist.py\"}\u001b[0m\n", "\u001b[35mSM_USER_ARGS=[\"--backend\",\"gloo\",\"--epochs\",\"1\"]\u001b[0m\n", "\u001b[35mSM_OUTPUT_INTERMEDIATE_DIR=/opt/ml/output/intermediate\u001b[0m\n", "\u001b[35mSM_CHANNEL_TRAINING=/opt/ml/input/data/training\u001b[0m\n", "\u001b[35mSM_HP_BACKEND=gloo\u001b[0m\n", "\u001b[35mSM_HP_EPOCHS=1\u001b[0m\n", "\u001b[35mPYTHONPATH=/opt/ml/code:/opt/conda/bin:/opt/conda/lib/python36.zip:/opt/conda/lib/python3.6:/opt/conda/lib/python3.6/lib-dynload:/opt/conda/lib/python3.6/site-packages\n", "\u001b[0m\n", "\u001b[35mInvoking script with the following command:\n", "\u001b[0m\n", "\u001b[35m/opt/conda/bin/python3.6 mnist.py --backend gloo --epochs 1\n", "\n", "\u001b[0m\n", "\u001b[35mDistributed training - True\u001b[0m\n", "\u001b[35mNumber of gpus available - 0\u001b[0m\n", "\u001b[34mInitialized the distributed environment: 'gloo' backend on 2 nodes. Current host rank is 0. Number of gpus: 0\u001b[0m\n", "\u001b[34mGet train data loader\u001b[0m\n", "\u001b[34mGet test data loader\u001b[0m\n", "\u001b[34mProcesses 30000/60000 (50%) of train data\u001b[0m\n", "\u001b[34mProcesses 10000/10000 (100%) of test data\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.348 algo-1:25 INFO utils.py:27] RULE_JOB_STOP_SIGNAL_FILENAME: None\u001b[0m\n", "\u001b[35mInitialized the distributed environment: 'gloo' backend on 2 nodes. Current host rank is 1. Number of gpus: 0\u001b[0m\n", "\u001b[35mGet train data loader\u001b[0m\n", "\u001b[35mGet test data loader\u001b[0m\n", "\u001b[35mProcesses 30000/60000 (50%) of train data\u001b[0m\n", "\u001b[35mProcesses 10000/10000 (100%) of test data\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.339 algo-2:25 INFO utils.py:27] RULE_JOB_STOP_SIGNAL_FILENAME: None\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.751 algo-2:25 INFO profiler_config_parser.py:102] User has disabled profiler.\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.752 algo-2:25 INFO json_config.py:91] Creating hook from json_config at /opt/ml/input/config/debughookconfig.json.\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.752 algo-2:25 INFO hook.py:199] tensorboard_dir has not been set for the hook. SMDebug will not be exporting tensorboard summaries.\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.752 algo-2:25 INFO hook.py:253] Saving to /opt/ml/output/tensors\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.752 algo-2:25 INFO state_store.py:77] The checkpoint config file /opt/ml/input/config/checkpointconfig.json does not exist.\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.conv1.weight count_params:250\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.conv1.bias count_params:10\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.conv2.weight count_params:5000\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.conv2.bias count_params:20\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.fc1.weight count_params:16000\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.fc1.bias count_params:50\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.fc2.weight count_params:500\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:584] name:module.fc2.bias count_params:10\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:586] Total Trainable Params: 21840\u001b[0m\n", "\u001b[35m[2021-06-04 21:24:08.808 algo-2:25 INFO hook.py:413] Monitoring the collections: losses\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.744 algo-1:25 INFO profiler_config_parser.py:102] User has disabled profiler.\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.744 algo-1:25 INFO json_config.py:91] Creating hook from json_config at /opt/ml/input/config/debughookconfig.json.\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.745 algo-1:25 INFO hook.py:199] tensorboard_dir has not been set for the hook. SMDebug will not be exporting tensorboard summaries.\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.745 algo-1:25 INFO hook.py:253] Saving to /opt/ml/output/tensors\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.745 algo-1:25 INFO state_store.py:77] The checkpoint config file /opt/ml/input/config/checkpointconfig.json does not exist.\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.conv1.weight count_params:250\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.conv1.bias count_params:10\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.conv2.weight count_params:5000\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.conv2.bias count_params:20\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.fc1.weight count_params:16000\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.fc1.bias count_params:50\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.fc2.weight count_params:500\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:584] name:module.fc2.bias count_params:10\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:586] Total Trainable Params: 21840\u001b[0m\n", "\u001b[34m[2021-06-04 21:24:08.795 algo-1:25 INFO hook.py:413] Monitoring the collections: losses\u001b[0m\n", "\u001b[35mTrain Epoch: 1 [6400/30000 (21%)] Loss: 2.075230\u001b[0m\n", "\u001b[34mTrain Epoch: 1 [6400/30000 (21%)] Loss: 2.076306\u001b[0m\n", "\u001b[34mTrain Epoch: 1 [12800/30000 (43%)] Loss: 1.056925\u001b[0m\n", "\u001b[35mTrain Epoch: 1 [12800/30000 (43%)] Loss: 1.216741\u001b[0m\n", "\u001b[35mTrain Epoch: 1 [19200/30000 (64%)] Loss: 0.911026\u001b[0m\n", "\u001b[34mTrain Epoch: 1 [19200/30000 (64%)] Loss: 0.942084\u001b[0m\n", "\u001b[35mTrain Epoch: 1 [25600/30000 (85%)] Loss: 0.671317\u001b[0m\n", "\u001b[34mTrain Epoch: 1 [25600/30000 (85%)] Loss: 0.841636\u001b[0m\n", "\u001b[34mTest set: Average loss: 0.3237, Accuracy: 9094/10000 (91%)\n", "\u001b[0m\n", "\u001b[34mSaving the model.\u001b[0m\n", "\u001b[34mINFO:__main__:Initialized the distributed environment: 'gloo' backend on 2 nodes. Current host rank is 0. Number of gpus: 0\u001b[0m\n", "\u001b[34mINFO:__main__:Get train data loader\u001b[0m\n", "\u001b[34mINFO:__main__:Get test data loader\u001b[0m\n", "\u001b[34mDEBUG:__main__:Processes 30000/60000 (50%) of train data\u001b[0m\n", "\u001b[34mDEBUG:__main__:Processes 10000/10000 (100%) of test data\u001b[0m\n", "\u001b[34m/opt/conda/lib/python3.6/site-packages/torch/distributed/distributed_c10d.py:144: UserWarning: torch.distributed.reduce_op is deprecated, please use torch.distributed.ReduceOp instead\n", " warnings.warn(\"torch.distributed.reduce_op is deprecated, please use \"\u001b[0m\n", "\u001b[34mINFO:__main__:Train Epoch: 1 [6400/30000 (21%)] Loss: 2.076306\u001b[0m\n", "\u001b[34mINFO:__main__:Train Epoch: 1 [12800/30000 (43%)] Loss: 1.056925\u001b[0m\n", "\u001b[34mINFO:__main__:Train Epoch: 1 [19200/30000 (64%)] Loss: 0.942084\u001b[0m\n", "\u001b[34mINFO:__main__:Train Epoch: 1 [25600/30000 (85%)] Loss: 0.841636\u001b[0m\n", "\u001b[34m/opt/conda/lib/python3.6/site-packages/torch/nn/_reduction.py:42: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.\n", " warnings.warn(warning.format(ret))\u001b[0m\n", "\u001b[34mINFO:__main__:Test set: Average loss: 0.3237, Accuracy: 9094/10000 (91%)\n", "\u001b[0m\n", "\u001b[34mINFO:__main__:Saving the model.\n", "\u001b[0m\n", "\u001b[34m2021-06-04 21:24:18,084 sagemaker-training-toolkit INFO Reporting training SUCCESS\u001b[0m\n", "\u001b[35mTest set: Average loss: 0.3237, Accuracy: 9094/10000 (91%)\n", "\u001b[0m\n", "\u001b[35mSaving the model.\u001b[0m\n", "\u001b[35mINFO:__main__:Initialized the distributed environment: 'gloo' backend on 2 nodes. Current host rank is 1. Number of gpus: 0\u001b[0m\n", "\u001b[35mINFO:__main__:Get train data loader\u001b[0m\n", "\u001b[35mINFO:__main__:Get test data loader\u001b[0m\n", "\u001b[35mDEBUG:__main__:Processes 30000/60000 (50%) of train data\u001b[0m\n", "\u001b[35mDEBUG:__main__:Processes 10000/10000 (100%) of test data\u001b[0m\n", "\u001b[35m/opt/conda/lib/python3.6/site-packages/torch/distributed/distributed_c10d.py:144: UserWarning: torch.distributed.reduce_op is deprecated, please use torch.distributed.ReduceOp instead\n", " warnings.warn(\"torch.distributed.reduce_op is deprecated, please use \"\u001b[0m\n", "\u001b[35mINFO:__main__:Train Epoch: 1 [6400/30000 (21%)] Loss: 2.075230\u001b[0m\n", "\u001b[35mINFO:__main__:Train Epoch: 1 [12800/30000 (43%)] Loss: 1.216741\u001b[0m\n", "\u001b[35mINFO:__main__:Train Epoch: 1 [19200/30000 (64%)] Loss: 0.911026\u001b[0m\n", "\u001b[35mINFO:__main__:Train Epoch: 1 [25600/30000 (85%)] Loss: 0.671317\u001b[0m\n", "\u001b[35m/opt/conda/lib/python3.6/site-packages/torch/nn/_reduction.py:42: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.\n", " warnings.warn(warning.format(ret))\u001b[0m\n", "\u001b[35mINFO:__main__:Test set: Average loss: 0.3237, Accuracy: 9094/10000 (91%)\n", "\u001b[0m\n", "\u001b[35mINFO:__main__:Saving the model.\n", "\u001b[0m\n", "\u001b[35m2021-06-04 21:24:18,140 sagemaker-training-toolkit INFO Reporting training SUCCESS\u001b[0m\n", "\n", "2021-06-04 21:24:46 Completed - Training job completed\n", "Training seconds: 124\n", "Billable seconds: 124\n" ] } ], "source": [ "estimator.fit({\"training\": inputs})" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Host\n", "### Create endpoint\n", "After training, we use the `PyTorch` estimator object to build and deploy a `PyTorchPredictor`. This creates a Sagemaker Endpoint -- a hosted prediction service that we can use to perform inference.\n", "\n", "As mentioned above we have implementation of `model_fn` in the `mnist.py` script that is required. We are going to use default implementations of `input_fn`, `predict_fn`, `output_fn` and `transform_fm` defined in [sagemaker-pytorch-containers](https://github.com/aws/sagemaker-pytorch-containers).\n", "\n", "The arguments to the deploy function allow us to set the number and type of instances that will be used for the Endpoint. These do not need to be the same as the values we used for the training job. For example, you can train a model on a set of GPU-based instances, and then deploy the Endpoint to a fleet of CPU-based instances, but you need to make sure that you return or save your model as a cpu model similar to what we did in `mnist.py`. Here we will deploy the model to a single ```ml.m4.xlarge``` instance." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-------!" ] } ], "source": [ "predictor = estimator.deploy(initial_instance_count=1, instance_type=\"ml.m4.xlarge\")" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Evaluate\n", "\n", "You can use the test images to evalute the endpoint. The accuracy of the model depends on how many it is trained. " ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "t10k-images-idx3-ubyte\t train-images-idx3-ubyte\n", "t10k-images-idx3-ubyte.gz train-images-idx3-ubyte.gz\n", "t10k-labels-idx1-ubyte\t train-labels-idx1-ubyte\n", "t10k-labels-idx1-ubyte.gz train-labels-idx1-ubyte.gz\n" ] } ], "source": [ "!ls data/MNIST/raw" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "import gzip\n", "import numpy as np\n", "import random\n", "import os\n", "\n", "data_dir = \"data/MNIST/raw\"\n", "with gzip.open(os.path.join(data_dir, \"t10k-images-idx3-ubyte.gz\"), \"rb\") as f:\n", " images = np.frombuffer(f.read(), np.uint8, offset=16).reshape(-1, 28, 28).astype(np.float32)\n", "\n", "mask = random.sample(range(len(images)), 16) # randomly select some of the test images\n", "mask = np.array(mask, dtype=np.int)\n", "data = images[mask]" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Raw prediction result:\n", "[[ -841.81384277 -809.42578125 -686.82019043 -514.44500732\n", " -308.11486816 -555.79718018 -855.24853516 -68.2052002\n", " -401.67419434 0. ]\n", " [ -646.59735107 -895.97802734 0. -544.23052979\n", " -755.7565918 -922.04547119 -625.824646 -812.57006836\n", " -500.33776855 -805.3817749 ]\n", " [ -887.1842041 -817.05535889 -741.71582031 -870.87322998\n", " 0. -643.92150879 -453.70858765 -701.31427002\n", " -686.24975586 -333.54837036]\n", " [ -891.87609863 -857.50964355 -627.76599121 -970.46557617\n", " 0. -768.94299316 -505.81027222 -653.79400635\n", " -676.14233398 -344.46173096]\n", " [ -660.29199219 -792.37634277 -664.95281982 0.\n", " -958.40881348 -385.23153687 -958.44628906 -779.3081665\n", " -500.71435547 -699.39404297]\n", " [ -834.11621094 -886.70550537 -529.53649902 -998.31347656\n", " -532.21209717 -538.67773438 0. -1198.16943359\n", " -689.94897461 -867.32391357]\n", " [ -465.91723633 0. -236.69277954 -139.23117065\n", " -266.07495117 -185.28543091 -275.40328979 -267.25372314\n", " -170.0657959 -231.46386719]\n", " [ -211.82693481 -656.51843262 -441.55142212 -156.15490723\n", " -581.20227051 0. -247.48072815 -792.90441895\n", " -189.44906616 -535.47607422]\n", " [ -823.66131592 -686.35046387 0. -666.04376221\n", " -725.9387207 -951.12542725 -613.12091064 -868.25402832\n", " -583.81872559 -809.61730957]\n", " [ -716.01312256 0. -457.86019897 -407.98397827\n", " -428.36694336 -492.61264038 -519.45214844 -401.35784912\n", " -434.07836914 -442.5569458 ]\n", " [ -614.79174805 -342.24572754 -124.56967163 0.\n", " -503.47006226 -328.65908813 -694.87536621 -285.80020142\n", " -37.24746704 -272.1781311 ]\n", " [ -693.29498291 -568.50708008 -590.91729736 0.\n", " -661.19091797 -358.86340332 -782.01672363 -653.08392334\n", " -463.67196655 -516.52587891]\n", " [ -377.30566406 -512.46130371 -608.6083374 0.\n", " -637.54870605 -59.34466553 -394.70697021 -676.92193604\n", " -573.77575684 -521.92242432]\n", " [ -357.77236938 -1050.88598633 -937.78881836 -340.1932373\n", " -673.72698975 0. -491.30606079 -905.3470459\n", " -411.84393311 -518.42871094]\n", " [ -852.84472656 -966.48913574 -761.59924316 -685.07775879\n", " -177.07427979 -618.85943604 -756.14312744 -102.18136597\n", " -460.47125244 0. ]\n", " [ -712.10375977 -574.57720947 -563.62750244 0.\n", " -855.70446777 -436.41946411 -968.52105713 -534.12976074\n", " -455.9407959 -543.6784668 ]]\n", "\n", "Labeled predictions: \n", "[(0, -841.8138427734375), (1, -809.42578125), (2, -686.8201904296875), (3, -514.4450073242188), (4, -308.1148681640625), (5, -555.7971801757812), (6, -855.24853515625), (7, -68.2052001953125), (8, -401.6741943359375), (9, 0.0)]\n", "\n", "Most likely answer: (9, 0.0)\n" ] } ], "source": [ "response = predictor.predict(np.expand_dims(data, axis=1))\n", "print(\"Raw prediction result:\")\n", "print(response)\n", "print()\n", "\n", "labeled_predictions = list(zip(range(10), response[0]))\n", "print(\"Labeled predictions: \")\n", "print(labeled_predictions)\n", "print()\n", "\n", "labeled_predictions.sort(key=lambda label_and_prob: 1.0 - label_and_prob[1])\n", "print(\"Most likely answer: {}\".format(labeled_predictions[0]))" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "### Cleanup\n", "\n", "After you have finished with this example, remember to delete the prediction endpoint to release the instance(s) associated with it" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "sagemaker_session.delete_endpoint(endpoint_name=predictor.endpoint_name)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Notebook CI Test Results\n", "\n", "This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.\n", "\n", "![This us-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-east-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This us-east-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-east-2/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This us-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/us-west-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This ca-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ca-central-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This sa-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/sa-east-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This eu-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-west-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This eu-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-west-2/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This eu-west-3 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-west-3/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This eu-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-central-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This eu-north-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/eu-north-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This ap-southeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-southeast-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This ap-southeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-southeast-2/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This ap-northeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-northeast-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This ap-northeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-northeast-2/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n", "\n", "![This ap-south-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable](https://h75twx4l60.execute-api.us-west-2.amazonaws.com/sagemaker-nb/ap-south-1/sagemaker-python-sdk|pytorch_mnist|pytorch_mnist.ipynb)\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (PyTorch 1.13 Python 3.9 CPU Optimized)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/pytorch-1.13-cpu-py39" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "3.9.16" }, "notice": "Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." }, "nbformat": 4, "nbformat_minor": 4 }