{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "de7e4dca-3653-4bf6-80a0-d964492d1d91", "metadata": {}, "source": [ "# Track an experiment while training a Pytorch model locally or in your notebook\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "0c605413", "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-experiments|local_experiment_tracking|pytorch_experiment.ipynb)\n", "\n", "---" ] }, { "attachments": {}, "cell_type": "markdown", "id": "4a603c73", "metadata": {}, "source": [ "\n", "This notebook shows how you can use the SageMaker SDK to track a Machine Learning experiment using a Pytorch model trained locally.\n", "\n", "We introduce two concepts in this notebook -\n", "\n", "* *Experiment:* An experiment is a collection of runs. When you initialize a run in your training loop, you include the name of the experiment that the run belongs to. Experiment names must be unique within your AWS account. \n", "* *Run:* A run consists of all the inputs, parameters, configurations, and results for one iteration of model training. Initialize an experiment run for tracking a training job with Run(). \n", "\n", "To execute this notebook in SageMaker Studio, you should select the `PyTorch 1.12 Python 3.8 CPU Optimizer image`.\n", "\n", "\n", "You can track artifacts for experiments, including datasets, algorithms, hyperparameters and metrics. Experiments executed on SageMaker such as SageMaker training jobs are automatically tracked and any existen SageMaker experiment on your AWS account is automatically migrated to the new UI version.\n", "\n", "In this notebook we will demonstrate the capabilities through an MNIST handwritten digits classification example. The notebook is organized as follow:\n", "\n", "1. Download and prepare the MNIST dataset\n", "2. Train a Convolutional Neural Network (CNN) Model and log the model training metrics\n", "3. Tune the hyperparameters that configures the number of hidden channels and the optimized in the model. Track teh parameter's configuration, resulting model loss and accuracy and automatically plot a confusion matrix using the Experiments capabilities of the SageMaker SDK.\n", "4. Analyse your model results and plot graphs comparing your model different runs generated from the tunning step 3.\n", "\n", "## Runtime\n", "This notebook takes approximately 20 minutes to run.\n", "\n", "## Contents\n", "1. [Install modules](#Install-modules)\n", "1. [Setup](#Setup)\n", "1. [Download the dataset](#Download-the-dataset)\n", "1. [Create experiment and log dataset information](#Create-experiment-and-log-dataset-information)\n", "1. [Create model training functions](#Create-model-training-functions)\n", "1. [Run first experiment](#Run-first-experiment)\n", "1. [Run multiple experiments](#Run-multiple-experiments)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "3368d208-aebb-4844-bf27-2b2e373ef3d2", "metadata": {}, "source": [ "## Setup\n", "\n", "Import required libraries and set logging and experiment configuration\n", "\n", "SageMaker Experiments now provides the `Run` class that allows you to create a new experiment run. You can retrieve an existent experiment run using the `load_run` function.\n", "\n", "You also define a unique name for the experiment that will be used to create and load the experiment later in this notebook" ] }, { "cell_type": "code", "execution_count": null, "id": "037c2813-b191-4420-b37b-9c6d1cbb8057", "metadata": { "tags": [] }, "outputs": [], "source": [ "from torchvision import datasets, transforms\n", "from sagemaker.session import Session\n", "from sagemaker.experiments.run import Run, load_run\n", "from sagemaker.utils import unique_name_from_base\n", "import torch\n", "import os\n", "import sys\n", "import logging\n", "from IPython.display import set_matplotlib_formats\n", "from matplotlib import pyplot as plt\n", "\n", "logger = logging.getLogger(__name__)\n", "logger.setLevel(logging.DEBUG)\n", "logger.addHandler(logging.StreamHandler(sys.stdout))\n", "\n", "\n", "experiment_name = unique_name_from_base(\"local-experiment-example\")\n", "run_name = \"experiment-run\"\n", "print(experiment_name)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "d9dc0054-d7dd-4ec8-b1e9-0b292fc7b1c0", "metadata": {}, "source": [ "## Download the dataset\n", "Let's now use the torchvision library to download the MNIST dataset from tensorflow and apply a transformation on each image" ] }, { "cell_type": "code", "execution_count": null, "id": "20c6e08a-92d3-4819-a080-4858337813cf", "metadata": { "tags": [] }, "outputs": [], "source": [ "# download the dataset\n", "# this will not only download data to ./mnist folder, but also load and transform (normalize) them\n", "datasets.MNIST.urls = [\n", " f\"https://sagemaker-example-files-prod-{Session().boto_region_name}.s3.amazonaws.com/datasets/image/MNIST/train-images-idx3-ubyte.gz\",\n", " f\"https://sagemaker-example-files-prod-{Session().boto_region_name}.s3.amazonaws.com/datasets/image/MNIST/train-labels-idx1-ubyte.gz\",\n", " f\"https://sagemaker-example-files-prod-{Session().boto_region_name}.s3.amazonaws.com/datasets/image/MNIST/t10k-images-idx3-ubyte.gz\",\n", " f\"https://sagemaker-example-files-prod-{Session().boto_region_name}.s3.amazonaws.com/datasets/image/MNIST/t10k-labels-idx1-ubyte.gz\",\n", "]\n", "\n", "train_set = datasets.MNIST(\n", " \"mnist_data\",\n", " train=True,\n", " transform=transforms.Compose(\n", " [transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]\n", " ),\n", " download=True,\n", ")\n", "\n", "test_set = datasets.MNIST(\n", " \"mnist_data\",\n", " train=False,\n", " transform=transforms.Compose(\n", " [transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]\n", " ),\n", " download=True,\n", ")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "1d7fc1d6-5b50-4a96-9e02-1d623072dd39", "metadata": {}, "source": [ "View and example image from the dataset" ] }, { "cell_type": "code", "execution_count": null, "id": "5f8cf8ed-5b35-4474-88b6-f98e0179d4d4", "metadata": { "tags": [] }, "outputs": [], "source": [ "plt.imshow(train_set.data[2].numpy())" ] }, { "attachments": {}, "cell_type": "markdown", "id": "cc1913d9-fe5f-4cf1-aca6-c6f6c12bd21c", "metadata": {}, "source": [ "## Create experiment and log dataset information\n", "\n", "Create an experiment run to track the model training. SageMaker Experiments is a great way to organize your data science work. You can create an experiment to organize all your model runs and analyse the different model metrics with the SageMaker Experiments UI.\n", "\n", "Here we create an experiment run and log parameters for the size of our training and test datasets. We also log all the downloaded files as inputs to our model." ] }, { "cell_type": "code", "execution_count": null, "id": "93f266e0-d73d-452c-a3ed-51b0fc48075d", "metadata": { "tags": [] }, "outputs": [], "source": [ "%%time\n", "# create an experiment and start a new run\n", "with Run(experiment_name=experiment_name, run_name=run_name, sagemaker_session=Session()) as run:\n", " run.log_parameters(\n", " {\"num_train_samples\": len(train_set.data), \"num_test_samples\": len(test_set.data)}\n", " )\n", " for f in os.listdir(train_set.raw_folder):\n", " print(\"Logging\", train_set.raw_folder + \"/\" + f)\n", " run.log_file(train_set.raw_folder + \"/\" + f, name=f, is_output=False)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "259c4fca-5128-4213-8065-cb68bd50b973", "metadata": {}, "source": [ "Checking the SageMaker Experiments UI, you can observe that a new Experiment was created with the run associated to it.\n", "\n", "\n", "\n", "" ] }, { "attachments": {}, "cell_type": "markdown", "id": "87b3cdd3-7b79-4ef2-a2ae-d48b3e5ae393", "metadata": {}, "source": [ "## Create model training functions\n", "\n", "Define your CNN architecture and training function. You can use `run.log_metric` with a defined step to log the metrics of your model for each epoch, in order to plot those metrics with SageMaker Experiments. With `run.log_confusion_matrix` you can automatically plot the confusion matrix of your model." ] }, { "cell_type": "code", "execution_count": null, "id": "2ba41e3d-c6b7-4758-81c1-7e6fc1230a4e", "metadata": { "tags": [] }, "outputs": [], "source": [ "# Based on https://github.com/pytorch/examples/blob/master/mnist/main.py\n", "class Net(torch.nn.Module):\n", " def __init__(self, hidden_channels, kernel_size, drop_out):\n", " super(Net, self).__init__()\n", " self.conv1 = torch.nn.Conv2d(1, hidden_channels, kernel_size=kernel_size)\n", " self.conv2 = torch.nn.Conv2d(hidden_channels, 20, kernel_size=kernel_size)\n", " self.conv2_drop = torch.nn.Dropout2d(p=drop_out)\n", " self.fc1 = torch.nn.Linear(320, 50)\n", " self.fc2 = torch.nn.Linear(50, 10)\n", "\n", " def forward(self, x):\n", " x = torch.nn.functional.relu(torch.nn.functional.max_pool2d(self.conv1(x), 2))\n", " x = torch.nn.functional.relu(\n", " torch.nn.functional.max_pool2d(self.conv2_drop(self.conv2(x)), 2)\n", " )\n", " x = x.view(-1, 320)\n", " x = torch.nn.functional.relu(self.fc1(x))\n", " x = torch.nn.functional.dropout(x, training=self.training)\n", " x = self.fc2(x)\n", " return torch.nn.functional.log_softmax(x, dim=1)" ] }, { "cell_type": "code", "execution_count": null, "id": "a15d44f7-e8bb-43d6-a433-54a5912283c2", "metadata": { "tags": [] }, "outputs": [], "source": [ "def log_performance(model, data_loader, device, epoch, run, metric_type=\"Test\"):\n", " model.eval()\n", " loss = 0\n", " correct = 0\n", " with torch.no_grad():\n", " for data, target in data_loader:\n", " data, target = data.to(device), target.to(device)\n", " output = model(data)\n", " loss += torch.nn.functional.nll_loss(\n", " output, target, reduction=\"sum\"\n", " ).item() # sum up batch loss\n", " # get the index of the max log-probability\n", " pred = output.max(1, keepdim=True)[1]\n", " correct += pred.eq(target.view_as(pred)).sum().item()\n", " loss /= len(data_loader.dataset)\n", " accuracy = 100.0 * correct / len(data_loader.dataset)\n", " # log metrics\n", " run.log_metric(name=metric_type + \":loss\", value=loss, step=epoch)\n", " run.log_metric(name=metric_type + \":accuracy\", value=accuracy, step=epoch)\n", "\n", "\n", "def train_model(\n", " run, train_set, test_set, data_dir=\"mnist_data\", optimizer=\"sgd\", epochs=10, hidden_channels=10\n", "):\n", " \"\"\"\n", " Function that trains the CNN classifier to identify the MNIST digits.\n", " Args:\n", " run (sagemaker.experiments.run.Run): SageMaker Experiment run object\n", " train_set (torchvision.datasets.mnist.MNIST): train dataset\n", " test_set (torchvision.datasets.mnist.MNIST): test dataset\n", " data_dir (str): local directory where the MNIST datasource is stored\n", " optimizer (str): the optimization algorthm to use for training your CNN\n", " available options are sgd and adam\n", " epochs (int): number of complete pass of the training dataset through the algorithm\n", " hidden_channels (int): number of hidden channels in your model\n", " \"\"\"\n", "\n", " # log the parameters of your model\n", " run.log_parameter(\"device\", \"cpu\")\n", " run.log_parameters(\n", " {\n", " \"data_dir\": data_dir,\n", " \"optimizer\": optimizer,\n", " \"epochs\": epochs,\n", " \"hidden_channels\": hidden_channels,\n", " }\n", " )\n", "\n", " # train the model on the CPU (no GPU)\n", " device = torch.device(\"cpu\")\n", "\n", " # set the seed for generating random numbers\n", " torch.manual_seed(42)\n", "\n", " train_loader = torch.utils.data.DataLoader(train_set, batch_size=64, shuffle=True)\n", " test_loader = torch.utils.data.DataLoader(test_set, batch_size=1000, shuffle=True)\n", " model = Net(hidden_channels, kernel_size=5, drop_out=0.5).to(device)\n", " model = torch.nn.DataParallel(model)\n", " momentum = 0.5\n", " lr = 0.01\n", " log_interval = 100\n", " if optimizer == \"sgd\":\n", " optimizer = torch.optim.SGD(model.parameters(), lr=lr, momentum=momentum)\n", " else:\n", " optimizer = torch.optim.Adam(model.parameters(), lr=lr)\n", "\n", " for epoch in range(1, epochs + 1):\n", " print(\"Training Epoch:\", epoch)\n", " model.train()\n", " for batch_idx, (data, target) in enumerate(train_loader, 1):\n", " data, target = data.to(device), target.to(device)\n", " optimizer.zero_grad()\n", " output = model(data)\n", " loss = torch.nn.functional.nll_loss(output, target)\n", " loss.backward()\n", " optimizer.step()\n", "\n", " log_performance(model, train_loader, device, epoch, run, \"Train\")\n", " log_performance(model, test_loader, device, epoch, run, \"Test\")\n", " # log confusion matrix\n", " with torch.no_grad():\n", " for data, target in test_loader:\n", " data, target = data.to(device), target.to(device)\n", " output = model(data)\n", " pred = output.max(1, keepdim=True)[1]\n", " run.log_confusion_matrix(target, pred, \"Confusion-Matrix-Test-Data\")" ] }, { "attachments": {}, "cell_type": "markdown", "id": "586a8712-f4c9-4769-8e3f-299a45869980", "metadata": {}, "source": [ "## Run first experiment\n", "\n", "You can load an existent run using the `load_run` function with `experiment_name` and `run_name` as parameters. \n", "Here we train the CNN with 5 hidden channels and ADAM as optimizer. " ] }, { "cell_type": "code", "execution_count": null, "id": "1e3e836e-2deb-4bc4-b246-062bb1a719de", "metadata": { "tags": [] }, "outputs": [], "source": [ "%%time\n", "with load_run(\n", " experiment_name=experiment_name, run_name=run_name, sagemaker_session=Session()\n", ") as run:\n", " train_model(\n", " run=run,\n", " train_set=train_set,\n", " test_set=test_set,\n", " epochs=5,\n", " hidden_channels=2,\n", " optimizer=\"adam\",\n", " )" ] }, { "attachments": {}, "cell_type": "markdown", "id": "df712f1f-c85d-4200-98b6-89a648e34cc7", "metadata": {}, "source": [ "In the SageMaker Experiments UI, you can observe that the new model parameters are added to the run. The model training metrics are captured and can be used to plot graphs. Additionally, the confusion matrix graph is automatically plotted in the UI.\n", "\n", "\n", "\n", "\n", "\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "d8ef9a56-fff5-40a0-8d08-db766e66d7ec", "metadata": {}, "source": [ "## Run multiple experiments\n", "\n", "You can now create multiple runs of your experiment using the functions created before" ] }, { "cell_type": "code", "execution_count": null, "id": "4ab66d9a-b2f2-4089-a450-b5c653723691", "metadata": { "tags": [] }, "outputs": [], "source": [ "%%time\n", "# define the list of parameters to train the model with\n", "num_hidden_channel_param = [5, 10]\n", "optimizer_param = [\"adam\", \"sgd\"]\n", "run_id = 0\n", "# train the model using SageMaker Experiments to track the model parameters,\n", "# metrics and performance\n", "sm_session = Session()\n", "for i, num_hidden_channel in enumerate(num_hidden_channel_param):\n", " for k, optimizer in enumerate(optimizer_param):\n", " run_id += 1\n", " run_name = \"experiment-run-\" + str(run_id)\n", " print(run_name)\n", " print(\n", " f\"Training model with: {num_hidden_channel} hidden channels and {optimizer} as optimizer\"\n", " )\n", " # Defining an experiment run for each model training run\n", " with Run(\n", " experiment_name=experiment_name, run_name=run_name, sagemaker_session=sm_session\n", " ) as run:\n", " train_model(\n", " run=run,\n", " train_set=train_set,\n", " test_set=test_set,\n", " epochs=5,\n", " hidden_channels=num_hidden_channel,\n", " optimizer=optimizer,\n", " )" ] }, { "attachments": {}, "cell_type": "markdown", "id": "5c978f9b-eba9-4db9-bdfa-01f6ee12210f", "metadata": { "tags": [] }, "source": [ "In the SageMaker Experiments UI, you can compare the different runs and analyze the metrics for those runs \n", "\n", "\n", "\n" ] }, { "attachments": {}, "cell_type": "markdown", "id": "1b08f9ea", "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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.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-experiments|local_experiment_tracking|pytorch_experiment.ipynb)\n" ] } ], "metadata": { "availableInstances": [ { "_defaultOrder": 0, "_isFastLaunch": true, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 4, "name": "ml.t3.medium", "vcpuNum": 2 }, { "_defaultOrder": 1, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 8, "name": "ml.t3.large", "vcpuNum": 2 }, { "_defaultOrder": 2, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 16, "name": "ml.t3.xlarge", "vcpuNum": 4 }, { "_defaultOrder": 3, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 32, "name": "ml.t3.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 4, "_isFastLaunch": true, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 8, "name": "ml.m5.large", "vcpuNum": 2 }, { "_defaultOrder": 5, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 16, "name": "ml.m5.xlarge", "vcpuNum": 4 }, { "_defaultOrder": 6, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 32, "name": "ml.m5.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 7, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 64, "name": "ml.m5.4xlarge", "vcpuNum": 16 }, { "_defaultOrder": 8, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 128, "name": "ml.m5.8xlarge", "vcpuNum": 32 }, { "_defaultOrder": 9, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 192, "name": "ml.m5.12xlarge", "vcpuNum": 48 }, { "_defaultOrder": 10, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 256, "name": "ml.m5.16xlarge", "vcpuNum": 64 }, { "_defaultOrder": 11, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 384, "name": "ml.m5.24xlarge", "vcpuNum": 96 }, { "_defaultOrder": 12, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 8, "name": "ml.m5d.large", "vcpuNum": 2 }, { "_defaultOrder": 13, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 16, "name": "ml.m5d.xlarge", "vcpuNum": 4 }, { "_defaultOrder": 14, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 32, "name": "ml.m5d.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 15, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 64, "name": "ml.m5d.4xlarge", "vcpuNum": 16 }, { "_defaultOrder": 16, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 128, "name": "ml.m5d.8xlarge", "vcpuNum": 32 }, { "_defaultOrder": 17, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 192, "name": "ml.m5d.12xlarge", "vcpuNum": 48 }, { "_defaultOrder": 18, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 256, "name": "ml.m5d.16xlarge", "vcpuNum": 64 }, { "_defaultOrder": 19, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 384, "name": "ml.m5d.24xlarge", "vcpuNum": 96 }, { "_defaultOrder": 20, "_isFastLaunch": false, "category": "General purpose", "gpuNum": 0, "hideHardwareSpecs": true, "memoryGiB": 0, "name": "ml.geospatial.interactive", "supportedImageNames": [ "sagemaker-geospatial-v1-0" ], "vcpuNum": 0 }, { "_defaultOrder": 21, "_isFastLaunch": true, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 4, "name": "ml.c5.large", "vcpuNum": 2 }, { "_defaultOrder": 22, "_isFastLaunch": false, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 8, "name": "ml.c5.xlarge", "vcpuNum": 4 }, { "_defaultOrder": 23, "_isFastLaunch": false, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 16, "name": "ml.c5.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 24, "_isFastLaunch": false, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 32, "name": "ml.c5.4xlarge", "vcpuNum": 16 }, { "_defaultOrder": 25, "_isFastLaunch": false, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 72, "name": "ml.c5.9xlarge", "vcpuNum": 36 }, { "_defaultOrder": 26, "_isFastLaunch": false, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 96, "name": "ml.c5.12xlarge", "vcpuNum": 48 }, { "_defaultOrder": 27, "_isFastLaunch": false, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 144, "name": "ml.c5.18xlarge", "vcpuNum": 72 }, { "_defaultOrder": 28, "_isFastLaunch": false, "category": "Compute optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 192, "name": "ml.c5.24xlarge", "vcpuNum": 96 }, { "_defaultOrder": 29, "_isFastLaunch": true, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 16, "name": "ml.g4dn.xlarge", "vcpuNum": 4 }, { "_defaultOrder": 30, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 32, "name": "ml.g4dn.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 31, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 64, "name": "ml.g4dn.4xlarge", "vcpuNum": 16 }, { "_defaultOrder": 32, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 128, "name": "ml.g4dn.8xlarge", "vcpuNum": 32 }, { "_defaultOrder": 33, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 4, "hideHardwareSpecs": false, "memoryGiB": 192, "name": "ml.g4dn.12xlarge", "vcpuNum": 48 }, { "_defaultOrder": 34, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 256, "name": "ml.g4dn.16xlarge", "vcpuNum": 64 }, { "_defaultOrder": 35, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 61, "name": "ml.p3.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 36, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 4, "hideHardwareSpecs": false, "memoryGiB": 244, "name": "ml.p3.8xlarge", "vcpuNum": 32 }, { "_defaultOrder": 37, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 8, "hideHardwareSpecs": false, "memoryGiB": 488, "name": "ml.p3.16xlarge", "vcpuNum": 64 }, { "_defaultOrder": 38, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 8, "hideHardwareSpecs": false, "memoryGiB": 768, "name": "ml.p3dn.24xlarge", "vcpuNum": 96 }, { "_defaultOrder": 39, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 16, "name": "ml.r5.large", "vcpuNum": 2 }, { "_defaultOrder": 40, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 32, "name": "ml.r5.xlarge", "vcpuNum": 4 }, { "_defaultOrder": 41, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 64, "name": "ml.r5.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 42, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 128, "name": "ml.r5.4xlarge", "vcpuNum": 16 }, { "_defaultOrder": 43, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 256, "name": "ml.r5.8xlarge", "vcpuNum": 32 }, { "_defaultOrder": 44, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 384, "name": "ml.r5.12xlarge", "vcpuNum": 48 }, { "_defaultOrder": 45, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 512, "name": "ml.r5.16xlarge", "vcpuNum": 64 }, { "_defaultOrder": 46, "_isFastLaunch": false, "category": "Memory Optimized", "gpuNum": 0, "hideHardwareSpecs": false, "memoryGiB": 768, "name": "ml.r5.24xlarge", "vcpuNum": 96 }, { "_defaultOrder": 47, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 16, "name": "ml.g5.xlarge", "vcpuNum": 4 }, { "_defaultOrder": 48, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 32, "name": "ml.g5.2xlarge", "vcpuNum": 8 }, { "_defaultOrder": 49, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 64, "name": "ml.g5.4xlarge", "vcpuNum": 16 }, { "_defaultOrder": 50, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 128, "name": "ml.g5.8xlarge", "vcpuNum": 32 }, { "_defaultOrder": 51, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 1, "hideHardwareSpecs": false, "memoryGiB": 256, "name": "ml.g5.16xlarge", "vcpuNum": 64 }, { "_defaultOrder": 52, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 4, "hideHardwareSpecs": false, "memoryGiB": 192, "name": "ml.g5.12xlarge", "vcpuNum": 48 }, { "_defaultOrder": 53, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 4, "hideHardwareSpecs": false, "memoryGiB": 384, "name": "ml.g5.24xlarge", "vcpuNum": 96 }, { "_defaultOrder": 54, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 8, "hideHardwareSpecs": false, "memoryGiB": 768, "name": "ml.g5.48xlarge", "vcpuNum": 192 }, { "_defaultOrder": 55, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 8, "hideHardwareSpecs": false, "memoryGiB": 1152, "name": "ml.p4d.24xlarge", "vcpuNum": 96 }, { "_defaultOrder": 56, "_isFastLaunch": false, "category": "Accelerated computing", "gpuNum": 8, "hideHardwareSpecs": false, "memoryGiB": 1152, "name": "ml.p4de.24xlarge", "vcpuNum": 96 } ], "kernelspec": { "display_name": "Python 3 (PyTorch 1.12 Python 3.8 CPU Optimized)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/pytorch-1.12-cpu-py38" }, "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.8.16" } }, "nbformat": 4, "nbformat_minor": 5 }