

# PERF02-BP06 使用最佳化的硬體型運算加速器
<a name="perf_compute_hardware_compute_accelerators"></a>

 使用硬體加速器執行特定功能，比以 CPU 為基礎的替代方案更有效率。

 **常見的反模式：**
+  在工作負載中，您尚未基準化分析一般用途執行個體和專用執行個體，而專用執行個體可以改善效能和降低成本。
+  您使用硬體型運算加速器來執行任務，比起使用以 CPU 為基礎的替代方案更有效率。
+  未監控 GPU 使用率。

**建立此最佳實務的優勢：**透過使用硬體型加速器，例如圖形處理單元 (GPU) 和現場可程式化閘道陣列 (FPGA)，您就可以更有效率地執行特定處理功能。

 **未建立此最佳實務時的曝險等級：**中 

## 實作指引
<a name="implementation-guidance"></a>

 加速運算執行個體可讓您存取硬體型運算加速器，例如 GPU 和 FPGA。這些硬體加速器比基於 CPU 的替代品更有效地執行某些功能，例如圖形處理或資料模式匹配。許多加速的工作負載 (例如轉譯、轉碼和機器學習) 在資源使用方面變化很大。只在需要時執行此硬體，並在不需要時自動停用它們，以提高整體效能的效率。

### 實作步驟
<a name="implementation-steps"></a>
+  確定哪些[加速運算執行個體](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/accelerated-computing-instances.html)可以滿足您的需求。
+  針對機器學習工作負載，請利用專供工作負載使用的專用硬體，例如 [AWS Trainium](https://aws.amazon.com/machine-learning/trainium/)、[AWS Inferentia](https://aws.amazon.com/machine-learning/inferentia/) 和 [Amazon EC2 DL1](https://aws.amazon.com/ec2/instance-types/dl1/)。AWS與同類 Amazon EC2 執行個體相比，Inferentia 執行個體 (例如 Inf2 執行個體) [所提供的效能功耗比要高出 50%](https://aws.amazon.com/machine-learning/inferentia/)。
+  收集加速運算執行個體的用量指標。例如，可以使用 CloudWatch 代理程式為您的 GPU 收集 `utilization_gpu` 和 `utilization_memory` 等指標，如[使用 Amazon CloudWatch 收集 NVIDIA GPU 指標](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-NVIDIA-GPU.html)中所示。
+  優化硬體加速器的程式碼、網路運作和設定，以確保系統會充分利用基礎硬體。
  +  [最佳化 GPU 設定](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/optimize_gpu.html) 
  +  [深度學習 AMI 中的 GPU 監控和最佳化](https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-gpu.html) 
  +  [將 I/O 最佳化以針對 Amazon SageMaker AI 中的深度學習訓練進行 GPU 效能調校](https://aws.amazon.com/blogs/machine-learning/optimizing-i-o-for-gpu-performance-tuning-of-deep-learning-training-in-amazon-sagemaker/) 
+  使用最新的高效能程式庫和 GPU 驅動程式。
+  使用自動化來釋出不使用的 GPU 執行個體。

## 資源
<a name="resources"></a>

 **相關文件：**
+  [在 Amazon Elastic Container Service 上使用 GPU](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-gpu.html) 
+  [GPU 執行個體](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/accelerated-computing-instances.html#gpu-instances) 
+  [AWS Trainium 的執行個體](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/accelerated-computing-instances.html#aws-trainium-instances) 
+  [AWS Inferentia 的執行個體](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/accelerated-computing-instances.html#aws-inferentia-instances) 
+  [開始建構吧！使用自訂晶片和加速器來進行建構](https://aws.amazon.com/blogs/architecture/lets-architect-custom-chips-and-accelerators/) 
+  [加速運算](https://aws.amazon.com/ec2/instance-types/#Accelerated_Computing) 
+  [Amazon EC2 VT1 執行個體](https://aws.amazon.com/ec2/instance-types/vt1/) 
+  [如何為工作負載選擇適當的 Amazon EC2 執行個體類型？](https://aws.amazon.com/premiumsupport/knowledge-center/ec2-instance-choose-type-for-workload/) 
+  [選擇最佳 AI 加速器和模型編譯來以 Amazon SageMaker AI 推斷電腦視覺](https://aws.amazon.com/blogs/machine-learning/choose-the-best-ai-accelerator-and-model-compilation-for-computer-vision-inference-with-amazon-sagemaker/) 

 **相關影片：**
+  AWS re:Invent 2021 - [如何選擇 Amazon Elastic Compute Cloud GPU 執行個體進行深度學習](https://www.youtube.com/watch?v=4bVrIbgGWEA&ab_channel=AWSEvents) 
+  [AWS re:Invent 2022 - [最新發佈！] 介紹基於 AWS Inferentia2 的 Amazon EC2 Inf2 執行個體](https://www.youtube.com/watch?v=jpqiG02Y2H4&ab_channel=AWSEvents) 
+  [AWS re:Invent 2022 - 使用 AWS Trainium 加速深度學習並加快創新速度](https://www.youtube.com/watch?v=YRqvfNwqUIA&ab_channel=AWSEvents) 
+  [AWS re:Invent 2022 - 透過 NVIDIA 在 AWS 上進行深度學習：從訓練到部署](https://www.youtube.com/watch?v=l8AFfaCkp0E&ab_channel=AWSEvents) 

 **相關範例：**
+  [Amazon SageMaker AI 和 NVIDIA GPU Cloud (NGC)](https://github.com/aws-samples/amazon-sagemaker-nvidia-ngc-examples) 
+  [搭配使用 SageMaker AI 與 Trainium 和 Inferentia，進行最佳化的深度學習訓練和推論工作負載](https://github.com/aws-samples/sagemaker-trainium-inferentia) 
+  [使用 Amazon SageMaker AI 中的 Amazon Elastic Compute Cloud Inf1 執行個體最佳化 NLP 模型](https://github.com/aws-samples/aws-inferentia-huggingface-workshop) 