# 5. GPU 개수 변경하기

앞과 동일한 fine-tuning 작업을 GPU 개수를 바꾸어 다시 실행해 보겠습니다. MoAI Platform은 GPU 자원을 단일 가속기로 추상화하여 제공하며 자동으로 병렬 처리를 수행합니다. 따라서 GPU 개수를 변경하더라도 PyTorch 스크립트는 전혀 고칠 필요가 없습니다.

# 가속기 Flavor 변경

moreh-switch-model 툴을 사용하여 가속기 flavor를 전환합니다. 가속기 변경 방법은 3. 학습 실행하기 문서를 한번 더 참고해주시기 바랍니다.

$ moreh-switch-model

인프라 제공자에게 문의하여 다음 중 하나를 선택한 다음 계속 진행하십시오.

  • AMD MI250 GPU 32개 사용
    • Moreh의 체험판 컨테이너 사용 시: 8xlarge 선택
    • KT Cloud의 Hyperscale AI Computing 사용 시: 8xLarge.4096GB 선택
  • AMD MI210 GPU 64개 사용
  • AMD MI300X GPU 16개 사용

# 학습 실행

다시 train_gpt.py 스크립트를 실행합니다.

~/moreh-quickstart$ python tutorial/train_gpt.py --batch-size 32

사용 가능한 GPU 메모리가 2배가 늘었기 때문에, 배치 사이즈 또한 32로 변경하여 실행시켜 보겠습니다.

학습이 정상적으로 진행된다면 다음과 같은 로그가 출력될 것입니다.

...
[info] Got DBs from backend for auto config.
[info] Requesting resources for MoAI Accelerator from the server...
[warning] A newer version of Moreh AI Framework is available. You can update the software to the latest version by running "update-moreh".
[info] Initializing the worker daemon for MoAI Accelerator
[info] [1/8] Connecting to resources on the server (192.168.110.1:24163)...
[info] [2/8] Connecting to resources on the server (192.168.110.2:24163)...
[info] [3/8] Connecting to resources on the server (192.168.110.4:24163)...
[info] [4/8] Connecting to resources on the server (192.168.110.37:24163)...
[info] [5/8] Connecting to resources on the server (192.168.110.39:24163)...
[info] [6/8] Connecting to resources on the server (192.168.110.40:24163)...
[info] [7/8] Connecting to resources on the server (192.168.110.72:24163)...
[info] [8/8] Connecting to resources on the server (192.168.110.73:24163)...
[info] Establishing links to the resources...
[info] MoAI Accelerator is ready to use.
[info] Moreh Version: 24.5.0
[info] Moreh Job ID: 977770
[info] The number of candidates is 6.
[info] Parallel Graph Compile start...
[info] Elapsed Time to compile all candidates = 4578 [ms]
[info] Parallel Graph Compile finished.
[info] The number of possible candidates is 2.
[info] SelectBestGraphFromCandidates start...
[info] Elapsed Time to compute cost for survived candidates = 254 [ms]
[info] SelectBestGraphFromCandidates finished.
[info] Configuration for parallelism is selected.
[info] num_stages : 4, num_micro_batches : 2, batch_per_device : 1, No TP, recomputation : false, distribute_param : true
[info] train: true
| INFO     | main:train:82 - [Step 0/3320] Loss: 0.9375 Throughput: 1765.73 tokens/sec
| INFO     | main:train:82 - [Step 10/3320] Loss: 0.6875 Throughput: 13705.69 tokens/sec
| INFO     | main:train:82 - [Step 20/3320] Loss: 0.66796875 Throughput: 13531.69 tokens/sec
| INFO     | main:train:82 - [Step 30/3320] Loss: 0.55078125 Throughput: 13839.31 tokens/sec
...

앞서 GPU 개수가 절반이었을 때 실행한 결과와 비교해 동일하게 학습이 이루어지며 throughput이 향상되었음을 확인할 수 있습니다.

  • AMD MI250 GPU 16 → 32개 사용 시: 약 6,800 tokens/sec → 13,000 tokens/sec