简体   繁体   English

在具有 SLURM 的 HPC 系统上使用 GNU Parallel 运行具有两个输入文件的 python 文件的多个实例

[英]Running multiple instances of a python file with two input files using GNU Parallel on an HPC system with SLURM

I try to run a single python file 240 times in parallel (since each individual file run takes about 9 min) on an HPC-system.我尝试在 HPC 系统上并行运行单个 python 文件 240 次(因为每个单独的文件运行大约需要 9 分钟)。 Ideally each python file should run on a single core.理想情况下,每个 python 文件都应在单个内核上运行。 There are 24 cores per node.每个节点有 24 个核心。 The python file takes two input files, one from each set: python 文件采用两个输入文件,每组一个:

  • CN_ONLY0.pdb up to CN_ONLY239.pdb CN_ONLY0.pdbCN_ONLY239.pdb
  • I_ONLY0.pdb up to I_ONLY239.pdb . I_ONLY0.pdbI_ONLY239.pdb

When I run the below posted code:当我运行以下发布的代码时:

parallel="parallel --delay .2         \
                    -j $SLURM_NTASKS   \
                   --joblog runtask.log \
                   --resume              \
                   --max-args=2"

srun="srun --exclusive -N1 -n1 --cpus-per-task=1 --cpu-bind=cores"

find . -type f \( -name "CN_ONLY*.pdb" -o -name "I_ONLY*.pdb" \) |
        sort -t Y -k 2 -g     |
        TMPDIR=$SLURM_SCRATCH \
        $parallel python python_test.py

It runs the Python program correctly, but does not distribute the program to all the different requested CPUs.它正确运行 Python 程序,但不会将程序分发到所有不同的请求 CPU。

Does anyone know how to fix this problem?有谁知道如何解决这个问题?

There is no need to use GNU parallel when SLURM itself proivdes that functionality via array jobs (or job arrays).当 SLURM 本身通过数组作业(或作业数组)提供该功能时,无需使用 GNU 并行。 Simply add --array=1-240 to the srun command and then submit the following script:只需将--array=1-240添加到srun命令,然后提交以下脚本:

#!/bin/sh

id=$(expr ${SLURM_ARRAY_TASK_ID} - 1)
python python_test.py CN_ONLY${id}.pdb I_ONLY${id}.pdb

What happens is that SLURM will launch this script 240 times and set the value of SLURM_ARRAY_TASK_ID to a different value in each of them, ranging from 1 to 240. It is then trivial to subtract one from this value and use it to generate the names of the script arguments.发生的情况是 SLURM 将启动此脚本 240 次,并将SLURM_ARRAY_TASK_ID的值设置为每个不同的值,范围从 1 到 240。然后从该值中减去一个并使用它来生成名称脚本 arguments。

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

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