gpt4 book ai didi

bash - 在采用命令行参数的 SLURM 上运行命令

转载 作者:行者123 更新时间:2023-12-04 08:40:52 24 4
gpt4 key购买 nike

我对使用 HPC 和 SLURM 完全陌生,所以我非常感谢这里的一些指导。
我需要迭代运行一个看起来像这样的命令

kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-SRR3225412" \
"SRR3225412_1.fastq.gz" \
"SRR3225412_2.fastq.gz"
哪里 SRR3225412部分在每次互动中都会有所不同
问题是,正如我发现的那样,我不能将它附加到 sbatch 的末尾。命令
sbatch --nodes=1          \
--ntasks-per-node=1 \
--cpus-per-task=1 \
kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-SRR3225412" \
"SRR3225412_1.fastq.gz" \
"SRR3225412_2.fastq.gz"
这个命令不起作用。我收到错误
sbatch: error: This does not look like a batch script.  The first
sbatch: error: line must start with #! followed by the path to an interpreter.
sbatch: error: For instance: #!/bin/sh
我想问一下,如何运行 sbatch命令,指定其运行参数,并为 kallisto 添加命令行参数我正在尝试使用的程序?最后我想有类似的东西
#!/bin/bash

for sample in ...
do
sbatch --nodes=1 \
--ntasks-per-node=1 \
--cpus-per-task=1 \
kallistoCommandOnSample --arg1 a1 \
--arg2 a2 arg3 a3
done

最佳答案

错误 sbatch: error: This does not look like a batch script.是因为 sbatch期待提交脚本。它是一个批处理脚本,通常是一个 Bash 脚本,其中的注释以 #SBATCH 开头。 Slurm 将其解释为选项。
所以提交作业的典型方式是创建一个文件,我们将其命名为 submit.sh :

#! /bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1

kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-SRR3225412" \
"SRR3225412_1.fastq.gz" \
"SRR3225412_2.fastq.gz"
然后提交
sbatch submit.sh
如果您有多个类似的工作要提交,那么使用 job array 的几个原因是有益的。 .您要创建的循环可以替换为单个提交脚本,如下所示
#! /bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=1
#SBATCH --array=1-10 # Replace here with the number of iterations in the loop

SAMPLES=(...) # here put what you would loop over
CURRSAMPLE=${SAMPLE[$SLURM_ARRAY_TASK_ID]}
kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o "output-${CURRSAMPLE}" \
"${CURRSAMPLE}_1.fastq.gz" \
"${CURRSAMPLE}_2.fastq.gz"
正如@Carles Fenoy 所指出的,如果您不想使用提交脚本,可以使用 --wrap sbatch 的参数:
sbatch --nodes=1          \
--ntasks-per-node=1 \
--cpus-per-task=1 \
--wrap "kallisto quant -i '/home/myName/genomes/hSapien.idx' \
-o 'output-SRR3225412' \
'SRR3225412_1.fastq.gz' \
'SRR3225412_2.fastq.gz'"

关于bash - 在采用命令行参数的 SLURM 上运行命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64576282/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com