简体   繁体   English

Ipython并行和多核流程

[英]Ipython parallel and multicore processes

I would like to use ipython parallel for job execution on a compute cluster. 我想在计算集群上使用ipython parallel执行作业。 Setting things up is all relatively straightforward, but some jobs that I will be executing include subprocess calls to multithreaded applications (bioinformatics). 设置相对简单,但我将执行的一些工作包括对多线程应用程序(生物信息学)的子进程调用。 Is there a simple way to tell ipython that multiple cores or entire engines are being consumed by a single python call? 是否有一种简单的方法告诉ipython单个python调用正在使用多个内核或整个引擎? More generally, I'd like to track resources used and available so that I can run heterogeneous jobs (memory requirements, core requirements). 更一般地说,我想跟踪使用和可用的资源,以便我可以运行异构作业(内存要求,核心要求)。

IPython does not do any resource allocation for individual tasks. IPython不为单个任务进行任何资源分配。 All resource allocation is done at engine creation time. 所有资源分配都在引擎创建时完成。 For instance, if your jobs are already fully multithreaded and multicore aware, then you may not want more than one IPython engine per physical machine. 例如,如果您的作业已经完全多线程且可识别多核,那么您可能不希望每台物理机器有多个IPython引擎。 If your jobs are single-threaded, then one engine per CPU core is logical. 如果您的作业是单线程的,那么每个CPU核心一个引擎是合乎逻辑的。 If your tasks are IO-bound on multiple non-exclusive resources, then you may want more engines than cores. 如果您的任务在多个非独占资源上受IO限制,那么您可能需要更多引擎而不是内核。

If your work is highly heterogeneous (eg some tasks are confined to one thread, while others will happily use the whole machine), then you may want to arrange some more sophisticated scheduling. 如果您的工作是高度异构的(例如,某些任务仅限于一个线程,而其他任务将很乐意使用整个机器),那么您可能希望安排一些更复杂的调度。 Two useful pieces of information for giving this a try are creating views of subsets of engines. 尝试这两个有用的信息是创建引擎子集的视图。 For instance, a load-balanced and direct view with only one engine per machine in the cluster: 例如,集群中每台机器只有一个引擎的负载均衡和直接视图:

import socket
host_map = client[:].apply_async(socket.gethostname).get_dict()
r = { v:k for k,v in host_map.items() }
one_id_per_machine = list(r.values())
one_per_machine = client[one_id_per_machine]
lb_per_machine = client.load_balanced_view(one_id_per_machine)

And the other is the graph-based dependencies that you might use to create barriers, allowing one task to block others from being submitted to other engines. 另一个是您可能用于创建障碍的基于图形的依赖项 ,允许一个任务阻止其他任务被提交到其他引擎。

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

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