Skip to content

Commit 9a84472

Browse files
committed
Upgrade Tensorflow version to v2.13.0
Signed-off-by: Yuki Iwai <[email protected]>
1 parent 888bec3 commit 9a84472

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed

cmd/metricscollector/v1beta1/tfevent-metricscollector/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ psutil==5.9.4
22
rfc3339>=6.2
33
grpcio>=1.41.1
44
googleapis-common-protos==1.6.0
5-
tensorflow==2.11.0
5+
tensorflow==2.13.0
6+
protobuf<=3.20.3
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
grpcio>=1.41.1
22
googleapis-common-protos==1.6.0
33
cython>=0.29.24
4-
tensorflow==2.11.0
4+
tensorflow==2.13.0
5+
protobuf<=3.20.3
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
scipy>=1.7.2
2-
tensorflow==2.11.0
2+
tensorflow==2.13.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
tensorflow==2.11.0
1+
tensorflow==2.13.0

pkg/metricscollector/v1beta1/tfevent-metricscollector/tfevent_loader.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
# https://github.com/kubeflow/katib/blob/master/examples/v1beta1/kubeflow-training-operator/tfjob-mnist-with-summaries.yaml#L16-L22
2323

2424
import tensorflow as tf
25-
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator
25+
from tensorboard.backend.event_processing.event_accumulator import EventAccumulator, TensorEvent
26+
from tensorboard.backend.event_processing.tag_types import TENSORS
27+
from tensorboard.compat.proto import tensor_pb2
2628
import os
27-
from datetime import datetime
2829
import rfc3339
30+
from datetime import datetime
31+
from dataclasses import is_dataclass
2932
import api_pb2
3033
from logging import getLogger, StreamHandler, INFO
3134
from pkg.metricscollector.v1beta1.common import const
@@ -41,27 +44,38 @@ def find_all_files(directory):
4144
for f in files:
4245
yield os.path.join(root, f)
4346

47+
@staticmethod
48+
def new_metric_log(metric_name: str, wall_time: float, tensor: tensor_pb2.TensorProto) -> api_pb2.MetricLog:
49+
return api_pb2.MetricLog(
50+
time_stamp=rfc3339.rfc3339(datetime.fromtimestamp(wall_time)),
51+
metric=api_pb2.Metric(
52+
name=metric_name,
53+
value=str(tf.make_ndarray(tensor))
54+
)
55+
)
56+
4457
def parse_summary(self, tfefile):
4558
metric_logs = []
46-
event_accumulator = EventAccumulator(tfefile, size_guidance={'tensors': 0})
59+
event_accumulator = EventAccumulator(tfefile, size_guidance={TENSORS: 0})
4760
event_accumulator.Reload()
48-
for tag in event_accumulator.Tags()['tensors']:
61+
for tag in event_accumulator.Tags()[TENSORS]:
4962
for m in self.metric_names:
5063

5164
tfefile_parent_dir = os.path.dirname(m) if len(m.split("/")) >= 2 else os.path.dirname(tfefile)
5265
basedir_name = os.path.dirname(tfefile)
5366
if not tag.startswith(m.split("/")[-1]) or not basedir_name.endswith(tfefile_parent_dir):
5467
continue
5568

56-
for wall_time, step, tensor in event_accumulator.Tensors(tag):
57-
ml = api_pb2.MetricLog(
58-
time_stamp=rfc3339.rfc3339(datetime.fromtimestamp(wall_time)),
59-
metric=api_pb2.Metric(
60-
name=m,
61-
value=str(tf.make_ndarray(tensor))
62-
)
63-
)
64-
metric_logs.append(ml)
69+
# Since Tensorboard v2.12.0, the 'TensorEvent' typed was changed from namedtuple to dataclass.
70+
# REF: https://github.com/tensorflow/tensorboard/commit/1975529d953eff55d279ee036240e4db4cb0d57c
71+
if is_dataclass(TensorEvent):
72+
# Tensorboard >= v2.12.0
73+
for tensors in event_accumulator.Tensors(tag):
74+
metric_logs.append(self.new_metric_log(m, tensors.wall_time, tensors.tensor_proto))
75+
else:
76+
# Tensorboard < v2.12.0
77+
for wall_time, step, tensor in event_accumulator.Tensors(tag):
78+
metric_logs.append(self.new_metric_log(m, wall_time, tensor))
6579

6680
return metric_logs
6781

sdk/python/v1beta1/kubeflow/katib/constants/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
# Supported base images for the Katib Trials.
5252
# TODO (andreyvelich): Implement list_base_images function to get each image description.
53-
BASE_IMAGE_TENSORFLOW = "docker.io/tensorflow/tensorflow:2.11.0"
54-
BASE_IMAGE_TENSORFLOW_GPU = "docker.io/tensorflow/tensorflow:2.11.0-gpu"
53+
BASE_IMAGE_TENSORFLOW = "docker.io/tensorflow/tensorflow:2.13.0"
54+
BASE_IMAGE_TENSORFLOW_GPU = "docker.io/tensorflow/tensorflow:2.13.0-gpu"
5555
BASE_IMAGE_PYTORCH = "docker.io/pytorch/pytorch:1.12.1-cuda11.3-cudnn8-runtime"
5656
BASE_IMAGE_MXNET = "docker.io/mxnet/python:1.9.1_native_py3"
5757

0 commit comments

Comments
 (0)