diff --git a/tools/timeline.py b/tools/timeline.py index 694ab1d50fd78da7f873d3a31b0607d9fedf8dcf..44c1c09b803dfc3efd83428035880101e1ddb3e2 100644 --- a/tools/timeline.py +++ b/tools/timeline.py @@ -160,6 +160,8 @@ class Timeline(object): self._devices[(k, event.device_id, "GPUKernel")] = pid self._chrome_trace.emit_pid("%s:gpu:%d" % (k, event.device_id), pid) + if not hasattr(profile_pb, "mem_events"): + continue for mevent in profile_pb.mem_events: if mevent.place == profiler_pb2.MemEvent.CUDAPlace: if (k, mevent.device_id, "GPU") not in self._mem_devices: @@ -211,7 +213,7 @@ class Timeline(object): args = {'name': event.name} if event.memcopy.bytes > 0: args['mem_bytes'] = event.memcopy.bytes - if event.detail_info: + if hasattr(event, "detail_info") and event.detail_info: args['detail_info'] = event.detail_info # TODO(panyx0718): Chrome tracing only handles ms. However, some # ops takes micro-seconds. Hence, we keep the ns here. @@ -220,6 +222,8 @@ class Timeline(object): event.sub_device_id, 'Op', event.name, args) def _allocate_memory_event(self): + if not hasattr(profiler_pb2, "MemEvent"): + return place_to_str = { profiler_pb2.MemEvent.CPUPlace: "CPU", profiler_pb2.MemEvent.CUDAPlace: "GPU",