Ceci est une ancienne révision du document !


Exemples de scripts de soumission

Certaines variables sont fantaisistes, pour vous forcer à les mettre à jour selon les configurations réelles des files d'attentes.
Many more examples scripts are available on our github repository

job parallèle

  • Soumission avec un seul script
  • Usage du /scratch glusterfs commun des queues E5-*
  • Configuration de l'environnement avec les modulefiles

Le script suivant se lance avec la commande : qsub parexample.sh

parexample.sh
#!/bin/bash
### variables SGE
### shell du job
#$ -S /bin/bash
### nom du job (a changer)
#$ -N testbash
### file d'attente (a changer)
#$ -q E5_test
### parallel environnement & nslots (a changer)
#$ -pe mpi8_debian 8
### charger l'environnement utilisateur pour SGE
#$ -cwd
### exporte les variables d'environnement sur tous les noeuds d'exécution
#$ -V
### mails en debut et fin d'execution
#$ -m b
#$ -m e
 
 
### sinon SGE travaille dans ~/
cd "${SGE_O_WORKDIR}" || { echo "cannot cd to ${SGE_O_WORKDIR}"; exit 1; }
 
### environment modules
source /usr/share/lmod/lmod/init/bash
module load GCC/7.2.0/OpenMPI/3.0.0/HISAT2/2.1.0
 
### definition SCRATCHDIR
SCRATCH="/scratch/E5N"
SCRATCHDIR=${SGE_O_WORKDIR/"${HOME}"/"${SCRATCH}"}
### verif SCRATCHDIR
echo "SCRATCHDIR=${SCRATCHDIR}"
 
BINDIR="/applis/PSMN/generic/PhyloMerge/0.2/"
EXEC="phylomerge"
 
### PREFIX doit matcher le modele openmpi (ligne 18)
PREFIX="/applis/PSMN/debian9/software/Compiler/GCC/7.2.0/OpenMPI/3.0.0"
MPIRUN="${PREFIX}/bin/mpirun"
### necessaire si plusieurs noeuds
### HOSTFILE=${TMPDIR}/machines
 
### creation du repertoire de travail dans le /scratch
if [[ ! -d "${SCRATCHDIR}" ]] 
then
  /bin/mkdir -p "${SCRATCHDIR}"
fi
 
 
### copie des fichiers input dans le /scratch
for FICHIER in INPUT.hdf5 MATHRICE cube3x3
do
  cp -- "${FICHIER}" "${SCRATCHDIR}/"
done
 
### nettoyage d'eventuels fichiers resultat indesirable AVANT le 
### lancement du programme, si necessaire
for FICHIER in OUTPUT.hdf5 mathrice.o
do
  if [[ -e "${SCRATCHDIR}/${FICHIER}" ]]
  then
    /bin/rm -f "${SCRATCHDIR}/${FICHIER}"
  fi
done
 
### hostfile SGE si repartition sur plusieurs noeuds
### ${TMPDIR}/machines est généré par SGE
/bin/cat "${TMPDIR}/machines" >> "${HOMEDIR}/tmp"
/bin/rm -f "${HOMEDIR}/Master"
Master=$(/usr/bin/head -1 "${TMPDIR}/machines")
/bin/echo "${Master}" >> "${HOMEDIR}/Master"
 
### se placer dans le repertoire d'execution AVANT le lancement du programme
cd "${SCRATCHDIR}" || { echo "cannot cd to ${SCRATCHDIR}"; exit 1; }
 
##${MPIRUN} -prefix ${PREFIX} -mca btl sm,openib,self -np ${NSLOTS} ${BINDIR}/${EXEC} > ${SCRATCHDIR}/out
"${MPIRUN}" -prefix "${PREFIX}" -mca btl vader,openib,self -np "${NSLOTS}" "${BINDIR}/${EXEC}" > "${SCRATCHDIR}/out"
 
### recuperation des resultats à la fin du calcul
for FICHIER in OUTPUT.hdf5 mathrice.o
do
  cp -- "${SCRATCHDIR}/${FICHIER}" "${HOMEDIR}/"
done
 
###
test_scratch.sh
#!/bin/bash
#
### variables SGE
### shell du job
#$ -S /bin/bash
### nom du job (a changer)
#$ -N test1
### file d'attente (a changer)
#$ -q E5_test
### charger l'environnement utilisateur pour SGE
#$ -cwd
### exporter les variables d'environnement sur tous les noeuds d'execution
#$ -V
### mails en debut et fin d'execution
#$ -m b
#$ -m e
 
# aller dans le repertoire de travail/soumission
# important, sinon, le programme est lancé depuis ~/
cd "${SGE_O_WORKDIR}" || { echo "cannot cd to ${SGE_O_WORKDIR}"; exit 1; }
 
### configurer l'environnement
source /usr/share/lmod/lmod/init/bash
module load IntelComp/15.0.2
 
### definition SCRATCHDIR
#SCRATCH="/scratch/E5N"
#SCRATCHDIR=${SGE_O_WORKDIR/"${HOME}"/"${SCRATCH}"}
SCRATCHDIR="/scratch/Lake/${USER}/testpourscratch"
### verif SCRATCHDIR
echo "SCRATCHDIR=${SCRATCHDIR}"
 
### creation du repertoire de travail dans le /scratch
if [[ ! -d "${SCRATCHDIR}" ]] 
then
   /bin/mkdir -p "${SCRATCHDIR}"
else
   if [[ "${SCRATCHDIR}" =~ scratch ]]
   then
   # cette commande est DANGEREUSE !
   #  /bin/rm -rf ${SCRATCHDIR}/
     /bin/mkdir -p "${SCRATCHDIR}"
   fi
fi
 
### copie des fichiers sources dans le /scratch
/bin/cp -- "${HOMEDIR}/*" "${SCRATCHDIR}/"
 
### se placer dans le repertoire d'execution AVANT le lancement du programme
cd "${SCRATCHDIR}" || { echo "cannot cd to ${SCRATCHDIR}"; exit 1; }
 
### execution du programme
##EXECDIR=${HOME}/Formations/Sequentiel
##${EXECDIR}/aggregate_infinite.exe < Monfichierdedata > monfichierresultat
./test1.exe
 
### recuperation des resultats à la fin du calcul
/bin/cp -- "${SCRATCHDIR}/*" "${HOMEDIR}/"
 
### delete le dossier sur /scratch
if [[ "${SCRATCHDIR}" =~ scratch ]]
then
  /bin/rm -rf "${SCRATCHDIR}"
fi
 
###
# fin

job parallèle, variantes

#!/bin/bash
#[...]
 
source /usr/share/lmod/lmod/init/bash
module load R/3.2.4
 
#[...]
  • variante du script : Appel à plusieurs queues (même cluster)
#!/bin/bash
### SGE
#$ -q E5-2670deb64A,E5-2670deb64B,E5-2670deb64C,E5-2670deb64D,E5-2670deb64E
#$ -pe mpi16_debian 32
 
#[...]
  • variante : Appel à plusieurs queues (de clusters différents)
#!/bin/bash
### SGE
#$ -q dl165_debian,sl390_debian,x41zlin32gb
#$ -pe openmp8 8
 
#[...]
  • variante : Retirer un node (host) des nodes autorisés
#!/bin/bash
### SGE
#$ -q dl165_debian
#$ -pe openmp8 8
## node HS :
#$ -l h=!dl165lin2
 
#[...]
  • variante : Copie des inputs dans /scratch
var1_copy_inputs.sh
#!/bin/bash
#[...]
 
# Copy input from home to scratch (pick bash or tcsh version)
cd "${SGE_O_WORKDIR}" || { echo "cannot cd to ${SGE_O_WORKDIR}"; exit 1; }
 
# for bash:
SCRATCH="/scratch/Bio"
SCRATCHDIR=${SGE_O_WORKDIR/"${HOME}"/"${SCRATCH}"}
 
/bin/mkdir -p "${SCRATCHDIR}"
 
# you only can know what $INPUT is
/bin/cp -rf -- "${INPUT}" "${SCRATCHDIR}/"
 
# go to scratch (instead of workdir) before running binary
cd "${SCRATCHDIR}" || { echo "cannot cd to ${SCRATCHDIR}"; exit 1; }
 
