简体   繁体   中英

How to run a python code with multiple inputs on a same node with slurm id?

I want to run a python program for 10 times and save different output files as output_1, output_2, output_3.....and so on. It can be run using 1 processor and 10 threads. I have access to 96 CPUs on a node, so, I want to perform all these 10 jobs in the same node.

My python code works like

python mycode.py $file_number #file_number =1,2,3,4...

I was submitting jobs like this... but it uses 7 nodes.

#!/bin/bash
#SBATCH -J v2-array              
#SBATCH -o x.out  
#SBATCH --nodes=1 
#SBATCH --ntasks-per-node=7 
#SBATCH --cpus-per-task=10

#SBATCH -t 72:00:00         
#SBATCH --mail-type=FAIL
#SBATCH --array=0-6

python mycode.py $SLURM_ARRAY_TASK_ID

But I want to perform this whole job on a same node instead of 7 nodes, how I can do this?

Remove the #SBATCH --ntasks-per-node=7 line. What you are requesting is a total of 7 jobs x 7 tasks/job x 10cpus/task = 490CPUs while it seems you only need jobs x 1 tasks/job x 10cpus/task = 70CPUs.

Furthermore, in the above example, unless mycode.py is explicitly written to interact with Slurm, it will only be able to use 10 CPUs per job (compared with 70 being allocated).

Note that all jobs in an array are independent, and there is no way to have them start on the same node for sure. They might start at different time, on different nodes, depending on the state of the queue. And if the queue is empty, it will depend on the Slurm configuration that might favour scattering of the jobs over the available nodes (this is a less-used feature, but it exists)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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