Post

[4] seraph 101_slurm

[4] seraph 101_slurm

Slurm interface (srun & sbatch)

srun vs sbatch

  • srun(제한 시간 짧음)
    • 디버그할때 이용
    • interactive 필요할때 이용
  • sbatch(시간 길다)
    • batch job(잡 넣고)
    • scripted
    • detached(퇴근)
  • 대표적인 플로우
    • srun으로 코드 잘 돌아가는지 확인 -> script 작성하고 shell 파일에 적고 sbatch로 제출

srun

alt text

1
2
slurm-gres-viz -i
# GPU 상태 확인
1
2
3
4
5
6
7
srun \
--gres=gpu:1 \
--cpus-per-gpu=8 \
--mem-per-gpu=29G \
-p debug_ugrad \
-w aurora-g7 \
--pty $SHELL
  • conda 초기화
    • node에 최초로 접속을 하면, 콘다 initialize 안되어있음. 콘다 initialize 한다는거는 home에 있는 ~/.bashrc file에다가 블록 추가하는건데.. home은 나스가 아니니 컴퓨팅 노드에선 이걸 인식못함. 그래서! 컴퓨팅 노드에서 수정해야함
1
2
/data/$USER/anaconda3/bin/conda init
source ~/.bashrc
1
2
3
4
conda info --envs
conda env remove -n hand
conda install -n myenv python=3.11 -y
python -m pip install numpy #가상 환경에 다운로드 할때
1
2
3
4
# CUDA 12.x 환경 예시 (권장)
conda install -y pytorch pytorch-cuda=12.4 -c pytorch -c nvidia
# (필요시) torchvision, torchaudio
conda install -y torchvision torchaudio -c pytorch

srun vs sbatch

alt text

1
2
nvidia-smi
# gpu 체크

Which partition shoud i use?

alt text

  • srun 할땐, debug
  • sbatch 할땐, batch

sbatch

alt text

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/bash

#SBATCH -J test-run
#SBATCH --gres=gpu:1
#SBATCH --cpus-per-gpu=8
#SBATCH --mem-per-gpu=29G
#SBATCH -p batch_ugrad
#SBATCH -w aurora-g7
#SBATCH -t 1-0
#SBATCH -o logs/slurm-%A.out


pwd
which python
hostname
python hello.py

exit 0

alt text alt text -> sbatch가 PATH라는 shell에 있는 variable을 상속받았다는 뜻. sbatch 하기 전에 python 환경 킨다음에 sbatch 하면 거기서도 이걸 환경으로 인식

1
2
scancel "$JOBID"
tail -f slurm-56683.out # log 실시간으로 보기

Monitoring Slurm: resource limits

alt text

1
2
3
show-qos

show-assoc

alt text alt text

This post is licensed under CC BY 4.0 by the author.