{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Train a PyTorch model with MNIST dataset\n" ] }, { "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-remote-function|pytorch_mnist_sample_notebook|pytorch_mnist.ipynb)\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "The notebook shows how to use the @remote and RemoteExecutor introduced to SageMaker SDK\n", "to train Pytorch models with remote jobs and track the training as SageMaker experiments." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Install the dependencies" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "%pip install -r ./requirements.txt" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "import sagemaker\n", "from sagemaker.experiments.run import Run, load_run\n", "from sagemaker.remote_function import remote, RemoteExecutor\n", "\n", "sm_session = sagemaker.Session()\n", "s3_root_folder = f\"s3://{sm_session.default_bucket()}/remote_function_demo/pytorch_mnist\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load the MNIST data\n", "\n", "Download data to ./data folder, load and normalize them." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "from torchvision import datasets, transforms\n", "\n", "\n", "datasets.MNIST.mirrors = [\n", " f\"https://sagemaker-example-files-prod-{sm_session.boto_region_name}.s3.amazonaws.com/datasets/image/MNIST/\"\n", "]\n", "\n", "train_set = datasets.MNIST(\n", " \"./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", " \"./data\",\n", " train=False,\n", " transform=transforms.Compose(\n", " [transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]\n", " ),\n", " download=True,\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Define the model architecture and training logic" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "import torch\n", "import torch.nn as nn\n", "import torch.nn.functional as F\n", "import torch.optim as optim\n", "\n", "from torch.optim.lr_scheduler import StepLR\n", "\n", "\n", "class Net(nn.Module):\n", " \"\"\"Define the CNN architecture.\"\"\"\n", "\n", " def __init__(self):\n", " super(Net, self).__init__()\n", " self.conv1 = nn.Conv2d(1, 32, 3, 1)\n", " self.conv2 = nn.Conv2d(32, 64, 3, 1)\n", " self.dropout1 = nn.Dropout(0.25)\n", " self.dropout2 = nn.Dropout(0.5)\n", " self.fc1 = nn.Linear(9216, 128)\n", " self.fc2 = nn.Linear(128, 10)\n", "\n", " def forward(self, x):\n", " x = self.conv1(x)\n", " x = F.relu(x)\n", " x = self.conv2(x)\n", " x = F.relu(x)\n", " x = F.max_pool2d(x, 2)\n", " x = self.dropout1(x)\n", " x = torch.flatten(x, 1)\n", " x = self.fc1(x)\n", " x = F.relu(x)\n", " x = self.dropout2(x)\n", " x = self.fc2(x)\n", " output = F.log_softmax(x, dim=1)\n", " return output" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "# Train the model by iterating through the data once\n", "# If dry_run is set to True, it only goes through one batch of the data set\n", "def train(model, device, train_loader, optimizer, epoch, log_interval, dry_run):\n", " model.train()\n", " for batch_idx, (data, target) in enumerate(train_loader):\n", " data, target = data.to(device), target.to(device)\n", " optimizer.zero_grad()\n", " output = model(data)\n", " loss = F.nll_loss(output, target)\n", " loss.backward()\n", " optimizer.step()\n", " if batch_idx % log_interval == 0:\n", " print(\n", " \"Train Epoch: {} [{}/{} ({:.0f}%)]\\tLoss: {:.6f}\".format(\n", " epoch,\n", " batch_idx * len(data),\n", " len(train_loader.dataset),\n", " 100.0 * batch_idx / len(train_loader),\n", " loss.item(),\n", " )\n", " )\n", " if dry_run:\n", " break" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "# Test the trained model using the test data set and also log test metrics to SageMaker experiment runs.\n", "def check_performance(run, model, device, test_loader, epoch):\n", " model.eval()\n", " test_loss = 0\n", " correct = 0\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", " test_loss += F.nll_loss(output, target, reduction=\"sum\").item() # sum up batch loss\n", " pred = output.argmax(dim=1, keepdim=True) # get the index of the max log-probability\n", " correct += pred.eq(target.view_as(pred)).sum().item()\n", "\n", " test_loss /= len(test_loader.dataset)\n", " test_accuracy = 100.0 * correct / len(test_loader.dataset)\n", "\n", " # log metrics\n", " run.log_metric(name=\"test:loss\", value=test_loss, step=epoch)\n", " run.log_metric(name=\"test:accuracy\", value=test_accuracy, step=epoch)\n", "\n", " print(\n", " \"\\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\\n\".format(\n", " test_loss, correct, len(test_loader.dataset), test_accuracy\n", " )\n", " )" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "# Train the model for specified number of epochs and test the performance after each epoch.\n", "def perform_train(\n", " train_data,\n", " test_data,\n", " *,\n", " batch_size: int = 64,\n", " test_batch_size: int = 1000,\n", " epochs: int = 3,\n", " lr: float = 1.0,\n", " gamma: float = 0.7,\n", " no_cuda: bool = True,\n", " no_mps: bool = True,\n", " dry_run: bool = False,\n", " seed: int = 1,\n", " log_interval: int = 10,\n", "):\n", " \"\"\"PyTorch MNIST Example\n", "\n", " :param train_data: the training data set\n", " :param test_data: the test data set\n", " :param batch_size: input batch size for training (default: 64)\n", " :param test_batch_size: input batch size for testing (default: 1000)\n", " :param epochs: number of epochs to train (default: 14)\n", " :param lr: learning rate (default: 1.0)\n", " :param gamma: Learning rate step gamma (default: 0.7)\n", " :param no_cuda: disables CUDA training\n", " :param no_mps: disables macOS GPU training\n", " :param dry_run: quickly check a single pass\n", " :param seed: random seed (default: 1)\n", " :param log_interval: how many batches to wait before logging training status\n", " :return: the trained model\n", " \"\"\"\n", "\n", " use_cuda = not no_cuda and torch.cuda.is_available()\n", " use_mps = not no_mps and torch.backends.mps.is_available()\n", "\n", " torch.manual_seed(seed)\n", "\n", " if use_cuda:\n", " device = torch.device(\"cuda\")\n", " elif use_mps:\n", " device = torch.device(\"mps\")\n", " else:\n", " device = torch.device(\"cpu\")\n", "\n", " train_kwargs = {\"batch_size\": batch_size}\n", " test_kwargs = {\"batch_size\": test_batch_size}\n", " if use_cuda:\n", " cuda_kwargs = {\"num_workers\": 1, \"pin_memory\": True, \"shuffle\": True}\n", " train_kwargs.update(cuda_kwargs)\n", " test_kwargs.update(cuda_kwargs)\n", "\n", " train_loader = torch.utils.data.DataLoader(train_data, **train_kwargs)\n", " test_loader = torch.utils.data.DataLoader(test_data, **test_kwargs)\n", "\n", " model = Net().to(device)\n", " optimizer = optim.Adadelta(model.parameters(), lr=lr)\n", "\n", " scheduler = StepLR(optimizer, step_size=1, gamma=gamma)\n", "\n", " # load the experiment run from the context\n", " with load_run() as run:\n", " run.log_parameters({\"epochs\": epochs, \"lr\": lr, \"gamma\": gamma})\n", "\n", " for epoch in range(1, epochs + 1):\n", " train(model, device, train_loader, optimizer, epoch, log_interval, dry_run)\n", " check_performance(run, model, device, test_loader, epoch)\n", " scheduler.step()\n", "\n", " # log confusion matrix\n", " with torch.no_grad():\n", " data, target = next(iter(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\")\n", "\n", " return model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Execute and test the training function locally\n", "\n", "Set the dry_run to `True` and execute the function locally to verify the correctness of the code and dependencies." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "with Run(\n", " experiment_name=\"local-tests\", run_name=\"local-tests\", sagemaker_session=sm_session\n", ") as run:\n", " trained_model = perform_train(train_set, test_set, epochs=1, dry_run=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup Configuration file path\n", "We are setting the directory in which the config.yaml file resides so that remote decorator can make use of the settings." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "import os\n", "\n", "# Set path to config file\n", "os.environ[\"SAGEMAKER_USER_CONFIG_OVERRIDE\"] = os.getcwd()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Execute the function remotely in parallel\n", "\n", "Here we run a series of jobs to explore how the hyperparameter `lr` impact the performance.\n", "The argument `max_parallel_jobs` controls the max number of jobs that can run in parallel.\n", "We also take advantage of warm pooling to reduce the job start up time." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "from sagemaker.remote_function import RemoteExecutor\n", "\n", "with RemoteExecutor(\n", " max_parallel_jobs=2, keep_alive_period_in_seconds=60, s3_root_uri=s3_root_folder\n", ") as executor:\n", " futures = {}\n", " for run_name, lr in [(\"run-0\", 0.3), (\"run-1\", 1), (\"run-2\", 3.0)]:\n", " with Run(\n", " experiment_name=\"pytorch-mnist\", run_name=run_name, sagemaker_session=sm_session\n", " ) as run:\n", " run.log_artifact(\n", " name=\"raw_data\",\n", " value=f\"https://sagemaker-example-files-prod-{sm_session.boto_region_name}.s3.amazonaws.com/datasets/image/MNIST/\",\n", " is_output=False,\n", " )\n", " futures[run_name] = executor.submit(perform_train, train_set, test_set, lr=lr)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Go to SageMaker Studio to view the experiment runs\n", "\n", "![charts of run-0](./images/experiment_snapshot.png)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "trained_models = [future.result() for future in futures.values()]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Execute the function remotely with function decorator\n", "\n", "Note that the duplication of the `perform_train` function implementation is only for demonstration purpose. `@remote` can be applied to the original `perform_train` once the local test runs successfully." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "from sagemaker.remote_function import remote\n", "\n", "\n", "@remote\n", "def perform_train(\n", " train_data,\n", " test_data,\n", " *,\n", " batch_size: int = 64,\n", " test_batch_size: int = 1000,\n", " epochs: int = 3,\n", " lr: float = 1.0,\n", " gamma: float = 0.7,\n", " no_cuda: bool = True,\n", " no_mps: bool = True,\n", " dry_run: bool = False,\n", " seed: int = 1,\n", " log_interval: int = 10,\n", "):\n", " \"\"\"PyTorch MNIST Example\n", "\n", " :param train_data: the training data set\n", " :param test_data: the test data set\n", " :param batch_size: input batch size for training (default: 64)\n", " :param test_batch_size: input batch size for testing (default: 1000)\n", " :param epochs: number of epochs to train (default: 14)\n", " :param lr: learning rate (default: 1.0)\n", " :param gamma: Learning rate step gamma (default: 0.7)\n", " :param no_cuda: disables CUDA training\n", " :param no_mps: disables macOS GPU training\n", " :param dry_run: quickly check a single pass\n", " :param seed: random seed (default: 1)\n", " :param log_interval: how many batches to wait before logging training status\n", " :return: the trained model\n", " \"\"\"\n", "\n", " use_cuda = not no_cuda and torch.cuda.is_available()\n", " use_mps = not no_mps and torch.backends.mps.is_available()\n", "\n", " torch.manual_seed(seed)\n", "\n", " if use_cuda:\n", " device = torch.device(\"cuda\")\n", " elif use_mps:\n", " device = torch.device(\"mps\")\n", " else:\n", " device = torch.device(\"cpu\")\n", "\n", " train_kwargs = {\"batch_size\": batch_size}\n", " test_kwargs = {\"batch_size\": test_batch_size}\n", " if use_cuda:\n", " cuda_kwargs = {\"num_workers\": 1, \"pin_memory\": True, \"shuffle\": True}\n", " train_kwargs.update(cuda_kwargs)\n", " test_kwargs.update(cuda_kwargs)\n", "\n", " train_loader = torch.utils.data.DataLoader(train_data, **train_kwargs)\n", " test_loader = torch.utils.data.DataLoader(test_data, **test_kwargs)\n", "\n", " model = Net().to(device)\n", " optimizer = optim.Adadelta(model.parameters(), lr=lr)\n", "\n", " scheduler = StepLR(optimizer, step_size=1, gamma=gamma)\n", "\n", " # load the experiment run from the context\n", " with load_run() as run:\n", " run.log_parameters({\"epochs\": epochs, \"lr\": lr, \"gamma\": gamma})\n", "\n", " for epoch in range(1, epochs + 1):\n", " train(model, device, train_loader, optimizer, epoch, log_interval, dry_run)\n", " check_performance(run, model, device, test_loader, epoch)\n", " scheduler.step()\n", "\n", " # log confusion matrix\n", " with torch.no_grad():\n", " data, target = next(iter(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\")\n", "\n", " return model" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "tags": [] }, "outputs": [], "source": [ "with Run(\n", " experiment_name=\"pytorch-mnist-decorator\", run_name=\"run-1\", sagemaker_session=sm_session\n", ") as run:\n", " trained_model = perform_train(train_set, test_set)" ] }, { "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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|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-remote-function|pytorch_mnist_sample_notebook|pytorch_mnist.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 (Base Python 3.0)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/sagemaker-base-python-310-v1" }, "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.10.8" } }, "nbformat": 4, "nbformat_minor": 4 }