Hi everyone! I have an AWS ECS workpool, which con...
# ask-community
p
Hi everyone! I have an AWS ECS workpool, which contains GPU instances in it. I want to run some flows which utilise those GPUs. However, when creating a deployment, I need a way to pass in
resourceRequirements: [{"type": "GPU", "value": N}]
into my task-definition. Otherwise the container running in ECS Task does not see the GPUs. Is there a way to dynamically pass in "resourceRequirements" to a deployment, for example, using
job_variables
? Or, any other ways?
I have tried out using a pre-created
task-definition
with
resourceRequirements
in it, and it works. However, then it's not dynamic enough. I would like to set the number of GPUs based on my flow
q
Hey, I'm currently facing the same issue, did you manage to figure out how to define resource requirements in the prefect.yaml directly without using the pre-created task definition? Also, how did you define capacity_provider_strategy in prefect.yaml?
p
Hi, I fixed it by editing my work-pool, going into "Advanced" and in the json config, adding the following under
variables:properties:
Copy code
"resource_requirements": {
        "type": "object",
        "title": "Resource Requirements",
        "default": {},
        "description": "Resource requirements to pass to the task run request. For example, to specify a GPU on a task, you can pass `{ \"resource_requirements\": [ { \"type\": \"GPU\", \"value\": \"1\" } ] }`"
      },
and adding the following to `job_configurationtask run requestcontainerOverrides`:
Copy code
"resourceRequirements": "{{ resource_requirements }}"
so now, I can do this in my
prefect.yaml
Copy code
- name: some_deployment
  work_pool: my_fixed_work_pool
    ... other options
    job_variables:
      ... other options
      resource_requirements:
        - type: GPU
          value: '1' #or, as many as you might need, but not more than what you have available
regarding capacity_provider_strategy, just set
launch_type: EC2
in
job_variables
hope this helps
q
I finally got it to work. Thanks so much for your help, really appreciate it!
👍 1