마구잡

Nvidia gpu-operator를 통한 다중 GPU MIG 설정 본문

Kubernetes

Nvidia gpu-operator를 통한 다중 GPU MIG 설정

MAGUJOB 2024. 6. 3. 17:07
728x90

개요

nvidia gpu-operator를 통해 클러스터 내 여러 GPU를 개별적으로 MIG 설정을 하는 방법이 공식 문서에도 나와있지 않고

블로그도 거의 찾기가 힘들어서 적어본다.

 

광고 클릭은 큰 힘이 됩니다.

728x90

 

 

이 글은 MIG 설정만 요약한 글이기에 nvidia-opertor 또는 GPU 드라이버 설정이 선행 되어야 한다.

GPU 모델마다 적용 가능한 프로파일이 다르기 때문에 Nvidia 공식 홈페이지에서 확인 후 설정을 진행한다.

본론

gpu-operator namespace 내 기본 mig configmaps 확인

kubectl get cm -n gpu-operator

default-gpu-clients                                   1      63d
default-mig-parted-config                             1      63d
kube-root-ca.crt                                      1      63d
..생략

 

gpu-operator default-mig-parted-config를 샘플링 하여 새로운 configmaps 생성

kubectl get cm -n gpu-operator default-mig-parted-config  -oyaml > custom-mig-config.yaml
kind: ConfigMap
metadata:
  name: custom-mig-config 
  namespace: gpu-operator 

apiVersion: v1
data:
  config.yaml: |
    version: v1
    mig-configs:
      all-disabled: # 모든 MIG 설정 제거
        - devices: all
          mig-enabled: false
      # 모든 GPU 디바이스를 1g.10gb로 나누는 프로파일
      all-1g.10gb:
        # H100-80GB, H800-80GB, A100-80GB, A800-80GB
        - device-filter: ["0x233010DE", "0x233110DE", "0x232210DE", "0x20B210DE", "0x20B510DE", "0x20F310DE", "0x20F510DE"]
          devices: all
          mig-enabled: true
          mig-devices:
            "1g.10gb": 7
      # 여러 디바이스를 동시에 설정하는 프로파일 설정
      # 필요에 따라 프로파일을 변경하여 적용
      new:
        - device-filter: ["0x233010DE", "0x233110DE", "0x232210DE", "0x20B210DE", "0x20B510DE", "0x20F310DE", "0x20F510DE"]
          devices: [0] # 0번 GPU 디바이스
          mig-enabled: true
          mig-devices:
            "1g.10gb": 7 # 1g.10gb 프로파일로 7개 인스턴스 생성

        - device-filter: ["0x233010DE", "0x233110DE", "0x232210DE", "0x20B210DE", "0x20B510DE", "0x20F310DE", "0x20F510DE"]
          devices: [1] # 1번 GPU 디바이스
          mig-enabled: true
          mig-devices:
            "1g.10gb": 7 # 1g.10gb 프로파일로 7개 인스턴스 생성

        - device-filter: ["0x233010DE", "0x233110DE", "0x232210DE", "0x20B210DE", "0x20B510DE", "0x20F310DE", "0x20F510DE"]
          devices: [2] # 2번 GPU 디바이스
          mig-enabled: true
          mig-devices:
            "2g.20gb": 2 # 2g.20gb 프로파일로 2개 인스턴스 생성
            "3g.40gb": 1 # 3g.40gb 프로파일로 1개 인스턴스 생성
        - device-filter: ["0x233010DE", "0x233110DE", "0x232210DE", "0x20B210DE", "0x20B510DE", "0x20F310DE", "0x20F510DE"]
          devices: [3] # 번 GPU 디바이스
          mig-enabled: true
          mig-devices:
            "7g.80gb": 1 # 7g.80gb 프로파일로 1개 인스턴스 생성
