{ "cells": [ { "cell_type": "markdown", "id": "e9b7c2d0-ea3d-48f9-bff0-bd71e156421d", "metadata": {}, "source": [ "Note : Please use **PyTorch 2.0 Python 3.10 GPU kernel on g4dn.xlarge** for this notebook" ] }, { "cell_type": "markdown", "id": "9eb70bb6-6eae-4cbf-b228-b1c9c5d61c04", "metadata": {}, "source": [ "# What's the use case?\n", "In this lab we will generate synthetic satellite images. These images can be used for research or as input data for building your computer vision models." ] }, { "cell_type": "markdown", "id": "82230498-8559-4b47-bb7e-bd855aafcf82", "metadata": {}, "source": [ "# Stable Diffusion" ] }, { "cell_type": "raw", "id": "511d4ee5-b7a7-4508-976b-827081a20c64", "metadata": {}, "source": [ "Stable Diffusion is a Generative AI model that makes it easy for you to generate images from text. Besides image generation though, stable diffusion also has a host of other features such as generating an image based on another image and a prompt (image to image), in-painting (modifying part of an image , out-painting (extending the image) and upscaling (increasing the resolution of an image). " ] }, { "cell_type": "markdown", "id": "3accf4d9-e879-4416-a90a-e8a1b2f50d12", "metadata": { "tags": [] }, "source": [ "## Why fine tune stable diffusion?" ] }, { "cell_type": "markdown", "id": "0636bfe9-a3b6-4206-9264-9c62a6c31122", "metadata": {}, "source": [ "Although Stable diffusion is great at generating images, the quality of images that specialise in a particular are may not be great. For example, in this notebook we aim to generate satellite images. However, the default satellite images that are generated do show some of the features (such as highways) very well. To improve the quality of satellite images with highways, we fine-tune stable diffusion using real satellite images." ] }, { "cell_type": "markdown", "id": "506f91fa-394f-4f49-a5db-3a307b67311f", "metadata": {}, "source": [ "## How do we fine-tune" ] }, { "cell_type": "markdown", "id": "d00a5a34-5620-4f26-be65-68c50d266133", "metadata": {}, "source": [ "To fine-tune stable diffusion we use a method called DreamBooth which is described [here](https://dreambooth.github.io/). Here's a short description of dreambooth from the paper\n", "> Our method takes as input a few images (typically 3-5 images suffice, based on our experiments) of a subject (e.g., a specific dog) and the corresponding class name (e.g. \"dog\"), and returns a fine-tuned/\"personalized'' text-to-image model that encodes a unique identifier that refers to the subject. Then, at inference, we can implant the unique identifier in different sentences to synthesize the subjects in difference contexts." ] }, { "cell_type": "markdown", "id": "de03eae0-d997-416a-8084-c2bcdad9b0be", "metadata": {}, "source": [ "**Lets Get started!**\n", "The first step is to get a feel of the hardware. A reminder though, please make sure you have the right kernel and notebook size as specified at the top!\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "9b4b7c00-9a68-41d7-aea1-e5ab74763629", "metadata": { "tags": [] }, "outputs": [], "source": [ "!nvidia-smi" ] }, { "cell_type": "markdown", "id": "c2eb2965-9095-4621-b696-3d9a574040e1", "metadata": {}, "source": [ "Next, we install a few libraries that the notebook needs." ] }, { "cell_type": "code", "execution_count": null, "id": "05a16c87-f909-4812-90bd-7bdb5d61b0a3", "metadata": { "tags": [] }, "outputs": [], "source": [ "!pip install transformers accelerate>=0.16.0 ftfy tensorboard Jinja2 huggingface_hub wandb kaggle git+https://github.com/huggingface/diffusers" ] }, { "cell_type": "markdown", "id": "a143ee81-cde7-4c8a-ae84-a44f78bca47b", "metadata": {}, "source": [ "### Dataset\n", "For this tutorial, we will use the EuroSAT dataset, which is a land use classification dataset consisting of Sentinel 2 Satellite images. We will use the `Highway` class as the type of satellite image that we would like to generate. The `Forest` and `Industrial` classes serve as the *class* that we want the model to separate the `Highway` *instance*. Note, for the purposes of this exercise, we will display all images resized to 64,64 to match the EuroSAT dataset image size.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "5356be77-9071-4504-bce1-126f42298cc8", "metadata": { "tags": [] }, "outputs": [], "source": [ "!mkdir -p EuroSAT/Highway\n", "!unzip -q eurosat-dataset.zip \"EuroSAT/Highway/*\" -d \"\"" ] }, { "cell_type": "code", "execution_count": null, "id": "965d3815-ae53-403c-9761-4ad71b4f21d7", "metadata": { "tags": [] }, "outputs": [], "source": [ "!mkdir -p EuroSAT/base/Forest\n", "!unzip -q eurosat-dataset.zip \"EuroSAT/Forest/*\" -d \"base\"" ] }, { "cell_type": "code", "execution_count": null, "id": "752ee964-dc64-4b21-89b3-57b5defb9da7", "metadata": { "tags": [] }, "outputs": [], "source": [ "!mkdir -p EuroSAT/base/Industrial\n", "!unzip -q eurosat-dataset.zip \"EuroSAT/Industrial/*\" -d \"base\"" ] }, { "cell_type": "markdown", "id": "935a7210-34fe-4f9a-8ea3-87adcdfff29f", "metadata": {}, "source": [ "## View Dataset\n", "Let's view the `Highway` class of the EuroSAT dataset" ] }, { "cell_type": "code", "execution_count": null, "id": "4ca65389-b58d-466e-8e66-9949dfd99dfd", "metadata": { "tags": [] }, "outputs": [], "source": [ "from PIL import Image\n", "\n", "def image_grid(imgs, rows, cols):\n", " assert len(imgs) == rows*cols\n", "\n", " w, h = imgs[0].size\n", " grid = Image.new('RGB', size=(cols*w, rows*h))\n", " grid_w, grid_h = grid.size\n", " \n", " for i, img in enumerate(imgs):\n", " grid.paste(img, box=(i%cols*w, i//cols*h))\n", " return grid" ] }, { "cell_type": "code", "execution_count": null, "id": "b085fbe3-88ba-4f4a-aabb-3320c43652da", "metadata": { "tags": [] }, "outputs": [], "source": [ "actual_img = [Image.open(\"EuroSAT/Highway/Highway_{}.jpg\".format(str(i))) for i in range(1,11)]\n", "image_grid([x.resize((64,64)) for x in actual_img], 2,5)" ] }, { "cell_type": "markdown", "id": "a0ff4ff5-04a8-4e2f-b0ec-58457e20b2e0", "metadata": {}, "source": [ "Let's view the `Forest` and `Industrial` classes:" ] }, { "cell_type": "code", "execution_count": null, "id": "ca1d3080-52e0-47f5-9f7b-37c76f7821d2", "metadata": { "tags": [] }, "outputs": [], "source": [ "actual_img = [Image.open(\"base/EuroSAT/Forest/Forest_{}.jpg\".format(str(i))) for i in range(1,11)]\n", "image_grid([x.resize((64,64)) for x in actual_img], 2,5)" ] }, { "cell_type": "code", "execution_count": null, "id": "e340ad6c-d353-4eb9-a79a-05222ff9a7d6", "metadata": { "tags": [] }, "outputs": [], "source": [ "actual_img = [Image.open(\"base/EuroSAT/Industrial/Industrial_{}.jpg\".format(str(i))) for i in range(1,11)]\n", "image_grid([x.resize((64,64)) for x in actual_img], 2,5)" ] }, { "cell_type": "code", "execution_count": null, "id": "9cb1feba-2040-40e7-85ec-08bf73877b07", "metadata": { "tags": [] }, "outputs": [], "source": [ "import shutil, os\n", "forest_files = os.listdir(\"base/EuroSAT/Forest\")\n", "industrial_files = os.listdir(\"base/EuroSAT/Industrial\")" ] }, { "cell_type": "code", "execution_count": null, "id": "7311f47c-ef6d-4e22-aa9b-5766913656b6", "metadata": { "tags": [] }, "outputs": [], "source": [ "!mkdir -p \"base/class\"" ] }, { "cell_type": "markdown", "id": "4973a424-972c-4624-9661-c9999aa57f93", "metadata": {}, "source": [ "Some preparatory stuff. Copy the files to a location that we can use during fine-tuning" ] }, { "cell_type": "code", "execution_count": null, "id": "a945bab7-4ac1-40a4-b129-effa41a2f5cf", "metadata": { "tags": [] }, "outputs": [], "source": [ "for filename in forest_files:\n", " shutil.copyfile(\n", " os.path.join(\"base/EuroSAT/Forest\",filename),\n", " os.path.join(\"base/class\",filename)\n", " )\n", "for filename in industrial_files:\n", " shutil.copyfile(\n", " os.path.join(\"base/EuroSAT/Industrial\",filename),\n", " os.path.join(\"base/class\",filename)\n", " )" ] }, { "cell_type": "markdown", "id": "9b2444ac-0b4d-412a-8bd5-8d84990fe387", "metadata": {}, "source": [ "## Images generated by Stable Diffusion\n", "Before we start fine-tuning, lets have a look at the default images generated by Stable Diffusion. We use Stable Diffusion (1.5) to generate satellite images of the `Highway` class. \n", "\n", "We leverate the [Diffusers](https://huggingface.co/docs/diffusers/index) library from Huggingface for the generation." ] }, { "cell_type": "code", "execution_count": null, "id": "0185fc1e-d9ef-4f89-8b1a-81e32dfdfae5", "metadata": { "tags": [] }, "outputs": [], "source": [ "from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler\n", "import torch\n", "\n", "pipe = DiffusionPipeline.from_pretrained(\"runwayml/stable-diffusion-v1-5\", torch_dtype=torch.float16)\n", "pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)\n", "pipe.to(\"cuda\")" ] }, { "cell_type": "code", "execution_count": null, "id": "821c4a04-ce95-48d5-9574-b62e554d7e83", "metadata": { "tags": [] }, "outputs": [], "source": [ "img_list = pipe([\"Sentinel 2 satellite image of a highway\"]*10, num_inference_steps=25).images" ] }, { "cell_type": "code", "execution_count": null, "id": "d49030dd-0e6a-4ef4-8974-8c4fa8ad482f", "metadata": { "tags": [] }, "outputs": [], "source": [ "image_grid([x.resize((64,64)) for x in img_list], 2,5)" ] }, { "cell_type": "code", "execution_count": null, "id": "f6de68c5-8e21-4430-bea3-51ac5c52b16e", "metadata": { "tags": [] }, "outputs": [], "source": [ "import gc\n", "from numba import cuda\n", "del(pipe)\n", "gc.collect()\n", "torch.cuda.empty_cache()\n", "\n", "# device = cuda.get_current_device()\n", "# device.reset()" ] }, { "cell_type": "markdown", "id": "e4d83fb5-d4c7-4c9e-af27-c2968d50837f", "metadata": {}, "source": [ "## Actual highway class images from EuroSAT " ] }, { "cell_type": "code", "execution_count": null, "id": "54d5dcb4-8a11-49a9-b0a6-196deba72546", "metadata": { "tags": [] }, "outputs": [], "source": [ "actual_img = [Image.open(\"EuroSAT/Highway/Highway_{}.jpg\".format(str(i))) for i in range(1,11)]\n", "image_grid([x.resize((64,64)) for x in actual_img], 2,5)" ] }, { "cell_type": "markdown", "id": "9f1e27fb-949e-4160-abd2-bcf717fc195a", "metadata": {}, "source": [ "We see that in terms of color and style there is a significant difference between Stable Diffusion direct generated images and the actual EuroSAT dataset images" ] }, { "cell_type": "markdown", "id": "afef0121-c634-4bc5-a701-8413000cdad1", "metadata": {}, "source": [ "## Fine-tune Stable Diffusion with LORA and DreamBooth\n", "We want to fine-tune our text-to-image model to learn how to generate the right type of satellite images. To do so, we utilize two recent innovations, Dreambooth and LoRA. Dreambooth is a new method to allow models to learn to generate images that fit the distinct characteristics of the `instance` relative to the larger `class`. Low rank adapters (LoRA) allows for fast model training by drastically reducing the number of training parameters. We utilize the scripts found [here](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README.md).\n", "\n", "To enable Stable Diffusion to learn a new `instance`, we use a unique (and short) token/word to represent the new `instance`. In our case, we use the token/word `sks` that is commonly used, and is not close in terms of character sequence to other meaningful words. `sks` is commonly used in many tutorials for Stable Diffusion fine-tuning." ] }, { "cell_type": "markdown", "id": "1ae36427-0940-4d09-9f93-46bb8842bf31", "metadata": {}, "source": [ "We first install diffusers library" ] }, { "cell_type": "code", "execution_count": null, "id": "d960e0ab-58b1-441a-b5d0-9cfa33c44831", "metadata": { "tags": [] }, "outputs": [], "source": [ "!wget https://raw.githubusercontent.com/huggingface/diffusers/main/examples/dreambooth/train_dreambooth_lora.py" ] }, { "cell_type": "markdown", "id": "e564bdc9-37ef-4746-8f04-15070d59f065", "metadata": {}, "source": [ "Next, we run the fine-tuning code. This runs fine-tuning locally within the instance of the notebook. The [accelerate](https://github.com/huggingface/accelerate) library makes running the PyTorch code on multi-GPU easy." ] }, { "cell_type": "code", "execution_count": null, "id": "df282d95-d718-45db-8df2-96d0e2c6d041", "metadata": { "tags": [] }, "outputs": [], "source": [ "!accelerate launch train_dreambooth_lora.py \\\n", " --pretrained_model_name_or_path=\"runwayml/stable-diffusion-v1-5\" \\\n", " --instance_data_dir=\"EuroSAT/Highway\" \\\n", " --output_dir=trained_model \\\n", " --instance_prompt=\"Sentinel 2 satellite image of sks\" \\\n", " --resolution=256 \\\n", " --train_batch_size=1 \\\n", " --gradient_accumulation_steps=1 \\\n", " --checkpointing_steps=100 \\\n", " --learning_rate=1e-4 \\\n", " --report_to=\"tensorboard\" \\\n", " --lr_scheduler=\"constant\" \\\n", " --lr_warmup_steps=0 \\\n", " --with_prior_preservation \\\n", " --class_data_dir=\"base/class\" \\\n", " --class_prompt=\"Sentinel 2 satellite image\" \\\n", " --max_train_steps=800 \\\n", " --seed=\"0\" " ] }, { "cell_type": "markdown", "id": "5bafac84-7fd9-4ada-8e43-44fc6606e929", "metadata": {}, "source": [ "## Visualizing results\n", "Now that the model is trained, let's compare:\n", "1. Stable Diffusion generated images without fine-tuning\n", "2. Stable Diffusion generated images with LoRA and Dreambooth fine-tuning\n", "3. Original EuroSAT images" ] }, { "cell_type": "code", "execution_count": null, "id": "5e0a2265-7e5d-4327-851a-72ff7bc9a9af", "metadata": { "tags": [] }, "outputs": [], "source": [ "from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler\n", "import torch" ] }, { "cell_type": "markdown", "id": "92b924a2-c281-4a6b-bd42-89d47f811229", "metadata": {}, "source": [ "Lets look at the images generated without fine-tuning" ] }, { "cell_type": "code", "execution_count": null, "id": "ab11c7cb-569f-45cd-ac91-246815ced63d", "metadata": { "tags": [] }, "outputs": [], "source": [ "pipe = DiffusionPipeline.from_pretrained(\"runwayml/stable-diffusion-v1-5\", torch_dtype=torch.float16)\n", "pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)\n", "pipe.to(\"cuda\")" ] }, { "cell_type": "code", "execution_count": null, "id": "943c0671-e281-4e52-9fc2-6e62cecb9ecc", "metadata": { "tags": [] }, "outputs": [], "source": [ "img_list = pipe([\"Sentinel 2 satellite image of a highway\"]*3, num_inference_steps=25).images\n", "image_grid([x.resize((128,128)) for x in img_list], 1,3)" ] }, { "cell_type": "markdown", "id": "c3d5c363-ea06-4a82-813d-f3c3b320de32", "metadata": { "tags": [] }, "source": [ "Next, we look at the images created after fine-tuning" ] }, { "cell_type": "code", "execution_count": null, "id": "4ff8acdb-795e-4382-ab07-1212514a1c7b", "metadata": { "tags": [] }, "outputs": [], "source": [ "pipe.unet.load_attn_procs(\"./trained_model/checkpoint-800\")" ] }, { "cell_type": "code", "execution_count": null, "id": "f4f0ad76-803d-461a-a4da-d4b036254be0", "metadata": { "tags": [] }, "outputs": [], "source": [ "img_list = pipe([\"Sentinel 2 satellite image of sks\"]*3, num_inference_steps=25).images" ] }, { "cell_type": "code", "execution_count": null, "id": "e30faa87-332d-43bb-b8eb-634e3bf601e7", "metadata": { "tags": [] }, "outputs": [], "source": [ "image_grid([x.resize((128,128)) for x in img_list], 1,3)" ] }, { "cell_type": "markdown", "id": "f1ec34df-6981-4d1f-9c0d-11f872e2105a", "metadata": {}, "source": [ "And eventually we look at the original images" ] }, { "cell_type": "code", "execution_count": null, "id": "80530dff-6962-4c44-ac80-c688ad54287b", "metadata": { "tags": [] }, "outputs": [], "source": [ "from PIL.ImageOps import exif_transpose\n", "actual_img = [exif_transpose(Image.open(\"EuroSAT/Highway/Highway_{}.jpg\".format(str(i)))) for i in range(1,4)]\n", "image_grid([x.resize((128,128)) for x in actual_img], 1,3)" ] }, { "cell_type": "markdown", "id": "1e04de58-0560-492d-bdd2-bb1125e1886e", "metadata": {}, "source": [ "That's it! This finishes the notebook. In this notebook, we have seen how fine-tuning stable diffusion with custom images increases the quality of generated images. " ] }, { "cell_type": "markdown", "id": "04a3df92-962a-4b9e-b9ac-f18bccfa9585", "metadata": {}, "source": [ "## Cleanup\n", "After you close the notebook, please ensure that you close the instance as well using the icon (black square within white circle) on the left." ] }, { "cell_type": "code", "execution_count": null, "id": "4870f942-2fc2-4fe8-b9d8-3c247b8ac54e", "metadata": {}, "outputs": [], "source": [] } ], "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.g4dn.xlarge", "kernelspec": { "display_name": "Python 3 (PyTorch 2.0.0 Python 3.10 GPU Optimized)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/pytorch-2.0.0-gpu-py310" }, "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": 5 }