【问题标题】:GNU Parallel not using all processorsGNU Parallel 不使用所有处理器
【发布时间】:2019-03-18 14:34:39
【问题描述】:

我正在使用 GNU 并行来加速进程。但是,GNU 并行并没有使用我机器上的所有内核。我想知道这里的限制因素是什么。

命令:

find data -type f | parallel --pipe -P 70 python program.py > output 

但是,它只使用了 70 个内核中的 4 个。我想知道是否有人知道是否有其他限制使其仅使用 4 个内核。

【问题讨论】:

  • -P 70 在做什么?尝试删除它。什么计算机有 70 个内核?
  • 如果你有一台奇怪的机器(有 70 个内核),你可以检查 parallel 看到你所有的内核与 parallel --number-of-cores
  • @MarkSetchell 它有 72 个,我想我会留下两个用于我正在做的其他事情。 parallel --number-of-cores 也返回 72。但是当我使用 --xargs 而不是 --pipe 时它似乎可以工作,但是我需要重写 program.py 才能工作。

标签: gnu-parallel


【解决方案1】:

我不知道program.py 会。但是将--pipefind 一起使用是非常少见的。所以我认为这就是你想要的:

find data -type f | parallel -P 70 python program.py > output 

对于--pipefind 的输出必须至少为 70 MB,才能并行运行 70 个作业,因为默认的 --block-size 为 1 MB:

find data -type f | parallel --pipe -P 70 python program.py > output 

如果program.py 真的在标准输入上读取文件名,那么您可能应该使用--round-robin 和更小的--block

find data -type f | parallel --pipe --block 1k --round-robin -P 70 python program.py > output

这将从find 获取输入,并将第一个 1kByte 分配给第一个作业,将第 70 个 kByte 分配给第 70 个作业,并将第 71 个 kByte 分配给第一个作业。

【讨论】:

    猜你喜欢
    • 2019-01-21
    • 2019-03-27
    • 1970-01-01
    • 2015-11-12
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多