{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Using ESMFold to Predict Protein Structures on SageMaker" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "NOTE: The authors recommend running this notebook in Amazon SageMaker Studio with the following environment settings: \n", "* **PyTorch 1.13 Python 3.9 CPU-optimized** image \n", "* **Python 3** kernel \n", "* **ml.r5.xlarge** instance type \n", "\n", "For improved performance, you may also use the **PyTorch 1.13 Python 3.9 GPU-optimized** image and a **ml.g4dn.2xlarge** instance type.\n", "\n", "---" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Understanding the structure of proteins like antibodies is important for understanding their function. However, it can be difficult and expensive to do this in a laboratory. Recently AI-driven protein folding algorithms have enabled biologists to predict these structures from their aminio acid sequences instead.\n", "\n", "In this notebook, we will use the [ESMFold](https://www.biorxiv.org/content/10.1101/2022.07.20.500902v1) protein folding algorithm to predict the structure of Herceptin (Trastuzumab), an important breast cancer therapy. Herceptin is a [monoclonal antibody](https://www.cancer.org/treatment/treatments-and-side-effects/treatment-types/immunotherapy/monoclonal-antibodies.html) (mAb) that binds to the HER2 receptor, inhibiting cancer cell growth. The following diagram shows several of the common elements of monoclonal antibodies.\n", "\n", "![A diagram of the major structural elements of an antibody](img/antibody.png)\n", "\n", "In this notebook, we'll focus on predicting the structure of the heavy chain region." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "%pip install -U -q -r esmfold-requirements.txt --disable-pip-version-check" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "## 1. Download and Visualize the Experimentally-Determined Herceptin Protein Structure" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "from Bio.PDB import PDBList, MMCIFParser\n", "import os\n", "import py3Dmol\n", "from prothelpers.structure import atoms_to_pdb\n", "import warnings\n", "\n", "target_id = \"1N8Z\"\n", "\n", "if not os.path.isdir(\"data\"):\n", " os.mkdir(\"data\")\n", "\n", "pdbl = PDBList()\n", "filename = pdbl.retrieve_pdb_file(target_id, pdir=\"data\", file_format=\"mmCif\")\n", "parser = MMCIFParser()\n", "with warnings.catch_warnings():\n", " warnings.simplefilter(\"ignore\")\n", " structure_1N8Z = parser.get_structure(target_id, filename)\n", "pdb_string = atoms_to_pdb(structure_1N8Z[0])\n", "\n", "view = py3Dmol.view(width=600, height=400)\n", "view.addModel(pdb_string)\n", "view.setStyle({\"chain\": \"A\"}, {\"cartoon\": {\"color\": \"orange\", \"opacity\": 0.5}})\n", "view.setStyle({\"chain\": \"B\"}, {\"cartoon\": {\"color\": \"blue\"}})\n", "view.setStyle({\"chain\": \"C\"}, {\"cartoon\": {\"color\": \"green\", \"opacity\": 0.5}})\n", "view.zoomTo()\n", "view.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the image above, the light chain (A) is in orange, the heavy chain (B) is in blue, and the HER2 antigen (chain C) is in green. In this notebook, we will use ESMFold to predict the structure of chain B from it's amino acid sequence. Then, we will compare the prediction to the experimentally-determined structure shown above." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Extract the structure and sequence of chain B for later use." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "from prothelpers.structure import get_aa_seq\n", "\n", "experimental_structure = atoms_to_pdb(structure_1N8Z[0][\"B\"])\n", "with open(\"data/experimental.pdb\", \"w\") as f:\n", " f.write(experimental_structure)\n", "\n", "experimental_sequence = get_aa_seq(structure_1N8Z[0][\"B\"])" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "## 2. Make an In-Notebook ESMFold Prediction\n", "We'll use the ESMFold model to predict the structure of the heavy chain and compare it to the experimental result. First, we load the pre-trained ESMFold model and tokenizer from HuggingFace Hub. This will take about one minute." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "from transformers import AutoTokenizer, EsmForProteinFolding\n", "\n", "tokenizer = AutoTokenizer.from_pretrained(\"facebook/esmfold_v1\")\n", "model = EsmForProteinFolding.from_pretrained(\n", " \"facebook/esmfold_v1\", low_cpu_mem_usage=True\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If using a GPU, we can switch to half-precision and use other optimizations to improve performance. We can also use a CPU for lower cost, but slower performance." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "import torch\n", "\n", "if torch.cuda.is_available():\n", " device = torch.device(\"cuda\")\n", " model.esm = model.esm.half()\n", " torch.backends.cuda.matmul.allow_tf32 = True\n", "else:\n", " print(\"CUDA not detected. Using CPU-only parameters\")\n", " device = torch.device(\"cpu\")\n", " model.esm = model.esm.float()\n", " torch.backends.cuda.matmul.allow_tf32 = False\n", "\n", "model = model.to(device)\n", "model.trunk.set_chunk_size(64)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we tokenize the sequence to convert it into a numerical format that ESMFold can use for prediction" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "tokenized_input = tokenizer(\n", " [experimental_sequence], return_tensors=\"pt\", add_special_tokens=False\n", ")[\"input_ids\"]\n", "tokenized_input = tokenized_input.to(device)\n", "\n", "print(f\"The human-readable sequence is {experimental_sequence}\")\n", "print(f\"The tokenized representation of the sequences is {tokenized_input}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, we submit the tokenized sequence to the ESMFold model to predict the 3D structure. This will take about three minutes on a non-accelerated instance type and several seconds on an accelerated instance." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "%%time\n", "print(f\"Predicting the structure of protein sequence {experimental_sequence}\")\n", "with torch.no_grad():\n", " notebook_prediction = model.infer_pdb(experimental_sequence)\n", "\n", "with open(\"data/prediction.pdb\", \"w\") as f:\n", " f.write(notebook_prediction)\n", "\n", "if torch.cuda.is_available():\n", " torch.cuda.empty_cache()\n", "\n", "print(f\"Prediction complete\")" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "We can determine the accuracy of our prediction by comparing it to the experimental structure and calculating a [TM-score](https://zhanggroup.org/TM-score/) between 0 and 1." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "from prothelpers.usalign import tmscore\n", "\n", "tmscore(\"data/prediction.pdb\", \"data/experimental.pdb\", pymol=\"data/superimposed\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A TM-Score of 0.8 isn't perfect, but good enough for analytical tasks like ligand-binding analysis. Let's visualize how the experimentally-determined and predicted structure align." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "view = py3Dmol.view(width=600, height=400)\n", "\n", "with open(\"data/experimental.pdb\") as ifile:\n", " superimposed = \"\".join([x for x in ifile])\n", "view.addModel(experimental_structure)\n", "\n", "with open(\"data/superimposed.pdb\") as ifile:\n", " superimposed = \"\".join([x for x in ifile])\n", "view.addModel(superimposed)\n", "\n", "view.setStyle({\"model\": 0}, {\"cartoon\": {\"color\": \"blue\"}})\n", "view.setStyle({\"model\": 1}, {\"cartoon\": {\"color\": \"red\"}})\n", "view.zoomTo()\n", "view.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The two structures show a high, but not perfect, degree of overlap. Protein structure predictions is a rapidly-evolving field and many research teams are developing ever-more accurate algorithms!" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "## 3. Deploy ESMFold as a SageMaker Inference API" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model inference in a notebook is fine for experimentation, but what if you need to integrate your model with an application? Or an MLOps pipeline? In this case, a better option is to deploy your model as an API endpoint. In this example, we'll deploy ESMFold as a real-time inference endpoint on an accelerated instance." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "import sagemaker\n", "import boto3\n", "import os\n", "\n", "boto_session = boto3.Session()\n", "sm_sess = sagemaker.Session()\n", "sm_client = boto_session.client(\"sagemaker\")\n", "region = sm_sess.boto_region_name\n", "bucket = sm_sess.default_bucket()\n", "prefix = \"sagemaker/ESMfold\"\n", "role = sagemaker.get_execution_role()\n", "\n", "if not os.path.isdir(\"code\"):\n", " os.mkdir(\"code\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The pre-built PyTorch container makes it easy to deploy deep learning models for common tasks. To predict protein structures we need to define a custom `inference.py` script to load the model, run the prediction, and format the output." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "%%writefile code/inference.py\n", "\n", "import json\n", "import numpy as np\n", "import os\n", "import torch\n", "import traceback\n", "import transformers\n", "from transformers.models.esm.openfold_utils.feats import atom14_to_atom37\n", "from transformers.models.esm.openfold_utils.protein import to_pdb, Protein as OFProtein\n", "from typing import Any, Dict, List\n", "\n", "MODEL_NAME = \"facebook/esmfold_v1\"\n", "\n", "def model_fn(model_dir: str) -> Dict[str, Any]:\n", " \"\"\" Load the model artifact \"\"\"\n", "\n", " try:\n", " model_path = os.path.join(model_dir, \"esmfold_v1\")\n", " tokenizer = transformers.AutoTokenizer.from_pretrained(model_path)\n", " model = transformers.EsmForProteinFolding.from_pretrained(model_path, low_cpu_mem_usage=True)\n", "\n", " if torch.cuda.is_available():\n", " model.to(\"cuda\")\n", " model.esm = model.esm.half()\n", " torch.backends.cuda.matmul.allow_tf32 = True\n", " model.trunk.set_chunk_size(64)\n", " else:\n", " model.to(\"cpu\")\n", " model.esm = model.esm.float()\n", " model.trunk.set_chunk_size(64)\n", "\n", " return tokenizer, model\n", " except Exception as e:\n", " traceback.print_exc()\n", " raise e\n", " \n", "def input_fn(request_body: str, request_content_type: str = \"text/csv\") -> List[str]:\n", " \"\"\" Process the request \"\"\"\n", "\n", " print(request_content_type)\n", " \n", " if request_content_type == \"text/csv\":\n", " sequence = request_body\n", " print(\"Input protein sequence: \", sequence)\n", " return sequence\n", " elif request_content_type == \"application/json\":\n", " sequence = json.loads(request_body)\n", " print(\"Input protein sequence: \", sequence)\n", " return sequence\n", " else:\n", " raise ValueError(\"Unsupported content type: {}\".format(request_content_type)) \n", "\n", "def predict_fn(input_data: List, tokenizer_model: tuple) -> np.ndarray:\n", " \"\"\" Run the prediction \"\"\"\n", " \n", " try:\n", " device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", " esm_tokenizer, esm_model = tokenizer_model\n", " tokenized_input = esm_tokenizer(\n", " input_data, return_tensors=\"pt\", add_special_tokens=False\n", " )[\"input_ids\"].to(device)\n", "\n", " with torch.no_grad():\n", " output = esm_model(tokenized_input)\n", " return output\n", " except Exception as e:\n", " traceback.print_exc()\n", " raise e\n", " \n", "def output_fn(outputs: str, response_content_type: str = \"text/csv\"):\n", " \"\"\"Transform the prediction into a pdb-formatted string\"\"\"\n", " \n", " final_atom_positions = atom14_to_atom37(outputs[\"positions\"][-1], outputs)\n", " outputs = {k: v.to(\"cpu\").numpy() for k, v in outputs.items()}\n", " final_atom_positions = final_atom_positions.cpu().numpy()\n", " final_atom_mask = outputs[\"atom37_atom_exists\"]\n", " pdbs = []\n", " for i in range(outputs[\"aatype\"].shape[0]):\n", " aa = outputs[\"aatype\"][i]\n", " pred_pos = final_atom_positions[i]\n", " mask = final_atom_mask[i]\n", " resid = outputs[\"residue_index\"][i] + 1\n", " pred = OFProtein(\n", " aatype=aa,\n", " atom_positions=pred_pos,\n", " atom_mask=mask,\n", " residue_index=resid,\n", " b_factors=outputs[\"plddt\"][i],\n", " chain_index=outputs[\"chain_index\"][i] if \"chain_index\" in outputs else None,\n", " )\n", " pdbs.append(to_pdb(pred))\n", " \n", " if response_content_type == \"text/csv\":\n", " return pdbs\n", " elif response_content_type == \"application/json\":\n", " return json.dumps(pdbs)\n", " else:\n", " raise ValueError(\"Unsupported content type: {}\".format(response_content_type))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can also define additional packages needed by our inference code in a `requirements.txt` file." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "%%writefile code/requirements.txt\n", "\n", "transformers==4.24.0\n", "accelerate==0.17.0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this example, we use a model artifact previously downloaded from HuggingFace hub and uploaded to S3." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "from sagemaker.huggingface import HuggingFaceModel\n", "from datetime import datetime\n", "\n", "public_model_url = \"s3://aws-hcls-ml/workshop/esmfold/esmfold_v1.tar.gz\"\n", "\n", "huggingface_model = HuggingFaceModel(\n", " model_data=public_model_url,\n", " name=f\"emsfold-v1-model-\" + datetime.now().strftime(\"%Y%m%d%s\"),\n", " transformers_version=\"4.17\",\n", " pytorch_version=\"1.10\",\n", " py_version=\"py38\",\n", " role=role,\n", " source_dir=\"code\",\n", " entry_point=\"inference.py\",\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we deploy the model to a real-time inference endpoint hosted on an accelerated instance type. This may take 10 minutes or more depending on the availability of ml.g4dn.2xlarge instances in your region." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "endpoint_name = f\"emsfold-v1-rt-endpoint-\" + datetime.now().strftime(\"%Y%m%d%s\")\n", "%store endpoint_name" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "%%time\n", "\n", "predictor = huggingface_model.deploy(\n", " initial_instance_count=1,\n", " instance_type=\"ml.g4dn.2xlarge\",\n", " endpoint_name=endpoint_name\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Submit the chain B sequence to the endpoint and print the first few rows of the predicted structure file." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "endpoint_prediction = predictor.predict(experimental_sequence)[0]\n", "print(endpoint_prediction[:900])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, save the predicted structure to a file and compare it to the notebook prediction. The two predictions should be identical." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "from prothelpers import usalign\n", "\n", "with open(\"data/endpoint_prediction.pdb\", \"w\") as f:\n", " f.write(endpoint_prediction)\n", "\n", "usalign.tmscore(\n", " \"data/endpoint_prediction.pdb\", \"data/prediction.pdb\", pymol=\"data/esm_superimposed\"\n", ")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "view2 = py3Dmol.view(width=600, height=400)\n", "\n", "with open(\"data/prediction.pdb\") as ifile:\n", " prediction = \"\".join([x for x in ifile])\n", "view2.addModel(prediction)\n", "\n", "with open(\"data/esm_superimposed.pdb\") as ifile:\n", " esm_superimposed = \"\".join([x for x in ifile])\n", "view2.addModel(esm_superimposed)\n", "\n", "view2.setStyle({\"model\": 0}, {\"cartoon\": {\"color\": \"red\"}})\n", "view2.setStyle({\"model\": 1}, {\"cartoon\": {\"color\": \"blue\"}})\n", "view2.zoomTo()\n", "view2.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you don't plan to run the next module, you can uncomment this final cell to remove the endpoint and data and halt further charges." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# try:\n", "# predictor.delete_endpoint()\n", "# except:\n", "# pass" ] } ], "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 } ], "instance_type": "ml.r5.xlarge", "kernelspec": { "display_name": "Python 3 (PyTorch 1.13 Python 3.9 CPU Optimized)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/pytorch-1.13-cpu-py39" }, "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.9.16" }, "vscode": { "interpreter": { "hash": "fdfb68e871d6536365c355bf7b4d3dfd72c5c59726fd6212cf37d110d4af5d61" } } }, "nbformat": 4, "nbformat_minor": 4 }