Unimore HPC Wiki

LYRALOGIN · Sottomissione job

Esempi di job Slurm con sbatch - LYRALOGIN

Introduzione

sbatch invia a Slurm uno script batch. Gli esempi seguenti sono costruiti sulle partizioni e QoS LYRALOGIN fornite.

Adattare sempre CPU, memoria, tempo, account e QoS alle autorizzazioni del proprio utente. Una QoS deve essere compatibile con la partizione scelta.

Job CPU standard su s3par

La partizione s3par ammette le QoS normal e long. La QoS normal ha MaxWall=2-00:00:00.

#!/bin/bash -l
#SBATCH --job-name=cpu_normal
#SBATCH --partition=s3par
#SBATCH --qos=normal
#SBATCH --time=01:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4

hostname
srun ./programma

Invio:

sbatch job_cpu.sh

Job CPU lungo su s3par

La QoS long ha MaxWall=4-00:00:00.

#!/bin/bash -l
#SBATCH --job-name=cpu_long
#SBATCH --partition=s3par
#SBATCH --qos=long
#SBATCH --time=3-00:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8

srun ./programma

Job sulla partizione long

La partizione long comprende node[01-08] e ammette normal,long.

#!/bin/bash -l
#SBATCH --job-name=long_partition
#SBATCH --partition=long
#SBATCH --qos=long
#SBATCH --time=2-00:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16

srun ./programma

Job sulla partizione larma

larma utilizza farnode4, ammette l'account abg e la QoS larma.

#!/bin/bash -l
#SBATCH --job-name=larma_job
#SBATCH --partition=larma
#SBATCH --qos=larma
#SBATCH --account=abg
#SBATCH --time=01:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4

srun ./programma

Job A100 su fluidp_dgx

fpdgx1 dispone di 8 NVIDIA A100 PCIe 40 GB. La QoS fp_a100 ha MaxTRES=gres/gpu=8 e GrpTRES=gres/gpu=8.

#!/bin/bash -l
#SBATCH --job-name=a100_job
#SBATCH --partition=fluidp_dgx
#SBATCH --qos=fp_a100
#SBATCH --gres=gpu:a100:1
#SBATCH --time=01:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8

nvidia-smi
srun ./programma_gpu

A100 guest

fp_a100_guest ha MaxWall=1-00:00:00.

#!/bin/bash -l
#SBATCH --job-name=a100_guest
#SBATCH --partition=fluidp_dgx
#SBATCH --qos=fp_a100_guest
#SBATCH --gres=gpu:a100:1
#SBATCH --time=04:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8

srun ./programma_gpu

Job H100 con QoS 4h100

4h100 permette per job fino a cpu=96,gres/gpu=4,mem=804G, con walltime massimo di 12 ore.

#!/bin/bash -l
#SBATCH --job-name=h100_4gpu
#SBATCH --partition=gpuh100
#SBATCH --qos=4h100
#SBATCH --gres=gpu:h100:4
#SBATCH --cpus-per-task=96
#SBATCH --mem=804G
#SBATCH --time=12:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1

nvidia-smi
srun ./programma_gpu

Job H100 completo con QoS 8h100

8h100 permette per job fino a cpu=192,gres/gpu=8,mem=1400G, con walltime massimo di 12 ore.

#!/bin/bash -l
#SBATCH --job-name=h100_8gpu
#SBATCH --partition=gpuh100
#SBATCH --qos=8h100
#SBATCH --gres=gpu:h100:8
#SBATCH --cpus-per-task=192
#SBATCH --mem=1400G
#SBATCH --time=12:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1

nvidia-smi
srun ./programma_gpu

Job H100 da una GPU

Le QoS emperorh100, lph100, phyh100 e qewh100 hanno MaxTRES=cpu=24,gres/gpu=1,mem=201G.

Esempio con lph100:

#!/bin/bash -l
#SBATCH --job-name=h100_single
#SBATCH --partition=gpuh100
#SBATCH --qos=lph100
#SBATCH --gres=gpu:h100:1
#SBATCH --cpus-per-task=24
#SBATCH --mem=201G
#SBATCH --time=01:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1

srun ./programma_gpu

Monitoraggio

squeue -u $USER
scontrol show job <jobid>
scancel <jobid>

Esempi MPI generici

LYRALOGIN espone tramite Slurm i plugin MPI pmix, pmi2, cray_shasta e none. L'esempio seguente usa pmix; il programma MPI deve essere stato compilato con un'implementazione MPI compatibile con l'ambiente disponibile sul cluster.

MPI multinodo con sbatch

Esempio generico su due nodi della partizione s3par:

#!/bin/bash -l
#SBATCH --job-name=mpi_test
#SBATCH --partition=s3par
#SBATCH --qos=normal
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=4
#SBATCH --time=01:00:00

# Caricare qui il modulo MPI utilizzato per compilare il programma.
# Esempio generico:
# module load <modulo_mpi>

