cluster
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
cluster [2019/03/25 10:33] – [The real life (--multi-prog)] osotolongo | cluster [2020/08/04 10:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 3: | Line 3: | ||
[[https:// | [[https:// | ||
- | El cluster (//brick//) consta de cuatro | + | El cluster (//brick//) consta de tres nodos (//brick01, brick02 y brick03//). Lo que sigue describe la operativa básica para ejecutar tareas en estas maquinas de una manera ordenada |
{{ :: | {{ :: | ||
Line 330: | Line 330: | ||
==== Hard batching ==== | ==== Hard batching ==== | ||
+ | |||
+ | [[https:// | ||
+ | |||
El procedimiento anterior funciona OK cuando se lanzan pocas tareas que consuman tiempo. Si hemos de lanzar muchas tareas rapidas lo mejor no es usar un solo //srun// con el switch // | El procedimiento anterior funciona OK cuando se lanzan pocas tareas que consuman tiempo. Si hemos de lanzar muchas tareas rapidas lo mejor no es usar un solo //srun// con el switch // | ||
+ | Ahora el // | ||
<code bash test_generator2.sh> | <code bash test_generator2.sh> | ||
#!/bin/sh | #!/bin/sh | ||
+ | #Creo los batch a ejecutar | ||
count=0 | count=0 | ||
while [ $count -lt 50 ] | while [ $count -lt 50 ] | ||
Line 339: | Line 344: | ||
cn=$((count+1)) | cn=$((count+1)) | ||
echo "# | echo "# | ||
- | echo "# | + | echo "# |
echo "# | echo "# | ||
echo "# | echo "# | ||
Line 345: | Line 350: | ||
((count++)) | ((count++)) | ||
done | done | ||
+ | #Creo un archivo que ejecute los batch | ||
+ | count=0 | ||
+ | echo "# | ||
+ | while [ $count -lt 50 ] | ||
+ | do | ||
+ | cn=$((count+1)) | ||
+ | echo " | ||
+ | ((count++)) | ||
+ | done | ||
+ | # Creo un script de aviso | ||
+ | echo "# | ||
+ | echo "# | ||
+ | echo "# | ||
+ | echo "# | ||
+ | echo "srun :" >> mailme.sh | ||
+ | echo " | ||
+ | chmod +x test.sh | ||
</ | </ | ||
+ | **Nota:** Cada proceso se ejecuta independientemente y solo envia emails en caso de fallo, para recibir un aviso cuando se termina la ejecucion es necesario crear y ejecutar un porceso que lo haga y que dependa especificamente de que todos los procesos previos terminen. La forma natural es ejecutarlo con el comando //sbatch --dependency=singleton//, | ||
+ | Vamos a probarlo, | ||
+ | <code bash> | ||
+ | [osotolongo@detritus cluster]$ ./ | ||
+ | [osotolongo@detritus cluster]$ ls | ||
+ | mailme.sh | ||
+ | test | ||
+ | test.conf | ||
+ | test_generator2.sh | ||
+ | test_generator.sh | ||
+ | [osotolongo@detritus cluster]$ cat test_run_1.sh | ||
+ | #!/bin/bash | ||
+ | #SBATCH -J test | ||
+ | #SBATCH --mail-type=FAIL, | ||
+ | #SBATCH --mail-user=osotolongo | ||
+ | srun test_runner.sh test/ | ||
+ | [osotolongo@detritus cluster]$ cat test.sh | ||
+ | #!/bin/bash | ||
+ | sbatch test_run_1.sh | ||
+ | sbatch test_run_2.sh | ||
+ | sbatch test_run_3.sh | ||
+ | sbatch test_run_4.sh | ||
+ | sbatch test_run_5.sh | ||
+ | ................... | ||
+ | sbatch test_run_50.sh | ||
+ | sbatch --dependency=singleton mailme.sh | ||
+ | |||
+ | [osotolongo@detritus cluster]$ ./ | ||
+ | Submitted batch job 15262 | ||
+ | Submitted batch job 15263 | ||
+ | Submitted batch job 15264 | ||
+ | Submitted batch job 15265 | ||
+ | Submitted batch job 15266 | ||
+ | Submitted batch job 15267 | ||
+ | Submitted batch job 15268 | ||
+ | ............... | ||
+ | |||
+ | [osotolongo@detritus cluster]$ squeue | ||
+ | JOBID PARTITION | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | .................... | ||
+ | </ | ||
+ | |||
+ | {{:: | ||
+ | |||
+ | |||
+ | ===== Paralelizando un archivo de ordenes ===== | ||
+ | |||
+ | Podemos abstraer todo esto en un script simple para paralelizar las ordenes escritas en un solo archivo. | ||
+ | |||
+ | Ejemplo, este script, | ||
+ | |||
+ | <code perl slurmize.pl> | ||
+ | # | ||
+ | use strict; | ||
+ | use warnings; | ||
+ | |||
+ | #Cambiar aqui el tiempo maximo de ejecucion | ||
+ | my $time = ' | ||
+ | |||
+ | my $ifile = $ARGV[0]; | ||
+ | my $wdir = ' | ||
+ | mkdir $wdir; | ||
+ | my $count = 0; | ||
+ | open IPDF, "< | ||
+ | while (< | ||
+ | $count++; | ||
+ | my $ofile = sprintf (" | ||
+ | $ofile = $wdir.'/' | ||
+ | open ORD, "> | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD "srun $_\n"; | ||
+ | close ORD; | ||
+ | system(" | ||
+ | } | ||
+ | close IPDF; | ||
+ | my $orderfile = $wdir.'/' | ||
+ | open ORD, "> | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD '# | ||
+ | print ORD ": | ||
+ | close ORD; | ||
+ | my $xorder = ' | ||
+ | exec($xorder); | ||
+ | </ | ||
+ | |||
+ | lee un archivo de entrada y ejecuta cada linea como una tarea de SLURM. Para esto basta hacer, | ||
+ | |||
+ | <code bash> | ||
+ | $ ./ | ||
+ | </ | ||
+ | |||
+ | donde // | ||
+ | |||
+ | ==== ejemplo ==== | ||
+ | * Las ordenes deben ejecutarse dentro del directorio /nas/ para que el sistema de archivos sea accesible a todos los nodos. | ||
+ | * Escribo las ordenes dentro de un archivo (en este caso //test//) | ||
+ | * Ejecuto el script dando como argumento el nombre del archivo de ordenes | ||
+ | * Las tareas seenvian a los nodos del cluster | ||
+ | * El output (STDOUT & STDERR) queda dentro del directorio //slurm// en un archivo distinto para cada proceso | ||
+ | * Tambien pueden mirarse los scripts individuales que quedan en el mismo directorio | ||
+ | |||
+ | |||
+ | <code bash> | ||
+ | [osotolongo@detritus slurmit]$ pwd | ||
+ | / | ||
+ | [osotolongo@detritus slurmit]$ cat test | ||
+ | sleep 2000; | ||
+ | sleep 2000; | ||
+ | sleep 2000; | ||
+ | [osotolongo@detritus slurmit]$ ./ | ||
+ | Submitted batch job 129583 | ||
+ | Submitted batch job 129584 | ||
+ | Submitted batch job 129585 | ||
+ | Submitted batch job 129586 | ||
+ | [osotolongo@detritus slurmit]$ squeue | grep test | ||
+ | 129586 | ||
+ | 129583 | ||
+ | 129584 | ||
+ | 129585 | ||
+ | [osotolongo@detritus slurmit]$ tree | ||
+ | . | ||
+ | ├── slurm | ||
+ | │ ├── sorder_0001.sh | ||
+ | │ ├── sorder_0002.sh | ||
+ | │ ├── sorder_0003.sh | ||
+ | │ ├── test-129583 | ||
+ | │ ├── test-129584 | ||
+ | │ ├── test-129585 | ||
+ | │ └── test_end.sh | ||
+ | ├── slurmize.pl | ||
+ | └── test | ||
+ | |||
+ | 1 directory, 9 files | ||
+ | |||
+ | </ | ||
+ |
cluster.1553510009.txt.gz · Last modified: 2020/08/04 10:44 (external edit)