HPC & GPU Engineering/AI Infrastructure Engineer

[HPC/GPU 클러스터 운영 Zero to Hero 27편] Ansible로 Slurm Cluster 자동 구성하기

ygtoken 2025. 8. 11. 21:18
728x90

 

왜 Slurm 자동 구성이 필요한가

 

HPC/GPU 클러스터에서 Slurm은 Job 스케줄링, 자원 관리, 우선순위 정책의 핵심 역할을 합니다.

하지만 Slurm은 Controller·Compute Node 간 설정 파일이 동일해야 하고,

버전·정책이 조금만 달라도 스케줄링 오류나 Job 실패가 발생합니다.

 

Ansible을 이용하면 Slurm 설치부터 설정 파일 배포, 서비스 재시작, 검증까지 한 번의 Playbook 실행으로 일괄 처리할 수 있습니다.

 


 

1. 사전 준비 사항

 

  1. Slurm 버전 결정
    • 예: Slurm 23.11.x (LTS)
    • Controller·Compute Node 동일 버전 필수
  2. 설치 대상 노드 구분
    • Controller, Compute 그룹별 Inventory 정의
  3. 설정 파일 템플릿 준비
    • slurm.conf.j2, gres.conf.j2

 


 

2. Inventory 예시

[controller]
ctrl01 ansible_host=192.168.0.10

[compute]
node[01:04] ansible_host=192.168.0.[11:14] gpu_type=A100

[all:vars]
ansible_user=hpcadmin
ansible_ssh_private_key_file=~/.ssh/id_rsa
slurm_version=23.11.5
slurm_cluster_name=hpc-cluster

 


 

3. Slurm 설치 및 설정 Playbook

# slurm_cluster_setup.yaml
- hosts: all
  become: yes
  tasks:
    - name: Slurm 패키지 설치
      apt:
        name:
          - slurm-wlm
          - slurm-wlm-doc
          - slurm-wlm-torque
        state: present

- hosts: controller
  become: yes
  tasks:
    - name: slurm.conf 배포
      template:
        src: templates/slurm.conf.j2
        dest: /etc/slurm/slurm.conf
        owner: root
        group: root
        mode: 0644

    - name: gres.conf 배포
      template:
        src: templates/gres.conf.j2
        dest: /etc/slurm/gres.conf
        owner: root
        group: root
        mode: 0644

    - name: Slurm Controller 서비스 재시작
      systemd:
        name: slurmctld
        state: restarted
        enabled: yes

- hosts: compute
  become: yes
  tasks:
    - name: slurm.conf 배포
      template:
        src: templates/slurm.conf.j2
        dest: /etc/slurm/slurm.conf
        owner: root
        group: root
        mode: 0644

    - name: gres.conf 배포
      template:
        src: templates/gres.conf.j2
        dest: /etc/slurm/gres.conf
        owner: root
        group: root
        mode: 0644

    - name: Slurm Compute 서비스 재시작
      systemd:
        name: slurmd
        state: restarted
        enabled: yes

 


 

4. slurm.conf 템플릿 예시 (slurm.conf.j2)

ClusterName={{ slurm_cluster_name }}
SlurmctldHost=ctrl01
SlurmUser=slurm
SlurmdUser=root
StateSaveLocation=/var/spool/slurm
SlurmdPort=6818
SlurmctldPort=6817
AuthType=auth/munge
SchedulerType=sched/backfill
SelectType=select/cons_tres
SelectTypeParameters=CR_Core_Memory,CR_GPU
NodeName=node[01-04] Gres=gpu:A100:8 CPUs=64 RealMemory=256000 State=UNKNOWN
PartitionName=debug Nodes=node[01-04] Default=YES MaxTime=INFINITE State=UP

 


 

5. gres.conf 템플릿 예시 (gres.conf.j2)

Name=gpu Type={{ gpu_type }} File=/dev/nvidia[0-7]

이 설정을 통해 Slurm이 각 노드의 GPU를 GRES 자원으로 인식하게 됩니다.

 


 

6. 설치 후 검증 명령어

# Controller에서 Slurm 서비스 상태 확인
systemctl status slurmctld

# Compute Node에서 slurmd 상태 확인
systemctl status slurmd

# Node 상태 점검
sinfo -N -l

# GPU 자원 인식 여부 확인
scontrol show node node01 | grep Gres

 


 

7. HPC 운영 적용 사례

시나리오 적용 방식
신규 노드 추가 Inventory에 노드 추가 후 Playbook 재실행
파티션 정책 변경 slurm.conf.j2 수정 후 Controller/Compute 동시 배포
GPU 모델 변경 gres.conf.j2 GPU Type 변수 변경 후 재배포
긴급 패치 Slurm 버전 변수 변경 후 전체 재설치

 


 

8. 성능·안정성 최적화 팁

  • 템플릿 변수화: GPU 수, 메모리, 파티션 속성을 변수로 관리
  • Dry-run 모드(--check)로 설정 변경 영향도 사전 확인
  • 롤링 재시작: Compute Node를 순차적으로 재시작하여 서비스 중단 최소화
  • 버전 잠금: 운영 중 Slurm 자동 업데이트 방지

 


 

9. 장애 대응 전략

  • Controller와 Compute Node 설정 불일치 → 템플릿 동기화 후 재배포
  • Slurm 서비스 비정상 종료 → 로그(/var/log/slurmctld.log, /var/log/slurmd.log) 분석 후 재시작
  • GPU 인식 실패 → nvidia-smi, gres.conf 재확인

 


 

정리하며

 

Ansible을 활용하면 Slurm Cluster 구성을 표준화·자동화하여,

  • 신규 노드 확장
  • 정책 변경
  • GPU 자원 관리
  • 를 빠르고 안전하게 수행할 수 있습니다.

 

다음 28편에서는 HPC/K8s 통합 노드 초기화 Playbook 작성을 다루어,

Slurm·Kubernetes 환경이 혼합된 HPC 인프라에서 초기화를 자동화하는 방법을 소개하겠습니다.

 

 

728x90