Sagemaker 模型训练中没有 space 留在设备上

No space left on device in Sagemaker model training

我在带有 AWS Sagemaker 的 p2 实例上使用随 Docker 图像一起提供的自定义算法 运行(有点类似于 https://github.com/awslabs/amazon-sagemaker-examples/blob/master/advanced_functionality/scikit_bring_your_own/scikit_bring_your_own.ipynb

在训练过程结束时,我尝试将我的模型写到输出目录,这是通过 Sagemaker 安装的(就像在教程中一样),如下所示:

model_path = "/opt/ml/model"
model.save(os.path.join(model_path, 'model.h5'))

不幸的是,模型显然随着时间的推移变得太大了,我得到了 以下错误:

RuntimeError: Problems closing file (file write failed: time = Thu Jul 26 00:24:48 2018

00:24:49 , filename = 'model.h5', file descriptor = 22, errno = 28, error message = 'No space left on device', buf = 0x1a41d7d0, total write[...]

所以我所有的 GPU 时间都被浪费了。我怎样才能防止这种情况再次发生?有谁知道我存储在 Sagemaker/mounted 目录中的模型的大小限制是多少?

在 SageMaker Jupyter notebook 中,您可以通过 运行 !df -h 检查文件系统上的免费 space。对于特定路径,请尝试 !df -h /opt.

当您使用 Estimators 训练模型时,它 defaults to 30 GB of storage 可能还不够。您可以在构造函数上使用 train_volume_size 参数来增加此值。尝试使用较大的数字(例如 100GB)并查看您的模型有多大。在后续的工作中,您可以将该值调低到更接近您实际需要的值。

存储成本[=13=].14 per GB-month of provisioned storage。部分使用是按比例分配的,所以给自己一些额外的空间是防止 运行 存储空间不足的廉价保险。