AWS 批处理¶
这包含可用于运行 TorchX 的 TorchX AWS Batch 调度程序 组件。
此调度程序处于原型阶段,如有更改,恕不另行通知。
先决条件¶
您需要创建为多节点并行作业配置的 AWS Batch 队列。
有关如何设置作业队列和计算环境的信息,请参阅 https://docs.aws.amazon.com/batch/latest/userguide/Batch_GetStarted.html。它需要得到 EC2 用于多节点并行作业。
有关分布式作业的更多信息,请参阅 https://docs.aws.amazon.com/batch/latest/userguide/multi-node-parallel-jobs.html。
如果您想使用工作区和容器修补,您还需要 配置 Docker 注册表以存储包含更改的修补容器 例如 AWS ECR。
有关如何创建映像存储库的信息,请参阅 https://docs.aws.amazon.com/AmazonECR/latest/userguide/getting-started-cli.html#cli-create-repository。
- torchx.schedulers.aws_batch_scheduler 类。AWSBatchScheduler(session_name: str, client: Optional[Any] = None, log_client: 可选[任何] = 无,docker_client: 可选[DockerClient] = 无)[来源]¶
基地:
DockerWorkspaceMixin
,Scheduler
[AWSBatchOpts
]AWSBatchScheduler 是 AWS Batch 的 TorchX 调度接口。
$ pip install torchx[kubernetes] $ torchx run --scheduler aws_batch --scheduler_args queue=torchx utils.echo --image alpine:latest --msg hello aws_batch://torchx_user/1234 $ torchx status aws_batch://torchx_user/1234 ...
使用凭证从环境中加载身份验证 处理。
boto3
配置选项
usage: queue=QUEUE,[user=USER],[privileged=PRIVILEGED],[share_id=SHARE_ID],[priority=PRIORITY],[job_role_arn=JOB_ROLE_ARN],[execution_role_arn=EXECUTION_ROLE_ARN],[image_repo=IMAGE_REPO],[quiet=QUIET] required arguments: queue=QUEUE (str) queue to schedule job in optional arguments: user=USER (str, runner) The username to tag the job with. `getpass.getuser()` if not specified. privileged=PRIVILEGED (bool, False) If true runs the container with elevated permissions. Equivalent to running with `docker run --privileged`. share_id=SHARE_ID (str, None) The share identifier for the job. This must be set if and only if the job queue has a scheduling policy. priority=PRIORITY (int, 0) The scheduling priority for the job within the context of share_id. Higher number (between 0 and 9999) means higher priority. This will only take effect if the job queue has a scheduling policy. job_role_arn=JOB_ROLE_ARN (str, None) The Amazon Resource Name (ARN) of the IAM role that the container can assume for AWS permissions. execution_role_arn=EXECUTION_ROLE_ARN (str, None) The Amazon Resource Name (ARN) of the IAM role that the ECS agent can assume for AWS permissions. image_repo=IMAGE_REPO (str, None) (remote jobs) the image repository to use when pushing patched images, must have push access. Ex: example.com/your/container quiet=QUIET (bool, False) whether to suppress verbose output for image building. Defaults to ``False``.
坐骑
此类支持绑定挂载主机目录、efs 卷和主机 设备。
绑定挂载:
type=bind,src=<host path>,dst=<container path>[,readonly]
EFS 卷:
type=volume,src=<efs id>,dst=<container path>[,readonly]
设备:
type=device,src=/dev/infiniband/uverbs0,[dst=<container path>][,perm=rwm]
看
torchx.specs.parse_mounts()
了解更多信息。对于其他文件系统,例如 FSx,您可以将它们挂载到主机上并绑定 将它们挂载到你的 Job 中:https://repost.aws/knowledge-center/batch-fsx-lustre-file-system-mount
对于 Elastic Fabric Adapter (EFA),您需要使用设备挂载来挂载 它们进入容器:https://docs.aws.amazon.com/batch/latest/userguide/efa.html
兼容性
特征
计划程序支持
获取日志
✔️
分布式作业
✔️
取消作业
✔️
描述任务
部分支持。AWSBatchScheduler 将返回作业和副本 状态,但不提供完整的原始 AppSpec。
工作区 / 修补
✔️
坐骑
✔️
弹性
❌
- describe(app_id: str) 可选[DescribeAppResponse] [来源]¶
描述指定的应用程序。
- 结果
AppDef 描述,或者应用程序不存在。
None
- list() List[ListAppResponse] [来源]¶
对于在调度程序上启动的应用程序,此 API 返回 ListAppResponse 列表 对象,每个对象都有 App ID 及其 Status。 注意:此 API 处于原型阶段,可能会发生更改。
- log_iter(app_id: str, role_name: str, k: int = 0, 正则表达式: 可选[str] = 无,因为: 可选[日期时间] = 无,直到:可选[日期时间] = 无,should_tail:bool = False,流: 可选[stream] = None) Iterable[str] [来源]¶
返回 . 当读取了所有符合条件的 log 行时,迭代器结束。
k``th replica of the ``role
如果调度程序支持基于时间的游标获取日志行 对于自定义时间范围,则 , 字段为 honored,否则将被忽略。未指定 ,相当于获取所有可用的日志行。如果 是 empty,则迭代器的行为类似于 ,跟在日志输出之后 直到作业达到 END 状态。
since
until
since
until
until
tail -f
构成日志的确切定义特定于计划程序。一些 调度器可能会将 stderr 或 stdout 视为日志,其他人可能会读取日志 从日志文件中。
行为和假设:
如果在不存在的应用程序上调用,则生成 undefined-behavior 调用方应在调用此方法之前检查应用是否存在 using。
exists(app_id)
不是有状态的,使用相同的参数调用此方法两次 返回一个新的迭代器。先前迭代 进度丢失。
并不总是支持对数拖尾。并非所有调度程序都支持 live 日志迭代(例如,在应用程序运行时跟踪日志)。指 Iterator 行为的特定 scheduler 文档。
- 3.1 如果调度器支持 log-tailing,应该对其进行控制
by 参数。
should_tail
不保证日志保留。有可能到这个 方法调用时,底层调度程序可能已经清除了日志记录 对于此应用程序。如果是这样,此方法将引发任意异常。
如果为 True,则该方法仅引发异常 当可访问的日志行已完全耗尽并且应用程序已达到 最终状态。例如,如果应用程序卡住并且没有产生任何日志行, 然后 iterator 会阻塞,直到应用程序最终被杀死(通过 timeout 或手动),此时它会引发 .
should_tail
StopIteration
StopIteration
如果为 False,则当没有更多日志时,该方法将引发。
should_tail
StopIteration
不需要所有调度程序都支持。
一些调度器可能通过支持 line cursor(例如 寻找第 50 个对数行)。
__getitem__
iter[50]
- 保留空格,每个新行应包含 。自
\n
支持交互式进度条返回的行不需要 include 的 m,但随后应打印时不带换行符 正确处理回车。
\n
\r
- 保留空格,每个新行应包含 。自
- 参数
streams – 要选择的 IO 输出流。 其中之一: combined, stdout, stderr. 如果计划程序不支持所选流,它将 throw 一个 ValueError 的 Error。
- 结果
指定角色副本的 over log lines
Iterator
- 提升:
NotImplementedError – 如果调度程序不支持日志迭代
- torchx.schedulers.aws_batch_scheduler 类。BatchJob(名称: str, 队列: str, share_id: Union[str, NoneType]、job_def:Dict[str, object]、images_to_push:Dict[str, 元组[str, str]])[来源]¶