

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

# SageMaker AI 环境变量和训练存储位置的默认路径
<a name="model-train-storage-env-var-summary"></a>

下表汇总了训练平台管理的训练数据集、检查点、模型工件和输出的输入和输出路径。 SageMaker 


|  SageMaker 训练实例中的本地路径 | SageMaker AI 环境变量 | 用途 | 在启动期间从 S3 读取 | 在竞价型重启期间从 S3 读取 | 训练期间写入 S3 | 作业终止时写入 S3 | 
| --- | --- | --- | --- | --- | --- | --- | 
| `/opt/ml/input/data/{{channel_name}}`1  | SM\_channel\_ {{CHANNEL\_NAME}} | 从 SageMaker AI Python SDK [估算器类或 [CreateTrainingJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html)](https://sagemaker.readthedocs.io/en/stable/api/training/estimators.html#sagemaker.estimator.Estimator)API 操作指定的输入通道中读取训练数据。有关如何使用 SageMaker Python SDK 在训练脚本中指定它的更多信息，请参阅[准备训练脚本](https://sagemaker.readthedocs.io/en/stable/overview.html?highlight=VPC#prepare-a-training-script)。 | 支持 | 是 | 否 | 否 | 
| `/opt/ml/output/data`2 | SM\_OUTPUT\_DIR | 保存输出，例如损耗、精度、中间层、权重、梯度、偏差和兼容 TensorBoard输出。您也可以使用此路径保存所有您想要的任意输出。请注意，这与存储最终模型构件的路径 `/opt/ml/model/` 不同。 | 否 | 否 | 否 | 是 | 
| `/opt/ml/model`3 | SM\_MODEL\_DIR | 存储最终的模型构件。这也是从 SageMaker AI Hosting 中部署模型工件以进行[实时推理](https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints.html)的路径。 | 否 | 否 | 否 | 是 | 
| `/opt/ml/checkpoints`4 | - | 保存模型检查点（模型状态）以便从某个点恢复训练，并且能够从意外或[托管竞价型训练](https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html)中断中恢复。 | 支持 | 是 | 是 | 否 | 
| `/opt/ml/code` | SAGEMAKER\_SUBMIT\_DIRECTORY | 复制训练脚本、其他库和依赖项。 | 支持 | 是 | 否 | 否 | 
| `/tmp` | - | 读取或写入 `/tmp` 作为暂存空间。 | 否 | 否 | 否 | 否 | 

1 `channel_name` 是为训练数据输入指定用户定义通道名称的地方。每个训练作业可以包含多个数据输入通道。您最多可以为每个训练作业指定 20 个训练输入通道。请注意，从数据通道下载数据的时间计入计费时间。有关数据输入路径的更多信息，请参阅 [Amazon SageMaker AI 如何提供训练信息](https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-training-algo-running-container.html)。此外， SageMaker AI 还支持三种类型的数据输入模式：文件模式 FastFile、管道模式和管道模式。要详细了解用于 SageMaker AI 训练的数据输入模式，请参阅[访问训练数据](https://docs.aws.amazon.com/sagemaker/latest/dg/model-access-training-data.html)。

2 SageMaker AI 压缩训练工件并将其写入 TAR 文件 (`tar.gz`)。压缩和上传的时间计入计费时间。有关更多信息，请参阅 [Amazon A SageMaker I 如何处理训练输出](https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-training-algo-output.html)。

3 SageMaker AI 压缩并写入最终的模型工件到 TAR 文件 (`tar.gz`)。压缩和上传的时间计入计费时间。有关更多信息，请参阅 [Amazon A SageMaker I 如何处理训练输出](https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms-training-algo-output.html)。

4 在训练期间与 Amazon S3 同步。按原样写入，而不压缩为 TAR 文件。有关更多信息，请参阅[在 Amazon A SageMaker I 中使用检查点](https://docs.aws.amazon.com/sagemaker/latest/dg/model-checkpoints.html)。