

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在互联网免费模式下运行训练和推理容器
<a name="mkt-algo-model-internet-free"></a>

SageMaker AI 训练和部署的推理容器默认支持互联网。这允许容器访问外部服务和公共 Internet 上的资源，以作为训练和部署工作负载的一部分。不过，这为未经授权访问您的数据提供了一种途径。例如，恶意用户或无意中安装在容器上的恶意代码（以公开发布的源代码库形式）就可以访问您的数据并将数据传输到远程主机。

如果您在调用 [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 仍然使用您的 A SageMaker I 执行角色来处理所有必要的 Amazon S3 下载和上传操作。这与您的训练和推理容器分开进行，从而确保您的训练数据和模型工件仍然可以访问，同时保持容器隔离。

以下托管 SageMaker AI 容器不支持网络隔离，因为它们需要访问 Amazon S3：
+ Chainer
+ SageMaker AI 强化学习

### 使用 VPC 进行网络隔离
<a name="mkt-algo-model-internet-free-isolation-marketplace"></a>

网络隔离可与 VPC 结合使用。在这种情况下，下载和上传的客户数据和模型构件将通过您的 VPC 子网进行路由。但是，训练和推理容器本身继续与网络隔离，并且对 VPC 内或 Internet 上的任何资源都没有访问权限。