[英]Parallel Python doesn't give errors but parallel processing doesn't take place
我是python和Parallel Python的新手。 问题是我要完成4个工作:生成4个蒙版,将它们与我的输入图像相乘,然后进行进一步处理。 以下是为并行处理而编写的代码。
inputs = range(4)
jobs = [(inpt, job_server.submit(PP, (inpt,input_data,size,(imageMultiply,blockCounter,imageQuantizer ), ("numpy","Image"))) for inpt in inputs]
job_server.print_stats()
for inpt, job in jobs:
print "No of blocks in ", inpt, "is", job() ## accessing the result of pp
我得到的输出是:
Starting pp with 4 workers
Job execution statistics:
job count | % of all jobs | job time sum | time per job | job server
4 | 100.00 | 0.0000 | 0.000000 | local
Time elapsed since server creation 0.0219678878784
4 active tasks, 4 cores
No of blocks in 0 is 52
No of blocks in 1 is 61
No of blocks in 2 is 104
No of blocks in 3 is 48
我无法理解,如果不能同时处理它,我仍然可以获得所需的输出,但是花费的时间太长,这就是为什么我要使用pp。请帮助我,以便成功减少时间。 提前致谢...
从您的print_stats()
输出(此处已重新格式化)
Job execution statistics:
job count | % of all jobs | job time sum | time per job | job server
4 | 100.00 | 16.0401 | 4.010028 | local
Time elapsed since server creation 4.04183793068
0 active tasks, 4 cores
一切似乎都很好。 您有4个CPU内核; 创建作业服务器后,您可以在4秒钟内完成4个作业; 系统总共花费了16个CPU秒来完成所有作业。
您可能要尝试使用top -H
, htop
或Windows Sysinternals Process Monitor
来实时观察CPU消耗。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.