简体   繁体   English

为什么多处理在Google Compute Engine中不使用100%CPU?

[英]Why doesn't Multiprocessing use 100% CPU in Google Compute Engine?

I have to run some code in parallel and, while it uses 100% of the CPU in my local computer, it doesn't work like that in Google Compute Engine. 我必须并行运行一些代码,尽管它占用了本地计算机中100%的CPU,但它无法像Google Compute Engine中那样工作。

I'm using a Compute Engine with 24vCPUs and 22Gb memory. 我正在使用具有24vCPU和22Gb内存的Compute Engine。 The following image shows the utilization of CPU while the program is running. 下图显示了程序运行时的CPU使用率。

CPU利用率低于0.15% The mock code I'm using is: 我正在使用的模拟代码是:

from joblib import Parallel, delayed
import multiprocessing 

def some_function():
       num_cores = multiprocessing.cpu_count() # = 24
       salida = Parallel(n_jobs=num_cores)(delayed(hijo.calcula_error)(metodo='pond') for hijo in self.descendencia)

Where hijo.calcula_error is a function that can be run in parallel. hijo.calcula_error是可以并行运行的函数。

Is this behaviour normal or am I doing something wrong? 这是正常现象还是我做错了什么?

I think that it also depends very much on your code, I would review the multiprocessing methods and start testing by run it on a single core instance to see if it uses all the capacity (or maybe spawn 24 process on a 24 core instance). 我认为这也很大程度上取决于您的代码,我将审查多处理方法并通过在单个核心实例上运行它来开始测试,以查看其是否使用了所有容量(或在24个核心实例上生成24个进程)。 I hope this can help. 希望对您有所帮助。

Other thing I would consider here is take a look on the memory bottleneck or disk I/O throttling that could be limiting the over all performance of the instance. 我在这里要考虑的另一件事是看一下内存瓶颈或磁盘I / O限制,它们可能会限制实例的整体性能。

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

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