srun --mpi=pmix ./programma_mpi

MPI + OpenMP

Esempio generico sui nodi LYRALOGIN da 40 core: 4 processi MPI per nodo e 10 thread per processo.

#!/bin/bash -l
#SBATCH --job-name=mpi_openmp
#SBATCH --partition=s3par
#SBATCH --qos=normal
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=4
#SBATCH --cpus-per-task=10
#SBATCH --time=01:00:00

export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK

srun --mpi=pmix ./programma_mpi_openmp

Su ciascun nodo, la richiesta corrisponde a 4 x 10 = 40 CPU Slurm.

MPI con pmi2

Se l'implementazione MPI utilizzata è compatibile con PMI2:

srun --mpi=pmi2 ./programma_mpi

Esempi di job Slurm interattivi con srun - LYRALOGIN

Introduzione

srun può essere utilizzato per richiedere risorse e avviare direttamente un comando o una shell sotto il controllo di Slurm.

Gli esempi rispettano i limiti esplicitamente forniti per partizioni e QoS. Account e QoS devono comunque essere autorizzati per il proprio utente.

Shell interattiva CPU su s3par

srun --partition=s3par --qos=normal --time=01:00:00 --nodes=1 --ntasks=1 --cpus-per-task=4 --pty bash -l

Job CPU lungo

srun --partition=s3par --qos=long --time=3-00:00:00 --nodes=1 --ntasks=1 --cpus-per-task=8 --pty bash -l

Shell sulla partizione long

srun --partition=long --qos=long --time=02:00:00 --nodes=1 --ntasks=1 --cpus-per-task=16 --pty bash -l

Partizione larma

srun --partition=larma --qos=larma --account=abg --time=01:00:00 --nodes=1 --ntasks=1 --cpus-per-task=4 --pty bash -l

Sessione A100

Il nodo fpdgx1 espone gpu:a100:8.

srun --partition=fluidp_dgx --qos=fp_a100 --gres=gpu:a100:1 --time=01:00:00 --nodes=1 --ntasks=1 --cpus-per-task=8 --pty bash -l

Dopo l'allocazione:

nvidia-smi

Sessione A100 guest

La QoS fp_a100_guest ha walltime massimo di un giorno.

srun --partition=fluidp_dgx --qos=fp_a100_guest --gres=gpu:a100:1 --time=04:00:00 --nodes=1 --ntasks=1 --cpus-per-task=8 --pty bash -l

Sessione H100 con 4h100

Esempio entro i limiti della QoS, senza richiedere necessariamente il massimo disponibile:

srun --partition=gpuh100 --qos=4h100 --gres=gpu:h100:1 --cpus-per-task=24 --mem=201G --time=02:00:00 --nodes=1 --ntasks=1 --pty bash -l

Sessione H100 con quattro GPU

srun --partition=gpuh100 --qos=4h100 --gres=gpu:h100:4 --cpus-per-task=96 --mem=804G --time=12:00:00 --nodes=1 --ntasks=1 --pty bash -l

Sessione H100 con 8h100

srun --partition=gpuh100 --qos=8h100 --gres=gpu:h100:8 --cpus-per-task=192 --mem=1400G --time=12:00:00 --nodes=1 --ntasks=1 --pty bash -l

QoS H100 da una GPU

Esempio con lph100, il cui MaxTRES è cpu=24,gres/gpu=1,mem=201G:

srun --partition=gpuh100 --qos=lph100 --gres=gpu:h100:1 --cpus-per-task=24 --mem=201G --time=01:00:00 --nodes=1 --ntasks=1 --pty bash -l

Avviare direttamente un programma

srun --partition=s3par --qos=normal --time=01:00:00 --cpus-per-task=4 ./programma

Per una GPU A100:

srun --partition=fluidp_dgx --qos=fp_a100 --gres=gpu:a100:1 --time=01:00:00 ./programma_gpu

Esempi MPI generici con srun

LYRALOGIN rende disponibili i plugin Slurm MPI pmix, pmi2, cray_shasta e none.

MPI su due nodi

srun --partition=s3par --qos=normal --nodes=2 --ntasks-per-node=4 --time=01:00:00 --mpi=pmix ./programma_mpi

MPI + OpenMP

Sui nodi s3par da 40 core, un esempio bilanciato è 4 task MPI per nodo con 10 CPU per task:

export OMP_NUM_THREADS=10
srun --partition=s3par --qos=normal --nodes=2 --ntasks-per-node=4 --cpus-per-task=10 --time=01:00:00 --mpi=pmix ./programma_mpi_openmp

Alternativa PMI2

srun --partition=s3par --qos=normal --nodes=2 --ntasks-per-node=4 --time=01:00:00 --mpi=pmi2 ./programma_mpi

La scelta tra pmix e pmi2 deve essere coerente con l'implementazione MPI con cui il programma è stato compilato.