简体   繁体   English

使用 Python 提交 Slurm 作业

[英]Submit Slurm Jobs using Python

I have foo.sh as below我有foo.sh如下

#!/bin/bash
#SBATCH -A research
#SBATCH -p long
#SBATCH --mem-per-cpu=1024
#SBATCH -N 1
#SBATCH -n 24
#SBATCH -t 2-00:00:00
#SBATCH --mail-type=END
#SBATCH --exclude=node37

module load Gaussian/09revC

export GAUSS_SCRDIR=/scratch/$USER.$SLURM_JOBID
/bin/mkdir -p $GAUSS_SCRDIR

g09 $1

/bin/rm -rf $GAUSS_SCRDIR

And I call foo.sh from another bash file called submit.sh我从另一个名为foo.sh的 bash 文件中调用submit.sh

#!/bin/bash
sbatch foo.sh 00_molecule_name_some_method.com
sbatch foo.sh 01_molecule_name_some_method.com
sbatch foo.sh 02_molecule_name_some_method.com

This submits multiple jobs.这会提交多个作业。

I want to change submit.sh to Python file which will call foo.sh provide it with argument which will go to $1 in foo.sh , Python should not wait for the jobs to get completed.我想将submit.sh更改为 Python 文件,该文件将调用foo.sh为其提供参数,该参数将 go 中的$1 foo.sh ,ZA7F5F35426B927411FC9231B56382 不应该等待作业完成。

Also molecule_name and some_method are variables which I will provide in for loop同样, molecule_namesome_method是我将在 for 循环中提供的变量

template Python script submit.py模板 Python 脚本submit.py

for molecule_name in molecules:
    for some_method in methods:
        foo.sh molecule_name some_method

I get this error:我收到此错误:

/bin/mkdir: cannot create directory ‘/scratch’: Permission denied
PGFIO/stdio: No such file or directory
PGFIO-F-/OPEN/unit=11/error code returned by host stdio - 2.
File name = /scratch/USERNAME./Gau-41212.inp
In source file ml0.f, at line number 181
PGFIO/stdio: No such file or directory
PGFIO-F-/OPEN/unit=11/error code returned by host stdio - 2.
File name = /scratch/USERNAME./Gau-41213.inp
In source file ml0.f, at line number 181

Use Subprocess使用子流程

import subprocess
for molecule_name in molecules:
    for some_method in methods:
        command1 = subprocess.Popen(['foo.sh', molecule_name, some_method])

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

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