# run whatever binary
whatever < "${INPUT}" > "${OUTPUT}"
 
# copy results from scratch to home
/bin/cp -r -- "${SCRATCHDIR}/${OUTPUT}" "${SGE_O_WORKDIR}/"
  • variante : Vérification de l'existence du /scratch (bash only)
var1_scratch_exist.sh
#!/bin/bash
#[...]
 
cd "${SGE_O_WORKDIR}" || { echo "cannot cd to ${SGE_O_WORKDIR}"; exit 1; }
 
# for bash:
SCRATCH="/scratch/E5N"
SCRATCHDIR=${SGE_O_WORKDIR/"${HOME}"/"${SCRATCH}"}
 
if [[ -d "/scratch" ]]
then
  mkdir -p "${SCRATCHDIR}"
else
  echo "/scratch not found, cannot create ${SCRATCHDIR}"
  exit 1
fi
 
/bin/cp -rf "${INPUT}" "${SCRATCHDIR}/"
 
# go to scratch (instead of workdir) before running binary
cd "${SCRATCHDIR}" || { echo "cannot cd to ${SCRATCHDIR}"; exit 1; }
  • variante : Vérification de l'existence du /scratch global (bash only)
var1_create_scratch.sh
#!/bin/bash
### creation avec verification scratch global
### avoid bash substitution
### SCRATCHDIR=${SGE_O_WORKDIR/"${HOME}"/"${SCRATCH}"}
 
if [[ -d "/scratch/Lake" ]]
then
    SCRATCHDIR="/scratch/Lake/${USER}/${JOB_ID}/"
elif [[ -d "/scratch/E5N" ]]
then
    SCRATCHDIR="/scratch/E5N/${USER}/${JOB_ID}/"
elif [[ -d "/scratch/X5" ]]
then
    SCRATCHDIR="/scratch/X5/${USER}/${JOB_ID}/"
else
    echo "/scratch not found, cannot create ${SCRATCHDIR}, fall back to current directory"
    SCRATCHDIR="${SGE_O_WORKDIR}/scratch/"
fi
mkdir -p "${SCRATCHDIR}"
  • variante : Job gaussian sur 8 coeurs ou 4 coeurs (mais réservation d'un noeud entier à 8 coeurs)
#!/bin/bash
### SGE
#$ -q x41zlin32gb
#$ -pe gaussian8 8
 
#[...]
  • variante : Job gaussian dans le /scratch
#!/bin/bash
#[...]
 
cd "${SCRATCHDIR}" || { echo "cannot cd to ${SCRATCHDIR}"; exit 1; }
export GAUSS_SCRDIR="${SCRATCHDIR}"
 
#[...]
  • variante : Directives particulières, 4 coeurs fixés
#!/bin/bash
### SGE
#$ -q sl390lin48
#$ -pe gaussian8 8
#$ -cwd
#$ -V
#
NPERSOCKET="4"
#
"${MPIRUN}" -prefix "${PREFIX}" -mca btl vader,openib,self -npersocket "${NPERSOCKET}" -bycore -bind-to-core -report-bindings -np "${NSLOTS}" "${EXECDIR}/MonProgrammeOpenmpi"
  • variante : Programme pseudo-parallèle, sequentiel + openmp
#!/bin/bash
### variables SGE
HOMEDIR="${SGE_O_WORKDIR}"
### shell du job:
#$ -S /bin/bash
### nom du job:
#$ -N testbash
### file d'attente:
#$ -q monoamddeb25
### parallel environnement & nslots
#$ -pe openmp8 8
### charger l'environnement utilisateur pour SGE
#$ -cwd
### exporte les variables d'environnement sur tous les noeuds d'exécution
#$ -V
 
#[...]
 
# Variables pour OPENMP
#export OMP_NUM_THREADS="8"
export OMP_NUM_THREADS=${NSLOTS}
 
 
"${EXEC_DIR}"/run_RSEM.pl --transcripts "${TRINITY}" --name_sorted_bam "${file}" --paired --group_by_component
Many more examples scripts are available on our github repository

Références

documentation/examples/submit_scripts.1595494224.txt.gz · Dernière modification : 2020/08/25 15:58 (modification externe)