C.W.K.
Stream
Lesson 03 of 07 · published

Multi-GPU 학습

~8 min · advanced

Level 0Keras 도제
0 XP0/97 lessons0/20 achievements
0/120 XP to next level120 XP to go0% complete

한 GPU 메모리 / 속도 부족할 때 multi-GPU. Keras 의 distribution: strategy = keras.distribution.DataParallel(); strategy.scope() 안에서 model 만들고 학습. data parallel — 같은 모델, GPU 별 다른 batch.

큰 모델용 model parallel 도 있음 — 모델 자체를 GPU 사이 분할. 보통은 data parallel 이 충분. fit() 인프라가 알아서 batch 분배 + gradient 합산.

백엔드 노트:
⚙️ Backend Note

Code

# Data parallelism: same model on each GPU, split data
devices = keras.distribution.list_devices("gpu")
data_parallel = keras.distribution.DataParallel(devices=devices)

# Set distribution before building the model
keras.distribution.set_distribution(data_parallel)

model = build_model()
model.compile(optimizer="adam", loss="mse")
model.fit(x_train, y_train)  # Automatically distributed!

# Model parallelism: split model across GPUs
device_mesh = keras.distribution.DeviceMesh(
    shape=(2,), axis_names=["model"], devices=devices
)
layout_map = keras.distribution.LayoutMap(device_mesh)
layout_map["dense/kernel"] = keras.distribution.TensorLayout(["model", None])

External links

Exercise

GPU 2+ 있으면 DataParallel strategy 로 CIFAR-10 학습. single-GPU vs epoch time 비교. accuracy 안 떨어지는지 확인. GPU 1 개만이면 Colab TPU 셋업 후 시도.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.