简体   繁体   English

限制celery中同时特定任务的数量

[英]Limit the number of simultaneous specific tasks in celery

I have 2 tasks taskA and taskB which run using the GPU.我有 2 个任务taskAtaskB ,它们使用 GPU 运行。 They can both run on the GPU at the same time.它们都可以同时在 GPU 上运行。 But if celery decides to launch an additional instance, then I will have a crash (out of memory on the GPU).但是如果 celery 决定启动一个额外的实例,那么我就会崩溃(GPU 上的 memory)。

I therefore would like to be able to have control over this (ie only allow taskA + taskB , or taskB + taskB , or taskA + taskA at the same time, but prevent for instance taskA + taskA + taskB ).因此,我希望能够对此进行控制(即同时只允许taskA + taskBtaskB + taskBtaskA + taskA ,但例如阻止taskA + taskA + taskB )。

How can I control this?我该如何控制这个?

You could limit the number of simultaneous tasks by using the --concurrency argument.您可以使用--concurrency参数限制并发任务的数量。 Set this to 2 if you're using the same worker for both tasks or to 1 if you have two separate workers.如果您对两个任务使用相同的工作人员,则将此设置为 2;如果您有两个单独的工作人员,则将其设置为 1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM