{ "cells": [ { "cell_type": "markdown", "id": "ed96eca6", "metadata": {}, "source": [ "# Compile and Train the GPT2 Model using the Transformers Trainer API with the wikitext Dataset for Multi-Node Multi-GPU Training" ] }, { "cell_type": "markdown", "id": "0050059a", "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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.ipynb)\n", "\n", "---" ] }, { "cell_type": "markdown", "id": "b6609fd7", "metadata": {}, "source": [ "1. [Introduction](#Introduction) \n", "2. [Development Environment](#Development-Environment)\n", " 1. [Installation](#Installation) \n", " 2. [SageMaker Environment](#SageMaker-Environment)\n", "3. [SageMaker Training Job](#SageMaker-Training-Job) \n", " 1. [Training with Native PyTorch + SM DDP](#Training-with-Native-PyTorch-+-SM-DDP) \n", " 2. [Training with SageMaker Training Compiler](#Training-with-SageMaker-Training-Compiler) \n", "4. [Analysis](#Analysis) " ] }, { "cell_type": "markdown", "id": "b84b38bf", "metadata": {}, "source": [ "## SageMaker Training Compiler Overview\n", "\n", "SageMaker Training Compiler is a capability of SageMaker that makes these hard-to-implement optimizations to reduce training time on GPU instances. The compiler optimizes DL models to accelerate training by more efficiently using SageMaker machine learning (ML) GPU instances. SageMaker Training Compiler is available at no additional charge within SageMaker and can help reduce total billable time as it accelerates training. \n", "\n", "SageMaker Training Compiler is integrated into the AWS Deep Learning Containers (DLCs). Using the SageMaker Training Compiler enabled AWS DLCs, you can compile and optimize training jobs on GPU instances with minimal changes to your code. Bring your deep learning models to SageMaker and enable SageMaker Training Compiler to accelerate the speed of your training job on SageMaker ML instances for accelerated computing. \n", "\n", "For more information, see [SageMaker Training Compiler](https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler.html) in the *Amazon SageMaker Developer Guide*.\n", "\n", "## Introduction\n", "\n", "In this demo, you'll use Hugging Face's transformers and datasets libraries with Amazon SageMaker Training Compiler to train the gpt-2 model on the wikitext dataset. Please note that by using this notebook you will be downloading wikitext from https://huggingface.co/datasets/wikitext and can check dataset information and terms there. To get started, we need to set up the environment with a few prerequisite steps, for permissions, configurations, and so on. \n", "\n", "**NOTE:** You can run this demo in SageMaker Studio, SageMaker notebook instances, or your local machine with AWS CLI set up. If using SageMaker Studio or SageMaker notebook instances, make sure you choose one of the PyTorch-based kernels, Python 3 (PyTorch x.y Python 3.x CPU Optimized) or conda_pytorch_p36 respectively.\n", "\n", "**NOTE:** This notebook uses four ml.p4d.24xlarge instances that have multiple GPUs. If you don't have enough quota, see [Request a service quota increase for SageMaker resources](https://docs.aws.amazon.com/sagemaker/latest/dg/regions-quotas.html#service-limit-increase-request-procedure). " ] }, { "cell_type": "markdown", "id": "c435eb27", "metadata": {}, "source": [ "## Development Environment " ] }, { "cell_type": "markdown", "id": "8d0517a0", "metadata": {}, "source": [ "### Installation" ] }, { "cell_type": "markdown", "id": "038a0306", "metadata": {}, "source": [ "This example notebook requires the **SageMaker Python SDK v2.133.0**." ] }, { "cell_type": "code", "execution_count": null, "id": "e87a5fdc", "metadata": {}, "outputs": [], "source": [ "!pip install \"sagemaker>=2.133.0\" botocore boto3 awscli typing-extensions pandas numpy --upgrade" ] }, { "cell_type": "code", "execution_count": null, "id": "e425a0a8", "metadata": {}, "outputs": [], "source": [ "import botocore\n", "import boto3\n", "import sagemaker\n", "import transformers\n", "import pandas as pd\n", "\n", "print(f\"sagemaker: {sagemaker.__version__}\")\n", "print(f\"transformers: {transformers.__version__}\")" ] }, { "cell_type": "markdown", "id": "95985fbe", "metadata": {}, "source": [ "**NOTE:** Copy and run the following code if you need to upgrade ipywidgets for datasets library and restart the kernel. This is needed if the installation is not applied to the current kernel.\n", "\n", "```python\n", "%%capture\n", "import IPython\n", "!conda install -c conda-forge ipywidgets -y\n", "# has to restart kernel for the updates to be applied\n", "IPython.Application.instance().kernel.do_shutdown(True) \n", "```" ] }, { "cell_type": "markdown", "id": "c7614da0", "metadata": {}, "source": [ "### SageMaker Environment " ] }, { "cell_type": "code", "execution_count": null, "id": "3d5b14e7", "metadata": {}, "outputs": [], "source": [ "import sagemaker\n", "\n", "sess = sagemaker.Session()\n", "\n", "# sagemaker session bucket -> used for uploading data, models and logs\n", "# sagemaker will automatically create this bucket if it not exists\n", "sagemaker_session_bucket = None\n", "if sagemaker_session_bucket is None and sess is not None:\n", " # set to default bucket if a bucket name is not given\n", " sagemaker_session_bucket = sess.default_bucket()\n", "\n", "role = sagemaker.get_execution_role()\n", "sess = sagemaker.Session(default_bucket=sagemaker_session_bucket)\n", "\n", "print(f\"sagemaker role arn: {role}\")\n", "print(f\"sagemaker bucket: {sess.default_bucket()}\")\n", "print(f\"sagemaker session region: {sess.boto_region_name}\")" ] }, { "cell_type": "markdown", "id": "98266e17", "metadata": {}, "source": [ "## SageMaker Training Job\n", "\n", "To create a SageMaker training job, we use a PyTorch estimator. Using the estimator, you can define which training script should SageMaker use through entry_point, which instance_type to use for training, which hyperparameters to pass, and so on.\n", "\n", "When a SageMaker training job starts, SageMaker takes care of starting and managing all the required machine learning instances, picks up the Deep Learning Container, uploads your training script, and downloads the data from sagemaker_session_bucket into the container at /opt/ml/input/data." ] }, { "cell_type": "code", "execution_count": null, "id": "30fd4078", "metadata": {}, "outputs": [], "source": [ "# Here we configure the training job. Please configure the appropriate options below:\n", "\n", "EPOCHS = 6\n", "\n", "# Choose between Causal Language Model and Masked Language Model\n", "LANGUAGE_MODELING_LOSS = \"clm\" # or \"mlm\"\n", "SEQ_LEN_ARG = \"block_size\" if LANGUAGE_MODELING_LOSS == \"clm\" else \"max_seq_length\"\n", "\n", "MODEL_NAME = \"gpt2\"\n", "TOKENIZER_NAME = \"gpt2\"\n", "\n", "MODEL_CONFIG = \"model_type\"\n", "\n", "# For more information about the options, please look into the training scripts\n", "\n", "# Select Instance type for training\n", "INSTANCE_TYPE = \"ml.p4d.24xlarge\"\n", "NUM_INSTANCES = 2\n", "# Since ml.p4d.24xlarge instance has 8 GPUs, we set num_gpus_per_instance to 8\n", "num_gpus_per_instance = 8" ] }, { "cell_type": "markdown", "id": "eff7eee1", "metadata": {}, "source": [ "First, we define some basic parameters common to all estimators.\n", "\n", "**Note**: We recommend you to turn the SageMaker Debugger's profiling and debugging tools off to avoid additional overheads." ] }, { "cell_type": "code", "execution_count": null, "id": "918895a5", "metadata": {}, "outputs": [], "source": [ "estimator_args = dict(\n", " entry_point=f\"run_{LANGUAGE_MODELING_LOSS}.py\",\n", " source_dir=\"./scripts\",\n", " instance_type=INSTANCE_TYPE,\n", " instance_count=NUM_INSTANCES,\n", " role=role,\n", " py_version=\"py39\",\n", " framework_version=\"1.13.1\",\n", " volume_size=512,\n", " disable_profiler=True, # Disabling SageMaker Profiler to avoid overheads during benchmarking\n", " debugger_hook_config=False, # Disabling SageMaker Debugger to avoid overheads during benchmarking\n", " base_job_name=\"trcomp-pt-example\",\n", " metric_definitions=[\n", " {\"Name\": \"summary_train_runtime\", \"Regex\": \"'train_runtime': ([0-9.]*)\"},\n", " {\n", " \"Name\": \"summary_train_samples_per_second\",\n", " \"Regex\": \"'train_samples_per_second': ([0-9.]*)\",\n", " },\n", " {\"Name\": \"summary_train_steps_per_second\", \"Regex\": \"'train_steps_per_second': ([0-9.]*)\"},\n", " {\"Name\": \"summary_train_loss\", \"Regex\": \"'train_loss': ([0-9.]*)\"},\n", " {\"Name\": \"epoch\", \"Regex\": \"'epoch': ([0-9.]*)\"},\n", " {\"Name\": \"train_loss\", \"Regex\": \"'loss': ([0-9.]*)\"},\n", " {\"Name\": \"learning_rate\", \"Regex\": \"'learning_rate': ([0-9.]*)\"},\n", " ],\n", ")" ] }, { "cell_type": "markdown", "id": "89f5ea5c", "metadata": {}, "source": [ "Next, we define some basic arguments to be passed to the training script." ] }, { "cell_type": "code", "execution_count": null, "id": "7830af96", "metadata": {}, "outputs": [], "source": [ "# hyperparameters are passed to the training entrypoint as arguments\n", "hyperparameters = {\n", " MODEL_CONFIG: MODEL_NAME,\n", " \"tokenizer_name\": TOKENIZER_NAME,\n", " \"dataset_name\": \"wikitext\",\n", " \"dataset_config_name\": \"wikitext-103-v1\",\n", " \"do_train\": True,\n", " \"do_eval\": False,\n", " \"num_train_epochs\": EPOCHS,\n", " SEQ_LEN_ARG: 512,\n", " \"overwrite_output_dir\": True,\n", " \"save_strategy\": \"no\",\n", " \"evaluation_strategy\": \"no\",\n", " \"logging_strategy\": \"epoch\",\n", " \"output_dir\": \"/opt/ml/model\",\n", " \"dataloader_drop_last\": True,\n", " \"preprocessing_num_workers\": 12,\n", "}" ] }, { "cell_type": "markdown", "id": "aa5e0832", "metadata": {}, "source": [ "In the following sections, we will create estimators and start training." ] }, { "cell_type": "markdown", "id": "d12581dc", "metadata": {}, "source": [ "### Training with Native PyTorch + SM DDP" ] }, { "cell_type": "markdown", "id": "9271aa50", "metadata": {}, "source": [ "The batch size below is the maximum batch we could fit into the memory of a ml.p4d.24xlarge instance. If you change the model, instance type, sequence length, and other parameters, you need to do some experiments to find the largest batch size that will fit into GPU memory.\n", "\n", "This example uses HuggingFace training script run_clm.py, which you can find it inside the scripts folder." ] }, { "cell_type": "code", "execution_count": null, "id": "59639c8f", "metadata": {}, "outputs": [], "source": [ "from sagemaker.pytorch import PyTorch\n", "\n", "hyperparameters[\"per_device_train_batch_size\"] = 28\n", "\n", "# The original LR was set for a batch of 32. Here we are scaling learning rate with batch size.\n", "hyperparameters[\"learning_rate\"] = (\n", " float(\"5e-5\") / 32 * hyperparameters[\"per_device_train_batch_size\"]\n", ")\n", "\n", "# configure the training job\n", "native_estimator = PyTorch(\n", " **estimator_args,\n", " hyperparameters=hyperparameters,\n", " distribution={\n", " \"smdistributed\": {\"dataparallel\": {\"enabled\": True}}\n", " }, # Use SageMaker Distributed Data Parallel to train across nodes/GPUs.\n", ")\n", "\n", "# Start the training job\n", "native_estimator.fit(wait=False)\n", "native_estimator.latest_training_job.name" ] }, { "cell_type": "markdown", "id": "e797c1c4", "metadata": {}, "source": [ "### Training with SageMaker Training Compiler " ] }, { "cell_type": "markdown", "id": "5e0eb9e7", "metadata": {}, "source": [ "Compilation through Training Compiler changes the memory footprint of the model. Most commonly, this manifests as a reduction in memory utilization and a consequent increase in the largest batch size that can fit on the GPU. Note that if you want to change the batch size, you must adjust the learning rate appropriately.\n", "Below, we have scaled the learning rate linearly with the increase in batch size.\n", "\n", "**Note**: We are using distribution mechanism pytorchxla which is a compiler aware method of distributed training." ] }, { "cell_type": "code", "execution_count": null, "id": "6b690fb7", "metadata": {}, "outputs": [], "source": [ "from sagemaker.pytorch import PyTorch, TrainingCompilerConfig\n", "\n", "# with SageMaker Training Compiler we are able to fit a larger batch into memory\n", "hyperparameters[\"per_device_train_batch_size\"] = 42\n", "\n", "# The original LR was set for a batch of 32. Here we are scaling learning rate with batch size.\n", "hyperparameters[\"learning_rate\"] = (\n", " float(\"5e-5\") / 32 * hyperparameters[\"per_device_train_batch_size\"]\n", ")\n", "\n", "# configure the training job\n", "optimized_estimator = PyTorch(\n", " compiler_config=TrainingCompilerConfig(),\n", " hyperparameters=hyperparameters,\n", " distribution={\"pytorchxla\": {\"enabled\": True}},\n", " **estimator_args,\n", ")\n", "\n", "# start the training job\n", "optimized_estimator.fit(wait=False)\n", "optimized_estimator.latest_training_job.name" ] }, { "cell_type": "markdown", "id": "6cea9f88", "metadata": {}, "source": [ "### Wait for training jobs to complete\n" ] }, { "cell_type": "code", "execution_count": null, "id": "17ad5549", "metadata": {}, "outputs": [], "source": [ "waiter = native_estimator.sagemaker_session.sagemaker_client.get_waiter(\n", " \"training_job_completed_or_stopped\"\n", ")\n", "waiter.wait(TrainingJobName=native_estimator.latest_training_job.name)\n", "waiter = optimized_estimator.sagemaker_session.sagemaker_client.get_waiter(\n", " \"training_job_completed_or_stopped\"\n", ")\n", "waiter.wait(TrainingJobName=optimized_estimator.latest_training_job.name)" ] }, { "cell_type": "markdown", "id": "578a6944", "metadata": {}, "source": [ "## Analysis" ] }, { "cell_type": "markdown", "id": "41f53d61", "metadata": {}, "source": [ "**Note:** If the estimator object is no longer available due to a kernel break or refresh, you need to directly use the training job name and manually attach the training job to a new PyTorch estimator. For example:\n", "\n", "```python\n", "estimator = PyTorch.attach(\"your_pytorch_training_job_name\")\n", "```" ] }, { "cell_type": "markdown", "id": "51d8e3ee", "metadata": {}, "source": [ "### Load logs of the training job *with* SageMaker Training Compiler" ] }, { "cell_type": "code", "execution_count": null, "id": "31da42e2", "metadata": {}, "outputs": [], "source": [ "%%capture optimized\n", "\n", "# access the logs of the optimized training job\n", "optimized_estimator.sagemaker_session.logs_for_job(optimized_estimator.latest_training_job.name)" ] }, { "cell_type": "markdown", "id": "a5d7d223", "metadata": {}, "source": [ "### Load logs of the training job *without* SageMaker Training Compiler" ] }, { "cell_type": "code", "execution_count": null, "id": "21abd12f", "metadata": {}, "outputs": [], "source": [ "%%capture native\n", "\n", "# access the logs of the native training job\n", "native_estimator.sagemaker_session.logs_for_job(native_estimator.latest_training_job.name)" ] }, { "cell_type": "markdown", "id": "6994a0ef", "metadata": {}, "source": [ "### Create helper functions for analysis" ] }, { "cell_type": "code", "execution_count": null, "id": "fd816f05", "metadata": {}, "outputs": [], "source": [ "from ast import literal_eval\n", "from collections import defaultdict\n", "from matplotlib import pyplot as plt\n", "\n", "\n", "def _summarize(captured):\n", " final = []\n", " for line in captured.stdout.split(\"\\n\"):\n", " cleaned = line.strip()\n", " if \"{\" in cleaned and \"}\" in cleaned:\n", " final.append(cleaned[cleaned.index(\"{\") : cleaned.index(\"}\") + 1])\n", " return final\n", "\n", "\n", "def make_sense(string):\n", " try:\n", " return literal_eval(string)\n", " except:\n", " pass\n", "\n", "\n", "def summarize(summary):\n", " final = {\"train\": [], \"eval\": [], \"summary\": {}}\n", " for line in summary:\n", " interpretation = make_sense(line.replace(\"nan\", \"'nan'\"))\n", " if interpretation:\n", " if \"loss\" in interpretation:\n", " final[\"train\"].append(interpretation)\n", " elif \"eval_loss\" in interpretation:\n", " final[\"eval\"].append(interpretation)\n", " elif \"train_runtime\" in interpretation:\n", " final[\"summary\"].update(interpretation)\n", " return final" ] }, { "cell_type": "markdown", "id": "4c6b90eb", "metadata": {}, "source": [ "### Plot Optimized vs Native Training Throughput\n", "\n", "Visualize average throughputs as reported by HuggingFace and see potential savings.\n" ] }, { "cell_type": "code", "execution_count": null, "id": "0a6f87cd", "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Average throughput for the native PyTorch training as reported by Trainer\n", "n = summarize(_summarize(native))\n", "native_throughput = n[\"summary\"][\"train_samples_per_second\"]\n", "\n", "# Average throughput for the optimized PyTorch training as reported by Trainer\n", "o = summarize(_summarize(optimized))\n", "optimized_throughput = o[\"summary\"][\"train_samples_per_second\"]\n", "\n", "# Calculate percentage speedup of optimized PyTorch over native PyTorch\n", "avg_speedup = f\"{round((optimized_throughput/native_throughput-1)*100)}%\"" ] }, { "cell_type": "code", "execution_count": null, "id": "dd04b654", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "plt.title(\"Training Throughput \\n (Higher is better)\")\n", "plt.ylabel(\"Samples/sec\")\n", "\n", "plt.bar(x=[1], height=native_throughput, label=\"PT + SM DDP\", width=0.35)\n", "plt.bar(x=[1.5], height=optimized_throughput, label=\"PT + Compiler\", width=0.35)\n", "\n", "plt.xlabel(\" ====> {} Compiler savings <====\".format(avg_speedup))\n", "plt.xticks(ticks=[1, 1.5], labels=[\"PT + SM DDP\", \"PT + Compiler\"])" ] }, { "cell_type": "markdown", "id": "b1160c05", "metadata": {}, "source": [ "### Convergence of Training Loss\n", "\n", "SageMaker Training Compiler does not affect the model convergence behavior. Here, we see the decrease in training loss is similar with and without SageMaker Training Compiler\n" ] }, { "cell_type": "code", "execution_count": null, "id": "2ae789e1", "metadata": {}, "outputs": [], "source": [ "vanilla_loss = [i[\"loss\"] for i in n[\"train\"]]\n", "vanilla_epochs = [i[\"epoch\"] for i in n[\"train\"]]\n", "optimized_loss = [i[\"loss\"] for i in o[\"train\"]]\n", "optimized_epochs = [i[\"epoch\"] for i in o[\"train\"]]\n", "\n", "plt.title(\"Plot of Training Loss\")\n", "plt.xlabel(\"Epoch\")\n", "plt.ylabel(\"Training Loss\")\n", "plt.plot(vanilla_epochs, vanilla_loss, label=\"PT + SM DDP\")\n", "plt.plot(optimized_epochs, optimized_loss, label=\"PT + Compiler\")\n", "plt.legend()" ] }, { "cell_type": "markdown", "id": "410b0eaf", "metadata": {}, "source": [ "### Training Stats\n", "\n", "Let's compare various training metrics with and without SageMaker Training Compiler. SageMaker Training Compiler provides an increase in training throughput which translates to a decrease in total training time.\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "9e3b710e", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "\n", "pd.DataFrame([n[\"summary\"], o[\"summary\"]], index=[\"PT + SM DDP\", \"PT + Compiler\"])" ] }, { "cell_type": "code", "execution_count": null, "id": "9aa33805", "metadata": {}, "outputs": [], "source": [ "speedup = (\n", " (n[\"summary\"][\"train_runtime\"] - o[\"summary\"][\"train_runtime\"])\n", " * 100\n", " / n[\"summary\"][\"train_runtime\"]\n", ")\n", "print(\n", " f\"SageMaker Training Compiler is about {int(speedup)}% faster in terms of total training time.\"\n", ")" ] }, { "cell_type": "markdown", "id": "26066cad", "metadata": {}, "source": [ "### Total Billable Time\n", "\n", "Finally, the decrease in total training time results in a decrease in the billable seconds from SageMaker." ] }, { "cell_type": "code", "execution_count": null, "id": "fcdcaabe", "metadata": {}, "outputs": [], "source": [ "def BillableTimeInSeconds(name):\n", " describe_training_job = (\n", " optimized_estimator.sagemaker_session.sagemaker_client.describe_training_job\n", " )\n", " details = describe_training_job(TrainingJobName=name)\n", " return details[\"BillableTimeInSeconds\"]" ] }, { "cell_type": "code", "execution_count": null, "id": "9699111f", "metadata": {}, "outputs": [], "source": [ "Billable = {}\n", "Billable[\"PT + SM DDP\"] = BillableTimeInSeconds(native_estimator.latest_training_job.name)\n", "Billable[\"PT + Compiler\"] = BillableTimeInSeconds(optimized_estimator.latest_training_job.name)\n", "pd.DataFrame(Billable, index=[\"BillableSecs\"])" ] }, { "cell_type": "code", "execution_count": null, "id": "3f413f99", "metadata": {}, "outputs": [], "source": [ "speedup = (Billable[\"PT + SM DDP\"] - Billable[\"PT + Compiler\"]) * 100 / Billable[\"PT + SM DDP\"]\n", "print(f\"SageMaker Training Compiler integrated PyTorch was {int(speedup)}% faster in summary.\")" ] }, { "cell_type": "markdown", "id": "6e2d5421", "metadata": {}, "source": [ "## Clean up\n", "\n", "Stop all training jobs launched if the jobs are still running." ] }, { "cell_type": "code", "execution_count": null, "id": "2a41c792", "metadata": {}, "outputs": [], "source": [ "import boto3\n", "\n", "sm = boto3.client(\"sagemaker\")\n", "\n", "\n", "def stop_training_job(name):\n", " status = sm.describe_training_job(TrainingJobName=name)[\"TrainingJobStatus\"]\n", " if status == \"InProgress\":\n", " sm.stop_training_job(TrainingJobName=name)\n", "\n", "\n", "stop_training_job(native_estimator.latest_training_job.name)\n", "stop_training_job(optimized_estimator.latest_training_job.name)" ] }, { "cell_type": "markdown", "id": "f4219a83", "metadata": {}, "source": [ "Also, to find instructions on cleaning up resources, see [Clean Up](https://docs.aws.amazon.com/sagemaker/latest/dg/ex1-cleanup.html) in the *Amazon SageMaker Developer Guide*." ] }, { "cell_type": "markdown", "id": "6a8a4641", "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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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-training-compiler|huggingface|pytorch_multiple_gpu_multiple_node|language-modeling-multi-gpu-multi-node.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.13 Python 3.9 CPU Optimized)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-west-2:236514542706:image/pytorch-1.13-cpu-py39" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.16" }, "vscode": { "interpreter": { "hash": "11bd1a5e22b55030e7dafa6146ff58da0a8819c60346681265e3e4937faaddb3" } } }, "nbformat": 4, "nbformat_minor": 5 }