"AWSBatch" (批处理计算服务商)
详细信息
AWS Batch 根据每个作业的 vCPU 计数要求将作业打包到实例中. 多个作业可以在单个 EC2 实例上同时执行,每个作业在专用 Docker 容器中运行.
作业设置
| "GPUCount" | Inherited | GPU 的整数数量 » | |
| "Memory" | Automatic | "InformationUnit" 数量或整数兆字节 » | |
| "VCPUCount" | Inherited | vCPU 的整数数量 » |
"GPUCount"、"Memory" 和 "VCPUCount" 设置的 Inherited 值对应由提供的 RemoteBatchSubmissionEnvironment 对象指定的 AWS Batch 作业定义中的值.
在使用 RemoteBatchSubmit 提交的 "Single" 类型作业中,ParallelEvaluate 和 ParallelMap 等函数将自动启动与 "VCPUCount" 设置值等效的多个子内核. 可以通过使用明确数量的内核调用 LaunchKernels 来覆盖此行为.
使用 "AWSBatch" 提供程序时,RemoteBatchSubmit 和 RemoteBatchMapSubmit 的 TimeConstraint 选项的值必须至少为 60 秒. TimeConstraint 选项默认为正在使用的作业定义中的 "Execution timeout"(执行超时)值.
作业通知
"AWSBatch" 服务商不支持作业通知.
作业状态
| "Submitted" | 已提交的 AWS Batch 调度程序尚未评估的作业 | |
| "Pending" | 作业正在等待依赖关系得到满足 | |
| "Runnable" | 作业正在等待可用的计算资源 | |
| "Starting" | 该作业已安排到一个实例,并且正在下载其容器映像 | |
| "Running" | 作业的容器已启动 | |
| "Succeeded" | 作业执行成功,其输出已上传 | |
| "Failed" | 作业执行失败 |
AWS Batch 文档中提供了有关作业状态的更多信息.
作业属性
| "JobExitCode" | 作业容器中内核返回的退出代码 | |
| "JobLog" | 来自作业容器的控制台日志 | |
| "JobStatusReason" | 描述作业处于当前状态的原因的字符串 | |
| "ProviderJobID" | AWS 为作业提供的唯一标识符 |
| "ChildJobExitCodes" | 每个阵列子作业的 "JobExitCode" 属性 | |
| "ChildJobStatusReasons" | 每个阵列子作业的 "JobStatusReason" 属性 | |
| "JobStatusReason" | 描述阵列作业处于其当前状态的原因的字符串 | |
| "ProviderJobID" | AWS 为阵列作业提供的唯一标识符 |
| "JobExitCode" | 作业容器中内核返回的退出代码 | |
| "JobLog" | 来自子作业容器的控制台日志 | |
| "JobStatusReason" | 描述子作业处于当前状态的原因的字符串 | |
| "ProviderJobID" | AWS-provided unique identifier for the child job |
表示已过期作业的 RemoteBatchJobObject 表达式无法查询状态,并且不会被 RemoteBatchJobs 列出. 过期作业的输出数据将保留在 Amazon S3 中,并可从 RemoteBatchJobObject 访问,直到被存储桶的生命周期策略手动删除或过期.
范例
打开所有单元 关闭所有单元基本范例 (2)
在按照设置 AWS Batch 计算提供程序工作流程中所述配置 "AWSBatch" 批处理计算提供程序后,创建一个 "AWSBatch" RemoteBatchSubmissionEnvironment 对象:
environment = RemoteBatchSubmissionEnvironment["AWSBatch", <|
"IOBucket" -> "my-job-bucket",
"JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1:123456789012:job-definition/MyDefinition:1"
|>]RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1:123456789012:job-definition/MyDefinition:1",
"IOBucket" -> "my-job-bucket"], "Valid" -> True]job = RemoteBatchSubmit[environment, 2 + 2]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... reated" -> True],
"ProviderJobID" -> "f82ccd45-8697-44d8-a568-c5490a93bd0e",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[2048, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]job["JobStatus"]job["JobStatus"]job["EvaluationResult"]使用明确指定的 "AWS" 服务对象创建环境对象:
aws = ServiceConnect["AWS"]ServiceObject["AWS", "ID" -> "connection-1fdc21f34e3b8af98e16ae0b2d970261"]RemoteBatchSubmissionEnvironment["AWSBatch", <|
"JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1:123456789012:job-definition/MyDefinition:1",
"IOBucket" -> "my-job-bucket",
"ServiceObject" -> aws
|>]RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1:123456789012:job-definition/MyDefinition:1",
"IOBucket" -> "my-job-bucket"], "Valid" -> True]作业设置 (4)
"GPUCount" (1)
向 AWS Batch 提交一个阵列作业,该作业使用 GPU 计算通过预训练的神经网络执行:
images = RandomSample[ResourceData["MNIST"], 20][[All, 1]];
job = RemoteBatchMapSubmit[
RemoteBatchSubmissionEnvironment[...],
model[#, TargetDevice -> "GPU"]&,
images,
RemoteProviderSettings -> <|"GPUCount" -> 1|>,
Initialization :> (model = NetModel["LeNet Trained on MNIST Data"])
]RemoteBatchJobObject["AWSBatch", Association["ChildJobCount" -> 4, "ChildJobsPerInputChunk" -> 4,
"Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueu ... toCreated" -> True], "ProviderJobID" -> "d50c05f5-c899-48e4-b148-cf6002b60a49",
"ProviderSettings" -> Association["GPUCount" -> 1, "Memory" -> Quantity[4096, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]AssociationThread[images -> job["EvaluationResults"]]"Memory" (2)
job = RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], Array[Range[1, #]&, 38000];, RemoteProviderSettings -> <|"Memory" -> Quantity[8, "Gibibytes"]|>]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... toCreated" -> True],
"ProviderJobID" -> "b23a465a-113e-4266-a647-17ff8afffa8b",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[8, "Gibibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]job["JobStatus"]若未另行指定,则默认内存限制基于配置的 vCPU 和 GPU 计数:
jobs = {
RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], 2 + 2],
RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], 2 + 2, RemoteProviderSettings -> <|"VCPUCount" -> 16|>],
RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], 2 + 2, RemoteProviderSettings -> <|"GPUCount" -> 2|>]
};
#["ProviderSettings"]& /@ jobs"VCPUCount" (1)
job = RemoteBatchSubmit[
RemoteBatchSubmissionEnvironment[...],
{$ProcessorCount, ParallelEvaluate[$KernelID]},
RemoteProviderSettings -> <|"VCPUCount" -> 4|>
]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... toCreated" -> True],
"ProviderJobID" -> "09b6f4aa-31b5-4ba7-8ac7-d84d39e018e6",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[4, "Gibibytes"],
"VCPUCount" -> 4], "TimeConstraint" -> Quantity[86400, "Seconds"]]]job["EvaluationResult"]作业属性 (2)
"Single" 作业 (1)
使用 RemoteBatchSubmit 向 AWS Batch 提交批处理作业:
job = RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], 2 + 2]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... reated" -> True],
"ProviderJobID" -> "8869279e-feaf-4fcc-a201-17747d6c896a",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[2048, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]{job["JobStatus"], job["JobStatusReason"]}job["JobLog"]"Array" 和 "ArrayChild" 作业 (1)
使用 RemoteBatchMapSubmit 将阵列作业提交到 AWS Batch:
arrayJob = RemoteBatchMapSubmit[
RemoteBatchSubmissionEnvironment[...],
# ^ 2&, Range[8]
]RemoteBatchJobObject["AWSBatch", Association["ChildJobCount" -> 3, "ChildJobsPerInputChunk" -> 3,
"Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueu ... toCreated" -> True], "ProviderJobID" -> "12ed940d-b260-4c81-ace3-74e6ea6e2cab",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[2048, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]Merge[{arrayJob["ChildJobStatuses"], arrayJob["ChildJobStatusReasons"]}, Identity]获取代表第一个子作业的 RemoteBatchJobObject 表达式:
childJob = arrayJob["ChildJobObjects"][[1]]{childJob["JobStatus"], childJob["JobStatusReason"]}childJob["JobLog"]属性和关系 (1)
如果作业被 RemoteBatchJobAbort 终止,"JobStatusReason" 属性的值将指示终止请求源自 Wolfram 语言:
job = RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], 2 + 2]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... reated" -> True],
"ProviderJobID" -> "d1ee02ea-e40a-4690-ac13-283610084d1b",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[2048, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]RemoteBatchJobAbort[job]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... reated" -> True],
"ProviderJobID" -> "d1ee02ea-e40a-4690-ac13-283610084d1b",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[2048, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]{job["JobStatus"], job["JobStatusReason"]}可能存在的问题 (2)
job = RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], Array[Range[1, #]&, 38000];]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... reated" -> True],
"ProviderJobID" -> "fe328b8a-6b14-4c26-a9f2-368638ba5a3c",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[4096, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]{job["JobStatus"], job["JobStatusReason"]}job = RemoteBatchSubmit[RemoteBatchSubmissionEnvironment[...], Array[Range[1, #]&, 38000];, RemoteProviderSettings -> <|"Memory" -> Quantity[8, "Gibibytes"]|>]RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... toCreated" -> True],
"ProviderJobID" -> "b23a465a-113e-4266-a647-17ff8afffa8b",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[8, "Gibibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[86400, "Seconds"]]]job["JobStatus"]AWS Batch 在作业达到完成状态("Succeeded" 或 "Failed")后 24 小时删除作业的元数据. 这将导致元数据查询返回缺失值:
job = RemoteBatchJobObject["AWSBatch",
Association["Environment" -> RemoteBatchSubmissionEnvironment["AWSBatch",
Association["JobQueue" -> "arn:aws:batch:us-east-1:123456789012:job-queue/MyQueue",
"JobDefinition" -> "arn:aws:batch:us-east-1: ... eated" -> True],
"ProviderJobID" -> "d80a93c8-fc81-4694-8904-3dfd0cd63a06",
"ProviderSettings" -> Association["GPUCount" -> 0, "Memory" -> Quantity[2048, "Mebibytes"],
"VCPUCount" -> 1], "TimeConstraint" -> Quantity[604800, "Seconds"]]];job["JobStatus"]若配置了相应策略,则作业的输出数据在被提交环境的 I/O 存储桶上的生命周期策略手动删除或自动过期之前仍然可以访问:
job["EvaluationResult"]相关的工作流程
- 设置 AWS Batch 计算服务商
相关的工作流程
▪
相关链接
历史
2020年引入 (12.2) | 在以下年份被更新:2021 (13.0)