

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Amazon SageMaker AI 資料平行程式庫範例
<a name="distributed-data-parallel-v2-examples"></a>

此頁面提供 Jupyter 筆記本，其中提供實作 SageMaker AI 分散式資料平行化 (SMDDP) 程式庫以在 SageMaker AI 上執行分散式訓練任務的範例。

## 部落格與案例研究
<a name="distributed-data-parallel-v2-examples-blog"></a>

下列部落格討論有關使用 SMDDP 程式庫的案例研究。

**SMDDP v2 部落格**
+ [使用 Amazon SageMaker AI 資料平行程式庫進行更快速的訓練](https://aws.amazon.com/blogs/machine-learning/enable-faster-training-with-amazon-sagemaker-data-parallel-library/)，*AWS 機器學習部落格* (2023 年 12 月 5 日)

**SMDDP v1 部落格**
+ [我如何在 SageMaker AI 上訓練 Stable Diffusion 10TB](https://medium.com/@emilywebber/how-i-trained-10tb-for-stable-diffusion-on-sagemaker-39dcea49ce32)，*Medium* (2022 年 11 月 29 日)
+ [與 Amazon Search 在 Amazon SageMaker 訓練中執行 PyTorch Learning 和原生 PyTorch DDP](https://aws.amazon.com/blogs/machine-learning/run-pytorch-lightning-and-native-pytorch-ddp-on-amazon-sagemaker-training-featuring-amazon-search/)，*AWS 機器學習部落格* (2022 年 8 月 18 日)
+ [AWS 使用 PyTorch 和 SageMaker AI 分散式資料平行程式庫在 上訓練 YOLOv5](https://medium.com/@sitecao/training-yolov5-on-aws-with-pytorch-and-sagemaker-distributed-data-parallel-library-a196ab01409b)，*中* (2022 年 5 月 6 日）
+ [使用 PyTorch 和 SageMaker AI 分散式資料平行程式庫，加速 SageMaker AI 上的 EfficientNet 模型訓練](https://medium.com/@dangmz/speed-up-efficientnet-model-training-on-amazon-sagemaker-with-pytorch-and-sagemaker-distributed-dae4b048c01a)，*Medium* (2022 年 3 月 21 日)
+ [AWS 使用 SageMaker AI 分散式資料平行程式庫加速 上的 EfficientNet 訓練](https://towardsdatascience.com/speed-up-efficientnet-training-on-aws-by-up-to-30-with-sagemaker-distributed-data-parallel-library-2dbf6d1e18e8)，*面向資料科學* (2022 年 1 月 12 日）
+ [現代汽車使用 Amazon SageMaker AI 縮短自動駕駛模型的 ML 模型訓練時間](https://aws.amazon.com/blogs/machine-learning/hyundai-reduces-training-time-for-autonomous-driving-models-using-amazon-sagemaker/)，*AWS 機器學習部落格* (2021 年 6 月 25 日)
+ [分散式訓練：使用 Transformers 和 Amazon SageMaker AI 訓練 BART/T5 進行摘要](https://huggingface.co/blog/sagemaker-distributed-training-seq2seq)，*Hugging Face 網站* (2021 年 4 月 8 日)

## 範例筆記本
<a name="distributed-data-parallel-v2-examples-pytorch"></a>

範例筆記本在 [SageMaker AI 範例 GitHub 儲存庫](https://github.com/aws/amazon-sagemaker-examples/tree/master/training/distributed_training/)中提供。若要下載範例，請執行下列命令來複製儲存庫並前往 `training/distributed_training/pytorch/data_parallel`。

**注意**  
在下列 SageMaker AI ML IDEs 中複製並執行範例筆記本。  
[SageMaker AI JupyterLab](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-jl.html) (可在 2023 年 12 月之後建立的 [Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated.html) 中使用)
[SageMaker AI 程式碼編輯器](https://docs.aws.amazon.com/sagemaker/latest/dg/code-editor.html) (可在 2023 年 12 月之後建立的 [Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated.html) 中使用)
[Studio Classic](https://docs.aws.amazon.com/sagemaker/latest/dg/studio.html) (作為在 2023 年 12 月之後建立的 [Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated.html) 中的應用程式提供)
[SageMaker 筆記本執行個體](https://docs.aws.amazon.com/sagemaker/latest/dg/nbi.html)

```
git clone https://github.com/aws/amazon-sagemaker-examples.git
cd amazon-sagemaker-examples/training/distributed_training/pytorch/data_parallel
```

**SMDDP v2 範例**
+ [使用 SageMaker AI 分散式資料平行程式庫 (SMDDP) 和 DeepSpeed 訓練 Llama 2](https://github.com/aws/amazon-sagemaker-examples/blob/main/training/distributed_training/pytorch/data_parallel/deepspeed/llama2/smddp_deepspeed_example.ipynb)
+ [使用 SageMaker AI 分散式資料平行程式庫 (SMDDP) 和 PyTorch 完全碎片資料平行化 (FSDP) 來訓練 Falcon](https://github.com/aws/amazon-sagemaker-examples/blob/main/training/distributed_training/pytorch/data_parallel/fully_sharded_data_parallel/falcon/smddp_fsdp_example.ipynb)

**SMDDP v1 範例**
+ [使用 PyTorch 的 CNN 與 SageMaker AI 資料平行化程式庫](https://github.com/aws/amazon-sagemaker-examples/blob/main/training/distributed_training/pytorch/data_parallel/mnist/pytorch_smdataparallel_mnist_demo.ipynb)
+ [使用 PyTorch 的 BERT 與 SageMaker AI 資料平行化程式庫](https://github.com/aws/amazon-sagemaker-examples/blob/main/training/distributed_training/pytorch/data_parallel/bert/pytorch_smdataparallel_bert_demo.ipynb)
+ [使用 TensorFlow 2.3.1 的 CNN 與 SageMaker AI 資料平行程式庫](https://sagemaker-examples.readthedocs.io/en/latest/training/distributed_training/tensorflow/data_parallel/mnist/tensorflow2_smdataparallel_mnist_demo.html)
+ [使用 TensorFlow 2.3.1 的 BERT 與 SageMaker AI 資料平行化程式庫](https://sagemaker-examples.readthedocs.io/en/latest/training/distributed_training/tensorflow/data_parallel/bert/tensorflow2_smdataparallel_bert_demo.html)
+ [在 SageMaker AI 上 PyTorch 中的 HuggingFace 分散式資料平行訓練：分散式問題回答](https://github.com/huggingface/notebooks/blob/master/sagemaker/03_distributed_training_data_parallelism/sagemaker-notebook.ipynb)
+ [在 SageMaker AI 上 PyTorch 中的 HuggingFace 分散式資料平行訓練：分散式文字摘要](https://github.com/huggingface/notebooks/blob/master/sagemaker/08_distributed_summarization_bart_t5/sagemaker-notebook.ipynb)
+ [在 SageMaker AI 上 TensorFlow 中 HuggingFace 分散式資料平行訓練](https://github.com/huggingface/notebooks/blob/master/sagemaker/07_tensorflow_distributed_training_data_parallelism/sagemaker-notebook.ipynb)