Thanks for all the comments and answers. Here is what I did to get to my final solution:
At first, I had a bash script to submit the job to the cluster as an array of jobs, with $PBS_ARRAYID to pass different command line argument to each job:
#PBS -N ondemand/sys/myjobs/default
#PBS -l walltime=24:10:00
#PBS -l file=1gb
#PBS -l nodes=1:ppn=1:gpus=1:default
#PBS -l mem=40MB
#PBS -j oe
#PBS -A PAS0108
#PBS -o Job_array.out
# Move to the directory where the job was submitted
# run the following cmd in shell to submit the job in an array
# qsub -t 1-6 myjob.sh
cd $PBS_O_WORKDIR
cd $TMPDIR
# $PBS_ARRAYID can be used as a variable
# copy data to local storage of the node
cp ~/code/2018_9_28_training_node_6_OSC/* $TMPDIR
cp -r ~/Datasets_1/Processed/PascalContext/ResNet_Output/ $TMPDIR
cp -r ~/Datasets_1/Processed/PascalContext/Truth/ $TMPDIR
cp -r ~/Datasets_1/Processed/PascalContext/Decision_Tree/ $TMPDIR
# currently in $TMPDIR, load modules
module load python/3.6 cuda
# using $PBS_ARRAYID as a variable to pass the corresponding node ID
python train_decision_tree_node.py $PBS_ARRAYID $TMPDIR > training_log_${PBS_ARRAYID}
# saving logs
cp training_log ${HOME}/logs/${PBS_ARRAYID}_node_log/
cp my_results $PBS_O_WORKDIR
I submit the above script with command line:
qsub -t 1-6 myjob.sh
But, I got an error from the cluster, somehow the local directory $TMPDIR
can't be recognized by the actual node in the cluster when I run the script.
Finally, what I did is that I use a top level bash script to submit each job with a different command line argument in a while loop and it worked:
run_multiple_jobs.tcsh:
#!/usr/bin/env tcsh
set n = 1
while ( $n <= 5 )
echo "Submitting job for concept node $n"
qsub -v NODE=$n job.pbs
@ n++
end
jobs.pbs:
#PBS -A PAS0108
#PBS -N node_${NODE}
#PBS -l walltime=160:00:00
#PBS -l nodes=1:ppn=1:gpus=1
#PBS -l mem=5GB
#PBS -m ae
#PBS -j oe
# copy data
cp -r ~/Datasets/Processed/PascalContext/Decision_Tree $TMPDIR
cp -r ~/Datasets/Processed/PascalContext/Truth $TMPDIR
cp -r ~/Datasets/Processed/PascalContext/ResNet_Output $TMPDIR
# move to working directory
cd $PBS_O_WORKDIR
# run program
module load python/3.6 cuda/8.0.44
python train_decision_tree_node.py ${NODE} $TMPDIR $HOME
# run with run_multiple_jobs.tcsh script