File size: 3,122 Bytes
3bfe3dd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
translated_content = """
# ๊ฐ์๊ธฐ ์ ํ
๋ถ์ฐ ํ๋ จ ์ค์๋ ์ฌ์ฉํ ๊ฐ์๊ธฐ(CUDA, XPU, MPS, HPU ๋ฑ)์ ๊ฐ์์ ์์๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค. ์ด๋ ์๋ก ๋ค๋ฅธ ์ปดํจํ
์ฑ๋ฅ์ ๊ฐ์ง ๊ฐ์๊ธฐ๋ค์ด ์์ ๋ ๋ ๋น ๋ฅธ ๊ฐ์๊ธฐ๋ฅผ ๋จผ์ ์ฌ์ฉํ๊ณ ์ถ๊ฑฐ๋, ์ฌ์ฉ ๊ฐ๋ฅํ ๊ฐ์๊ธฐ ์ค ์ผ๋ถ๋ง ์ฌ์ฉํ๊ณ ์ถ์ ๋ ์ ์ฉํฉ๋๋ค. ์ ํ ๊ณผ์ ์ [DistributedDataParallel](https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html)๊ณผ [DataParallel](https://pytorch.org/docs/stable/generated/torch.nn.DataParallel.html) ๋ชจ๋์์ ์๋ํฉ๋๋ค. Accelerate๋ [DeepSpeed integration](./main_classes/deepspeed)์ด ํ์ํ์ง ์์ต๋๋ค.
์ด ๊ฐ์ด๋์์๋ ์ฌ์ฉํ ๊ฐ์๊ธฐ์ ๊ฐ์์ ์ฌ์ฉ ์์๋ฅผ ์ ํํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ๋๋ฆฝ๋๋ค.
## ๊ฐ์๊ธฐ ๊ฐ์
์๋ฅผ ๋ค์ด, 4๊ฐ์ ๊ฐ์๊ธฐ๊ฐ ์๊ณ ์ฒ์ 2๊ฐ๋ง ์ฌ์ฉํ๊ณ ์ถ๋ค๋ฉด ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํ์ธ์.
<hfoptions id="select-accelerator">
<hfoption id="torchrun">
์ฌ์ฉํ ๊ฐ์๊ธฐ ๊ฐ์๋ฅผ ์ ํํ๋ ค๋ฉด `--nproc_per_node`๋ฅผ ์ฌ์ฉํ์ธ์.
</hfoption>
<hfoption id="Accelerate">
์ฌ์ฉํ ๊ฐ์๊ธฐ ๊ฐ์๋ฅผ ์ ํํ๋ ค๋ฉด `--num_processes`๋ฅผ ์ฌ์ฉํ์ธ์.
</hfoption>
<hfoption id="๐ค DeepSpeed">
์ฌ์ฉํ GPU ๊ฐ์๋ฅผ ์ ํํ๋ ค๋ฉด `--num_gpus`๋ฅผ ์ฌ์ฉํ์ธ์.
</hfoption>
</hfoptions>
## ๊ฐ์๊ธฐ ์์
์ฌ์ฉํ ํน์ ๊ฐ์๊ธฐ์ ๊ทธ ์์๋ฅผ ์ ํํ๋ ค๋ฉด ํ๋์จ์ด์ ์ ํฉํ ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํ์ธ์. ์ด๋ ๋ณดํต ๊ฐ ์คํ๋ง๋ค ๋ช
๋ น์ค์์ ์ค์ ๋์ง๋ง, `~/.bashrc`๋ ๋ค๋ฅธ ์์ ์ค์ ํ์ผ์ ์ถ๊ฐํ ์๋ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, 4๊ฐ์ ๊ฐ์๊ธฐ(0, 1, 2, 3)๊ฐ ์๊ณ ๊ฐ์๊ธฐ 0๊ณผ 2๋ง ์คํํ๊ณ ์ถ๋ค๋ฉด:
<hfoptions id="accelerator-type">
<hfoption id="CUDA">
GPU 0๊ณผ 2๋ง PyTorch์ "๋ณด์ด๋ฉฐ" ๊ฐ๊ฐ `cuda:0`๊ณผ `cuda:1`๋ก ๋งคํ๋ฉ๋๋ค.
์์๋ฅผ ๋ฐ๊พธ๋ ค๋ฉด(GPU 2๋ฅผ `cuda:0`์ผ๋ก, GPU 0์ `cuda:1`๋ก ์ฌ์ฉ):
GPU ์์ด ์คํํ๋ ค๋ฉด:
`CUDA_DEVICE_ORDER`๋ฅผ ์ฌ์ฉํ์ฌ CUDA ์ฅ์น์ ์์๋ฅผ ์ ์ดํ ์๋ ์์ต๋๋ค:
- PCIe ๋ฒ์ค ID ์์(`nvidia-smi`์ ์ผ์น):
- ์ปดํจํ
์ฑ๋ฅ ์์(๊ฐ์ฅ ๋น ๋ฅธ ๊ฒ๋ถํฐ):
</hfoption>
<hfoption id="Intel XPU">
XPU 0๊ณผ 2๋ง PyTorch์ "๋ณด์ด๋ฉฐ" ๊ฐ๊ฐ `xpu:0`๊ณผ `xpu:1`๋ก ๋งคํ๋ฉ๋๋ค.
์์๋ฅผ ๋ฐ๊พธ๋ ค๋ฉด(XPU 2๋ฅผ `xpu:0`์ผ๋ก, XPU 0์ `xpu:1`๋ก ์ฌ์ฉ):
๋ค์์ผ๋ก Intel XPU์ ์์๋ฅผ ์ ์ดํ ์๋ ์์ต๋๋ค:
Intel XPU์์์ ์ฅ์น ์ด๊ฑฐ ๋ฐ ์ ๋ ฌ์ ๋ํ ์์ธํ ์ ๋ณด๋ [Level Zero](https://github.com/oneapi-src/level-zero/blob/master/README.md?plain=1#L87) ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ธ์.
</hfoption>
</hfoptions>
> [!WARNING]
> ํ๊ฒฝ ๋ณ์๋ ๋ช
๋ น์ค์ ์ถ๊ฐํ๋ ๋์ exportํ ์ ์์ต๋๋ค. ํ๊ฒฝ ๋ณ์๊ฐ ์ด๋ป๊ฒ ์ค์ ๋์๋์ง ์์ด๋ฒ๋ฆฌ๊ณ ์๋ชป๋ ๊ฐ์๊ธฐ๋ฅผ ์ฌ์ฉํ๊ฒ ๋ ์ ์์ด ํผ๋์ค๋ฌ์ธ ์ ์์ผ๋ฏ๋ก ๊ถ์ฅํ์ง ์์ต๋๋ค. ๋์ ํน์ ํ๋ จ ์คํ์ ์ํ ํ๊ฒฝ ๋ณ์๋ฅผ ๊ฐ์ ๋ช
๋ น์ค์์ ์ค์ ํ๋ ๊ฒ์ด ์ผ๋ฐ์ ์ธ ๊ดํ์
๋๋ค.
"""
|