简体   繁体   English

如何在具有 slurm id 的同一节点上运行具有多个输入的 python 代码?

[英]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.我想运行一个 python 程序 10 次,并将不同的 output 文件保存为 output_1、output_2、output_3 ......等等。 It can be run using 1 processor and 10 threads.它可以使用 1 个处理器和 10 个线程运行。 I have access to 96 CPUs on a node, so, I want to perform all these 10 jobs in the same node.我可以访问一个节点上的 96 个 CPU,因此,我想在同一个节点上执行所有这 10 个作业。

My python code works like我的 python 代码的工作方式类似于

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

I was submitting jobs like this... but it uses 7 nodes.我正在提交这样的工作......但它使用 7 个节点。

#!/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?但是我想在同一个节点而不是 7 个节点上执行整个工作,我该怎么做?

Remove the #SBATCH --ntasks-per-node=7 line.删除#SBATCH --ntasks-per-node=7行。 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.您要求的是总共 7 个作业 x 7 个任务/作业 x 10cpus/任务 = 490CPU,而您似乎只需要作业 x 1 个任务/作业 x 10cpus/任务 = 70CPU。

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).此外,在上面的示例中,除非mycode.py被明确编写为与 Slurm 交互,否则每个作业只能使用 10 个 CPU(相比之下,分配了 70 个)。

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.它们可能在不同的时间、不同的节点上开始,具体取决于队列的 state。 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)如果队列为空,它将取决于可能有利于将作业分散到可用节点上的 Slurm 配置(这是一个较少使用的功能,但它存在)

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

相关问题 如何在 Python 中运行多个输入? - How to run multiple inputs in Python? 为什么我不能在SLURM中同时运行同一个python脚本的多个实例 - Why can't I run multiple instances of the same python script simulataniously in SLURM 如何为大输入运行 python 代码 - How to run a python code for large inputs 如何在集群中通过 slurm 运行 python 脚本? - How to run a python script through slurm in a cluster? SLURM:如何为目录中的不同 $arg 并行运行相同的 python 脚本 - SLURM: how to run the same python script for different $arg from a catalogue in parallel 如何为多个输入文件运行相同的 python 代码 - How to run the same python code for multiple input files SLURM和python,节点已分配,但代码仅在一个节点上运行 - SLURM and python, nodes are allocated, but the code only runs on one node 为多个文件运行相同的代码 Python - Run the Same Code for Multiple Files Python 如何修改我的代码,以便我可以在 Python 中同时搜索多个输入(来自同一列) - How to I modify my code so I can search for multiple inputs(from the same column) at the same time in Python 如何在Slurm集群上的多个节点上运行MPI Python脚本? 错误:警告:无法在2个节点上运行1个进程,将nnode设置为1 - How To Run MPI Python Script across multiple nodes on Slurm cluster? Error: Warning: can't run 1 processes on 2 nodes, setting nnodes to 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM