As a last step to configuring AWS Batch, we will register a job definition that will act as a template when we submit jobs.
Run the following to generate the configuration file that will be used to create the job definition:
export JOB_DEFINITION_NAME=RenderingJobDefinition
cat <<EoF > job-definition-config.json
{
"jobDefinitionName": "${JOB_DEFINITION_NAME}",
"type": "container",
"containerProperties": {
"image": "${IMAGE}",
"vcpus": 1,
"memory": 8000,
"command": ["Ref::action", "-i", "Ref::inputUri", "-o", "Ref::outputUri", "-f", "Ref::framesPerJob"]
},
"retryStrategy": {
"attempts": 3
},
"platformCapabilities": [
"EC2"
]
}
EoF
Let’s explore the configuration parameters in the structure:
container
is the default type and allows to run loosely coupled HPC workloads at scale. The other available type is multi-node
. With AWS Batch multi-node you can run large-scale, tightly coupled, high performance computing applications. Note multi-node
jobs are not supported with Spot instances. To learn more about multi-node
jobs, visit multi-node parallel jobs.EC2
or FARGATE
.The values of vcpus
and memory
have been defined based on the resources needed to render a specific file. Each Blender file can be different in this sense and those values should be adapted accordingly to prevent the container from running out of memory when executing Blender.
Execute this command to create the job definition. To learn more about this API, see register-job-definition CLI command reference.
export JOB_DEFINITION_ARN=$(aws batch register-job-definition --cli-input-json file://job-definition-config.json | jq -r '.jobDefinitionArn')
echo "Job definition Arn: ${JOB_DEFINITION_ARN}"
Finally, you are going to submit a job request.