본문 바로가기
HPC

[SLURM] SBATCH(2)

by Yoon_estar 2024. 9. 9.
728x90
반응형

기타 SBATCH 옵션

  • Dependency Job 수행 방법
#SBATCH --error=파일이름
#SBATCH --mail-type=ALL
#SBATCH --mail-user=이메일 주소
#SBATCH --cpu-per-task=쓰레드 수 
#SBATCH --mem=메모리 크기 // --mem, --mem-per-cpu는 중복 불가, 노드 설정에 RealMemory=8080(M) 부분 반영 필요
#SBATCH --mem-per-cpu=메모리 크기
#SBATCH --gres=gpu:개수
#SBATCH --time=HH:MM:SS
#SBATCH --begin=시작시간
#SBATCH --partition=파티션이름
#SBATCH --qos=QOS 이름
#SBATCH --nodelist=노드 리스트
#SBATCH --exclude=노드 리스트
#SBATCH --get-user-env
#SBATCH --export=ALL
#SBATCH --test-only
#SBATCH --array=0-9
#SBATCH --priority=우선순위
#SBATCH --requeue
#SBATCH --exclusive ##독점 모드
#SBATCH --account
#SBATCH --dependency=[after|afterany|afterok|afternotok:<jobid>] 이전작업에 종속성을 설정

예시 작업(1)

$ cat dep_job_01.sbatch
#!/bin/bash
#SBATCH --job-name=dep_job_01
#SBATCH --ntasks=1
#SBATCH --output=dep_job_01.out
#SBATCH --partition=cpu.q
#SBATCH --get-user-env

# Run your command
sleep 60

$ sbatch dep_job_01.sbatch

$ squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
                12     cpu.q dep_job_ estar987  R       0:04      1 slurm91

예시 작업(2)

  • 파티션 두 개 동시 설정
$ cat dep_job_011.sbatch
#!/bin/bash
#SBATCH --job-name=dep_job_01
#SBATCH --ntasks=1
#SBATCH --output=dep_job_01.out
#SBATCH --partition=cpu.q,docker.q
#SBATCH --get-user-env
# Run your command
sleep 60

$ sbatch dep_job_01.sbatch

$ squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
                13     cpu.q dep_job_ estar987  R       0:03      1 slurm91

예시 작업(3)

  • 이전 작업에 종속성을 설정
$ sbatch --dependency=afterok:2016 dep_job_011.sbatch
Submitted batch job 14
$ sbatch --dependency=afterok:2017 dep_job_011.sbatch
Submitted batch job 15
$ sbatch --dependency=afterok:2018 dep_job_011.sbatch
Submitted batch job 16
$ sbatch --dependency=afterok:2019 dep_job_011.sbatch
Submitted batch job 17
$ sbatch --dependency=afterok:2020 dep_job_011.sbatch
Submitted batch job 18
$ squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
                14     cpu.q dep_job_ estar987  R       0:18      1 slurm91
                15     cpu.q dep_job_ estar987  R       0:12      1 slurm92
                16     cpu.q dep_job_ estar987  R       0:09      1 slurm91
                17     cpu.q dep_job_ estar987  R       0:06      1 slurm92
                18     cpu.q dep_job_ estar987  R       0:03      1 slurm91

예시 작업(4)

  • Array Job 수행 방법
$ cat array_job.01.sbatch
#!/bin/bash
#SBATCH --job-name=array_job_01
#SBATCH --ntasks=1
#SBATCH --output=array_job_01_%A_%a.out
#SBATCH --partition=docker.q
#SBATCH --get-user-env
#SBATCH --array=1-10
#SBATCH --account=prj_estar987

# Run your command
sleep 5
echo "Array Task ID: $SLURM_ARRAY_TASK_ID"

$ sbatch array_job.01.sbatch

$ squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
              29_1  docker.q array_jo estar987  R       0:12      1 docker95
              29_2  docker.q array_jo estar987  R       0:12      1 docker96
              29_3  docker.q array_jo estar987  R       0:12      1 docker95
              29_4  docker.q array_jo estar987  R       0:12      1 docker96
              29_5  docker.q array_jo estar987  R       0:12      1 docker95
              29_6  docker.q array_jo estar987  R       0:12      1 docker96
              29_7  docker.q array_jo estar987  R       0:12      1 docker95
              29_8  docker.q array_jo estar987  R       0:12      1 docker96
              29_9  docker.q array_jo estar987  R       0:12      1 docker95
              
$ ls -1 array_job_01*.out
array_job_01_29_10.out
array_job_01_29_1.out
array_job_01_29_2.out
array_job_01_29_3.out
array_job_01_29_4.out
array_job_01_29_5.out
array_job_01_29_6.out
array_job_01_29_7.out
array_job_01_29_8.out
array_job_01_29_9.out
array_job_01_40_10.out
array_job_01_40_1.out
array_job_01_40_2.out
array_job_01_40_3.out
array_job_01_40_4.out
array_job_01_40_5.out
array_job_01_40_6.out
array_job_01_40_7.out
array_job_01_40_8.out
array_job_01_40_9.out

$ cat array_job_01_40_4.out
Array Task ID: 4
  • array 구문 활용 예시
#!/bin/bash
#SBATCH --job-name=array_job_01
#SBATCH --ntasks=1
#SBATCH --output=array_job_01_%A_%a.out
#SBATCH --partition=docker.q
#SBATCH --get-user-env
#SBATCH --array=1,3,5,7,9      //  수정
#SBATCH --account=prj_estar987

# Run your command
sleep 5
echo "Array Task ID: $SLURM_ARRAY_TASK_ID"

$ squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
              50_1  docker.q array_jo estar987  R       0:03      1 docker95
              50_3  docker.q array_jo estar987  R       0:03      1 docker96
              50_5  docker.q array_jo estar987  R       0:03      1 docker95
              50_7  docker.q array_jo estar987  R       0:03      1 docker96
              50_9  docker.q array_jo estar987  R       0:03      1 docker95
#!/bin/bash
#SBATCH --job-name=array_job_01
#SBATCH --ntasks=1
#SBATCH --output=array_job_01_%A_%a.out
#SBATCH --partition=docker.q
#SBATCH --get-user-env
#SBATCH --array=1-20:2
#SBATCH --account=prj_estar987

# Run your command
sleep 5
echo "Array Task ID: $SLURM_ARRAY_TASK_ID"

$ squeue
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
              65_1  docker.q array_jo estar987  R       0:02      1 docker95
              65_3  docker.q array_jo estar987  R       0:02      1 docker96
              65_5  docker.q array_jo estar987  R       0:02      1 docker95
              65_7  docker.q array_jo estar987  R       0:02      1 docker96
              65_9  docker.q array_jo estar987  R       0:02      1 docker95
             65_11  docker.q array_jo estar987  R       0:02      1 docker96
             65_13  docker.q array_jo estar987  R       0:02      1 docker95
             65_15  docker.q array_jo estar987  R       0:02      1 docker96
             65_17  docker.q array_jo estar987  R       0:02      1 docker95
             65_19  docker.q array_jo estar987  R       0:02      1 docker96
반응형

'HPC' 카테고리의 다른 글

Singularity  (0) 2024.11.25
[Linux] ANSYS 소프트웨어 설치  (0) 2024.11.18
[SLURM] SBATCH(1)  (0) 2024.09.06
[SLURM] SRUN 명령어  (1) 2024.09.05
[Ubuntu] SGE 설치  (0) 2024.09.03