提交python程序到集群运行,在HPC集群上使用python代码(mpi4py)提交作业

I am working a python code with MPI (mpi4py) and I want to implement my code across many nodes (each node has 16 processors) in a queue in a HPC cluster.

My code is structured as below:

from mpi4py import MPI

comm = MPI.COMM_WORLD

size = comm.Get_size()

rank = comm.Get_rank()

count = 0

for i in range(1, size):

if rank == i:

for j in range(5):

res = some_function(some_argument)

comm.send(res, dest=0, tag=count)

I am able to run this code perfectly fine on the head node of the cluster using the command

$mpirun -np 48 python codename.py

Here "code" is the name of the python script and in the given example, I am choosing 48 processors. On the head node, for my specific task, the job takes about 1 second to finish (and it successfully gives the desired output).

However, when I run try to submit this same exact code as a job on one of the queues of the HPC cluster, it keeps running for a very long time (many hours) (doesn't finish) and I have to manually kill the job after a day or so. Also, it doesn't give the expected output.

Here is the pbs file that I am using,

#!/bin/sh

#PBS -l nodes=3:ppn=16

#PBS -N phy

#PBS -m abe

#PBS -l walltime=23:00:00

#PBS -j eo

#PBS -q queue_name

cd $PBS_O_WORKDIR

echo 'This job started on: ' `date`

module load python27-extras

mpirun -np 48 python codename.py

I use the command qsub jobname.pbs to submit the job.

I am confused as to why the code should run perfectly fine on the head node, but run into this problem when I submit this job to run the code across many processors in a queue. I am presuming that I may need to change the pbs script. I will be really thankful if someone can suggest what I should do to run such a MPI script as a job on a queue in a HPC cluster.

解决方案

Didn't need to change my code. This is the pbs script that worked. =)

Apparently, I needed to call the appropriate mpirun in the job script, so that when the code runs in the clusters, it uses the same mpirun as that was being used in head node.

This is the line which made the difference: /opt/intel/impi/4.1.1.036/intel64/bin/mpirun

This is the job script which worked.

#!/bin/sh

#PBS -l nodes=3:ppn=16

#PBS -N phy

#PBS -m abe

#PBS -l walltime=23:00:00

#PBS -j eo

#PBS -q queue_name

cd $PBS_O_WORKDIR

export OMP_NUM_THREADS=16

export I_MPI_PIN=off

echo 'This job started on: ' `date`

/opt/intel/impi/4.1.1.036/intel64/bin/mpirun -np 48 python codename.py

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值