Devices에 들어갈 장치 아이디는 gpu 노드에서 nvidia-smi 명령어로 확인이 가능하다.
더보기
nvidia-smi
# 맨 앞 숫자가 장치 아이디
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.54.15              Driver Version: 550.54.15      CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0 <- GPU ID NVIDIA A100 80GB PCI eOff |                        |                   On |
| N/A   35C    P0             69W /  300W |      25MiB /  81920MiB |     N/A      Default |
|                                         |                        |              Enabled |
|=========================================+========================+======================|
|   1 <- GPU ID NVIDIA A100 80GB PCIe Off |                        |                   On |
| N/A   35C    P0             69W /  300W |      25MiB /  81920MiB |     N/A      Default |
|                                         |                        |              Enabled |
|=========================================+========================+======================|
|   2 <- GPU ID NVIDIA A100 80GB PCIe Off |                        |                   On |
| N/A   35C    P0             69W /  300W |      25MiB /  81920MiB |     N/A      Default |
|                                         |                        |              Enabled |
|=========================================+========================+======================|
|   3 <- GPU ID NVIDIA A100 80GB PCIe Off |                        |                   On |
| N/A   35C    P0             69W /  300W |      25MiB /  81920MiB |     N/A      Default |
|                                         |                        |              Enabled |
+-----------------------------------------------------------------------------------------+

새로운 configmaps 생성

kubectl apply -f custom-mig-config.yaml

kubectl get cm -n gpu-operator

NAME                                                  DATA   AGE
custom-mig-config                                     1      45s
..생략

 

configmaps 적용을 위한 cluster-policy 수정

kubectl edit -n gpu-operator  clusterpolicies.nvidia.com cluster-policy

# 188번 라인 수정

183   mig:
184     strategy: single
185   migManager:
186     config:
187       default: all-disabled # default 수정시 기본 MIG 설정 변경 가능
188       name: custom-mig-config # <- 상기 생성한 configmaps로 변경
189     enabled: true

 

node labeling MIG 적용

# 위 configmaps에서 생성한 프로파일 라벨링

kubectl label node geon5 nvidia.com/mig.config=new --overwrite

kubectl get node --show-labels |grep mig.config
생략..nvidia.com/mig.config.state=pending,nvidia.com/mig.config=new
labeling 시작후 mig-manger에 의해 state=pending 상태로 변경 이후 정상적으로 적용 완료 후 success 변경 됨

 

적용 확인

kubectl get node --show-labels |grep mig.config
생략..nvidia.com/mig.config.state=success,nvidia.com/mig.config=new

혹여 state=failed 상태라면 mig-manager pod의 로그로 트러블슈팅이 가능하다.

kubectl logs -n gpu-operator nvidia-mig-manager-sbf6v

# 아래처럼 적용 로그도 확인이 가능

Applying the MIG mode change from the selected config to the node (and double checking it took effect)
If the -r option was passed, the node will be automatically rebooted if this is not successful
time="2024-06-03T04:01:48-04:00" level=debug msg="Parsing config file..."
time="2024-06-03T04:01:48-04:00" level=debug msg="Selecting specific MIG config..."
time="2024-06-03T04:01:48-04:00" level=debug msg="Running apply-start hook"
time="2024-06-03T04:01:48-04:00" level=debug msg="Checking current MIG mode..."
time="2024-06-03T04:01:49-04:00" level=debug msg="Walking MigConfig for (device-filter=[0x233010DE 0x233110DE 0x232210DE 0x20B210DE 0x20B510DE 0x20F310DE 0x20F510DE], devices=[0])"
time="2024-06-03T04:01:49-04:00" level=debug msg="  GPU 0: 0x20B510DE"
time="2024-06-03T04:01:49-04:00" level=debug msg="    Asserting MIG mode: Enabled"
time="2024-06-03T04:01:49-04:00" level=debug msg="    MIG capable: true\n"
time="2024-06-03T04:01:49-04:00" level=debug msg="    Current MIG mode: Enabled"
time="2024-06-03T04:01:49-04:00" level=debug msg="Walking MigConfig for (device-filter=[0x233010DE 0x233110DE 0x232210DE 0x20B210DE 0x20B510DE 0x20F310DE 0x20F510DE], devices=[1])"
time="2024-06-03T04:01:49-04:00" level=debug msg="Walking MigConfig for (device-filter=[0x233010DE 0x233110DE 0x232210DE 0x20B210DE 0x20B510DE 0x20F310DE 0x20F510DE], devices=[2])"
time="2024-06-03T04:01:49-04:00" level=debug msg="Walking MigConfig for (device-filter=[0x233010DE 0x233110DE 0x232210DE 0x20B210DE 0x20B510DE 0x20F310DE 0x20F510DE], devices=[3])"
time="2024-06-03T04:01:50-04:00" level=debug msg="Running apply-exit hook"
MIG configuration applied successfully
728x90