

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

# 在無網際網路模式中執行的訓練和推論容器
<a name="mkt-algo-model-internet-free"></a>

SageMaker AI 訓練和部署的推論容器預設可以使用網際網路。這可讓容器存取公有網際網路的外部服務和資源，做為訓練和推論工作負載的一部分。不過，這就多提供了一個能未經授權存取您資料的管道。舉例而言，惡意使用者或是您不小心安裝在容器上的惡意程式碼 (以可公開取得的筆記本或原始碼程式庫的形式出現) 均能存取您的資料，並將其傳輸至遠端主機。

如果您在呼叫 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html)、[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateHyperParameterTuningJob.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateHyperParameterTuningJob.html) 或 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html) 時，透過指定 `VpcConfig` 參數的值來使用 Amazon VPC，您可以藉由管理安全群組並限制您的 VPC 的網際網路存取來保護資料和資源。不過，這會增加額外的網路組態，並存在錯誤設定網路的風險。如果您不想要 SageMaker AI 提供對訓練或推論容器的外部網路存取，您可以啟用網路隔離。

## 網路隔離
<a name="mkt-algo-model-internet-free-isolation"></a>

您可以在建立訓練工作或模型時啟用網路隔離，方法是將當您呼叫 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html)、[https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateHyperParameterTuningJob.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateHyperParameterTuningJob.html) 或 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateModel.html) 時，將 `EnableNetworkIsolation` 參數的值設定為 `True` 。

**注意**  
使用 AWS Marketplace的資源執行訓練任務和模型時，需要網路隔離。為了提高安全性， AWS Marketplace 映像會在 Amazon VPC 中執行。它們只能存取其本機檔案系統內的資料。

當您啟用網路隔離時，您的訓練和推論容器無法對任何服務進行任何傳出網路呼叫，包括 Amazon S3。容器執行期環境不會提供任何 AWS 登入資料。對於具有多個執行個體的訓練任務，網路傳入和傳出流量僅限於訓練容器對等之間的通訊。

SageMaker AI 仍會使用您的 SageMaker AI 執行角色處理所有必要的 Amazon S3 下載和上傳操作。除了訓練和推論容器之外，這也會發生，確保您的訓練資料和模型成品仍可存取，同時保持容器隔離。

下列受管 SageMaker AI 容器不支援網路隔離，因為它們需要存取 Amazon S3：
+ Chainer
+ SageMaker AI 強化學習

### 使用 VPC 的網路隔離
<a name="mkt-algo-model-internet-free-isolation-marketplace"></a>

您可以結合 VPC 使用網路隔離。在此案例中，客戶資料的下載和上傳以及模型成品，會透過您的 VPC 子網路來路由。不過，訓練和推論容器本身會持續從網路隔離，並且無法存取您的 VPC 內或網際網路上的任何資源。