Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
documentation:examples:submit_scripts [2020/07/23 15:00] – [job parallèle] ltaulelldocumentation:examples:submit_scripts [2023/01/13 09:39] (Version actuelle) – supprimée ccalugar
Ligne 1: Ligne 1:
-====== Exemples de scripts de soumission ====== 
  
-<note warning>Certaines variables sont fantaisistes, pour vous forcer à les mettre à jour selon [[documentation:clusters:batch#les_files_d_attente|les configurations réelles des files d'attentes]].</note> 
- 
-<note tip>Many more examples scripts are available on our [[https://github.com/ltaulell/submission_scripts|github repository]]</note> 
- 
- 
-===== job parallèle ===== 
- 
-  * Soumission avec un seul script 
-  * Usage du ''/scratch glusterfs'' commun des queues ''E5-*'' 
-  * Configuration de l'environnement avec les modulefiles 
-  * Parallel Environment and ''$NSLOTS'': 
-    * OpenMP **must** match (-pe openmp8 8) 
-    * OpenMPI **must** match **or** multiple (-pe mpi8_debian 8, -pe mpi8_debian 32) 
- 
-**Le script suivant se lance avec la commande** : ''qsub parexample.sh'' 
- 
-<code bash 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 
- 
-### 
-</code> 
- 
-<code bash 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 
-</code> 
-===== job parallèle, variantes ===== 
- 
- 
-  * variante utilisant [[documentation:tools:modules|Environment Modules]] 
- 
- 
-<code bash> 
-#!/bin/bash 
-#[...] 
- 
-source /usr/share/lmod/lmod/init/bash 
-module load R/3.2.4 
- 
-#[...] 
-</code> 
- 
-  * variante du script : Appel à plusieurs queues (même cluster) 
- 
-<code bash> 
-#!/bin/bash 
-### SGE 
-#$ -q E5-2670deb64A,E5-2670deb64B,E5-2670deb64C,E5-2670deb64D,E5-2670deb64E 
-#$ -pe mpi16_debian 32 
- 
-#[...] 
-</code> 
- 
-  * variante : Appel à plusieurs queues (de clusters différents) 
- 
-<code bash> 
-#!/bin/bash 
-### SGE 
-#$ -q dl165_debian,sl390_debian,x41zlin32gb 
-#$ -pe openmp8 8 
- 
-#[...] 
-</code> 
- 
-  * variante : Retirer un node (host) des nodes autorisés 
- 
-<code bash> 
-#!/bin/bash 
-### SGE 
-#$ -q dl165_debian 
-#$ -pe openmp8 8 
-## node HS : 
-#$ -l h=!dl165lin2 
- 
-#[...] 
-</code> 
- 
-  * variante : Copie des inputs dans ''/scratch'' 
- 
-<code bash 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}/" 
-</code> 
- 
-  * variante : Vérification de l'existence du ''/scratch'' (**bash only**) 
- 
-<code bash 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; } 
- 
- 
-</code> 
- 
-  * variante : Vérification de l'existence du ''/scratch'' global (**bash only**) 
- 
-<code bash 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}" 
-</code> 
- 
- 
-  * variante : Job gaussian sur 8 coeurs ou 4 coeurs (mais réservation d'un noeud entier à 8 coeurs) 
- 
-<code bash> 
-#!/bin/bash 
-### SGE 
-#$ -q x41zlin32gb 
-#$ -pe gaussian8 8 
- 
-#[...] 
-</code> 
- 
-  * variante : Job gaussian dans le ''/scratch'' 
- 
-<code bash> 
-#!/bin/bash 
-#[...] 
- 
-cd "${SCRATCHDIR}" || { echo "cannot cd to ${SCRATCHDIR}"; exit 1; } 
-export GAUSS_SCRDIR="${SCRATCHDIR}" 
- 
-#[...] 
-</code> 
- 
- 
-  * variante : Directives particulières, 4 coeurs fixés 
- 
-<code bash> 
-#!/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" 
- 
-</code> 
- 
- 
-  * variante : Programme pseudo-parallèle, sequentiel + openmp 
- 
-<code bash> 
-#!/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 
- 
-</code> 
- 
-<note tip>Many more examples scripts are available on our [[https://github.com/ltaulell/submission_scripts|github repository]]</note> 
- 
- 
-===== Références ===== 
- 
-  * https://wiki.crc.nd.edu/w/index.php/Submitting_an_array_Job_to_SGE 
-  * https://bioinformatics.uconn.edu/resources-and-events/tutorials-2/script-array-job/ 
documentation/examples/submit_scripts.1595516439.txt.gz · Dernière modification : 2020/08/25 15:58 (modification externe)