[英]Pass a config file to Sagemaker training program
Setup:设置:
I have gone for the bring your own container option for AWS Sagemaker Training.我已经为 AWS Sagemaker Training 选择了自带容器选项。 In the Dockerfile, I specify the SAGEMAKER_PROGRAM
variable to point to tools/train.py
as I am working with mmaction2 repo.在 Dockerfile 中,我指定SAGEMAKER_PROGRAM
变量指向tools/train.py
,因为我正在使用 mmaction2 存储库。
So a user is executing所以用户正在执行
estimator = PyTorch(
role='sagemaker_role',
image_uri="path_in_ecr",
instance_count=1,
instance_type="ml.g4dn.xlarge",
volume_size=40,
output_path=f"s3://{bucket}/{prefix_output}/",
sagemaker_session=sagemaker_session,
max_run=3600 * 2,
)
estimator.fit()
on an ec2 machine where say they have a config in /home/ubuntu/train_config_mmaction2.py
在 ec2 机器上说他们在/home/ubuntu/train_config_mmaction2.py
中有一个配置
Problem: Since mmaction2 requires a config file as input which specifies the training config, how can I pass a file to Sagemaker Training so that it is copied from the calling ec2 instance to the training instance and used as a command line argument for the SAGEMAKER_PROGRAM
defined in the Dockerfile?问题:由于 mmaction2 需要一个配置文件作为指定训练配置的输入,我如何将文件传递给 Sagemaker Training,以便将其从调用 ec2 实例复制到训练实例,并用作定义的SAGEMAKER_PROGRAM
的命令行参数在 Dockerfile 中?
I tried using the entrypoint
and source_code
argument provided in the pytorch class where the entrypoint and the config is in the source_code directory so that the config would be copied.我尝试使用 pytorch class 中提供的entrypoint
点和source_code
代码参数,其中入口点和配置位于源代码目录中,以便复制配置。 However, this creates a dependency on have the entrypoint present locally for each run.但是,这会产生对每次运行都在本地存在入口点的依赖性。 I am wondering if there is a way to do this without having this dependency我想知道是否有办法在没有这种依赖的情况下做到这一点
Hey you can do multiple things:嘿,你可以做很多事情:
source_dir
, along with the entry point.在source_dir
中包含配置文件以及入口点。 This doesn't have to be local, it can also come from a git repo, as indicated here: blog , demo这不一定是本地的,它也可以来自 git 存储库,如下所示: 博客、 演示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.