简体   繁体   English

Joblib是否需要多个内核进行多处理?

[英]Does joblib require multiple cores for multiprocessing?

I am using joblib for processing 4 frames (images taken from video) in parallel. 我正在使用joblib并行处理4帧(从视频拍摄的图像)。 Used the parallel for loop for this where each loop called the same function for different frames. 为此使用了并行for循环,其中每个循环针对不同的帧调用相同的函数。 Since the capturing of the frame takes just 1 percent of the total processing time (found by python script profiling using line profiler), I first capture 4 frames and hand over to joblib for multiprocessing. 由于捕获帧仅占总处理时间的1%(通过使用line profiler通过python脚本分析发现),因此我首先捕获4帧并将其移交给joblib进行多处理。

I found that using Laptop, the process speeded up by roughly 5x. 我发现使用笔记本电脑,处理速度提高了大约5倍。 On Rapberry pi-2 (quad-core), almost 8x speedup was observed and on the Beaglebone Black, (not multicore) also, there was almost 7x speedup is observed. 在Rapberry pi-2(四核)上,观察到近8倍的加速,而在Beaglebone Black(非多核)上也观察到近7倍的加速。 So, how exactly does joblib distribute the tasks? 那么,joblib如何精确地分配任务?

By default joblib.parallel uses the Python multiprocessing module to fork separate Python worker processes to execute tasks concurrently on separate CPUs. 默认情况下, joblib.parallel使用Python multiprocessing模块来分叉单独的Python工作进程,以在单独的CPU上同时执行任务。

The multiprocessing module can take advantage of multiple cores/processors (it gets around GIL by starting multiple processes transparently). multiprocessing模块可以利用多个内核/处理器(它通过透明地启动多个进程来绕过GIL)。 It offers some primitives similar to the threading module. 它提供了一些类似于线程模块的原语。

The overall efficiency depends on subtleties of how the cores share access to memory. 整体效率取决于内核如何共享对内存的访问的微妙之处。

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

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