【发布时间】:2021-04-19 00:51:42
【问题描述】:
我正在使用 Amazon Sagemaker 使用 Tensorflow 训练模型,我希望能够在作业运行时监控训练进度。然而,在训练期间,不会将 Tensorboard 文件输出到 S3,只有在训练作业完成后才会将文件上传到 S3。训练完成后,我可以下载文件并看到 Tensorboard 在整个训练过程中一直正确记录值,尽管训练完成后仅在 S3 中更新一次。
我想知道为什么 Sagemaker 没有在整个训练过程中将 Tensorboard 信息上传到 S3?
这是我在 Sagemaker 上的笔记本中启动培训工作的代码
import sagemaker
from sagemaker.tensorflow import TensorFlow
from sagemaker.debugger import DebuggerHookConfig, CollectionConfig, TensorBoardOutputConfig
import time
bucket = 'my-bucket'
output_prefix = 'training-jobs'
model_name = 'my-model'
dataset_name = 'my-dataset'
dataset_path = f's3://{bucket}/datasets/{dataset_name}'
output_path = f's3://{bucket}/{output_prefix}'
job_name = f'{model_name}-{dataset_name}-training-{time.strftime("%Y-%m-%d-%H-%M-%S", time.gmtime())}'
s3_checkpoint_path = f"{output_path}/{job_name}/checkpoints" # Checkpoints are updated live as expected
s3_tensorboard_path = f"{output_path}/{job_name}/tensorboard" # Tensorboard data isn't appearing here until the training job has completed
tensorboard_output_config = TensorBoardOutputConfig(
s3_output_path=s3_tensorboard_path,
container_local_output_path= '/opt/ml/output/tensorboard' # I have confirmed this is the unaltered path being provided to tf.summary.create_file_writer()
)
role = sagemaker.get_execution_role()
estimator = TensorFlow(entry_point='main.py', source_dir='./', role=role, max_run=60*60*24*5,
output_path=output_path,
checkpoint_s3_uri=s3_checkpoint_path,
tensorboard_output_config=tensorboard_output_config,
instance_count=1, instance_type='ml.g4dn.xlarge',
framework_version='2.3.1', py_version='py37', script_mode=True)
dpe_estimator.fit({'train': dataset_path}, wait=True, job_name=job_name)
【问题讨论】:
-
查看训练作业的 cloudwatch 日志。有什么相关的吗?
-
似乎没有。在日志中搜索“tensorboard”没有产生任何结果。唯一与远程相关的日志似乎是
Creating hook from json_config at /opt/ml/input/config/debughookconfig.json.和Saving to /opt/ml/output/tensors,它们出现在训练开始之前。 -
只是为了确认.. 训练作业完成后,日志是否上传到您在训练期间尝试上传的完全相同的 s3 位置?或者它是一个不同的桶?
-
日志被上传到嵌套在我试图让它们在整个培训过程中上传的位置的目录中,我将其传递为
s3_output_path。我传递给TensorBoardOutputConfig的目录是s3://{bucket}/training-jobs/{job_name}/tensorboard。在训练结束时,日志输出文件到嵌套在其中的目录,特别是s3://{bucket}/training-jobs/{job_name}/tensorboard/{job_name}/tensorboard_output/ -
更新:我已将
s3_output_path更改为s3://{bucket}/training-jobs,以便在训练后,日志直接在s3://{bucket}/training-jobs/{job_name}/tensorboard-output/中而不是嵌套,但tensorboard-output文件夹和日志仍然没有' t 出现直到训练完成
标签: python amazon-web-services tensorflow tensorboard amazon-sagemaker