# Kubeflow Trainer v2 - TensorFlow Custom ClusterTrainingRuntime # Trainer v2에는 TensorFlow runtime이 기본 제공되지 않으므로 Custom Runtime으로 생성 # # 핵심 차이점: # - PyTorch runtime: mlPolicy.torch 사용 → torchrun 자동 주입, MASTER_ADDR/RANK 등 자동 설정 # - TensorFlow runtime (custom): mlPolicy에 framework 없음 → TF_CONFIG를 학습 스크립트에서 자체 구성 # # TF_CONFIG 자동 구성 방식: # 1. Pod hostname에서 TrainJob 이름과 replica index 추출 # 2. Headless Service DNS를 이용한 worker 주소 목록 생성 # 3. tf.distribute.MultiWorkerMirroredStrategy로 분산학습 실행 apiVersion: trainer.kubeflow.org/v1alpha1 kind: ClusterTrainingRuntime metadata: name: tensorflow-distributed labels: trainer.kubeflow.org/framework: tensorflow spec: mlPolicy: numNodes: 1 template: spec: network: publishNotReadyAddresses: true replicatedJobs: - name: node template: metadata: labels: trainer.kubeflow.org/trainjob-ancestor-step: trainer spec: template: spec: containers: - name: node image: tensorflow/tensorflow:2.16.1-gpu env: - name: NUM_WORKERS value: "1" - name: TF_WORKER_PORT value: "12345" - name: NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace