Path: blob/master/site/ko/guide/migrate/mirrored_strategy.ipynb
38956 views
Copyright 2021 The TensorFlow Authors.
단일 작업자 멀티 GPU 훈련 마이그레이션하기
이 가이드는 단일 작업자 멀티 GPU 워크플로를 TensorFlow 1에서 TensorFlow 2로 마이그레이션하는 방법을 설명합니다.
다음과 같이 한 머신에서 멀티 GPU로 동기식 훈련을 수행할 수 있습니다.
TensorFlow 1에서는
tf.distribute.MirroredStrategy와 함께tf.estimator.EstimatorAPI를 사용합니다.TensorFlow 2에서는
tf.distribute.MirroredStrategy와 함께 Keras Model.fit 또는 사용자 정의 훈련 루프를 사용할 수 있습니다. TensorFlow를 사용하는 분산 훈련 가이드에서 자세히 알아보세요.
설치하기
데모를 위해 가져오기 및 간단한 데이터세트로 시작해 보겠습니다.
TensorFlow 1: tf.estimator.Estimator로 단일 작업자 분산 훈련하기
이 예제는 단일 작업자 멀티 GPU 훈련의 TensorFlow 1 정식 워크플로를 보여줍니다. tf.estimator.Estimator의 config 매개변수를 통해 배포 전략(tf.distribute.MirroredStrategy)을 설정해야 합니다.
TensorFlow 2: Keras로 단일 작업자 훈련하기
TensorFlow 2로 마이그레이션하는 경우 tf.distribute.MirroredStrategy와 함께 Keras API를 사용할 수 있습니다.
모델 빌드에 tf.keras API를 사용하고 훈련에 Keras Model.fit을 사용하는 경우 주요 차이점은 tf.estimator.Estimator에 config를 정의하는 대신 Strategy.scope 컨텍스트에서 Keras 모델, 옵티마이저 및 메트릭을 인스턴스화하는 것입니다.
사용자 정의 훈련 루프를 사용해야 하는 경우 사용자 정의 훈련 루프와 함께 tf.distribute.Strategy 사용하기 가이드를 확인하세요.
다음 단계
TensorFlow 2에서 tf.distribute.MirroredStrategy를 사용하는 분산 훈련에 대한 자세한 내용은 다음 설명서를 확인하세요
TensorFlow.org에서 보기
Google Colab에서 실행하기
GitHub에서 소스 보기
노트북 다운로드하기