Parallel job submission of for loop
1
vote
0
answers
1090
views
I have written
loop and parallelized it with &
and limited the threshold to running
jobs at one time. Below is my script. I am reserving cores
and GB
memory through
command. The
I am running inside
loop requires
cores and GB
memory.
I am getting memory failure errors on some jobs. I think I am reserving only
cores and GB
and trying to run
jobs at a time which might be causing memory failure errors on some jobs.
My question is how do I parallelize such that all
jobs are using the same amount of cores and memory.
I submitted using the command < example.sh
#!/bin/bash
#BSUB -J cnt_job # LSF job name
#BSUB -o cnt_job.%J.out # Name of the job output file
#BSUB -e cnt_job.%J.error # Name of the job error file
#BSUB -n 32 # 32 cores
#BSUB -M 262144 # 256 GB
#BSUB -R "span[hosts=1] rusage [mem=262144]"
n=0
maxjobs=3
for sample in $main ; do
for run in $nested ; do
sample_pipe count --id="$run_name" \
--localcores=32 \
--localmem=256 &
done
cd ..
# limit jobs
if (( $(($((++n)) % $maxjobs)) == 0 )) ; then
wait # wait until all have finished
echo $n wait
fi
done
Asked by botloggy
(137 rep)
Sep 22, 2021, 02:14 PM
Last activity: Sep 22, 2021, 02:28 PM
Last activity: Sep 22, 2021, 02:28 PM