我正在使用Keras TensorBoard回调探索TensorFlow Profiler。我为profile_batch参数尝试了一堆不同的范围值,但Profiler似乎仅显示以下内容:
这里是a gist,以重现此内容。感谢您的帮助。
我使用您的Gist中包含的代码在Google Colab中执行了该代码,并遵循了此link中的Tensorflow Profiler文档。
您应该检查您的TensorFlow,Tensorboard和TensorFlow Profiler版本。
按照文档中的说明运行此代码段,以确保最新版本。
# Uninstall twice to uninstall both the 1.15.0 and 2.1.0 version of TensorFlow and TensorBoard.
!pip uninstall -y -q tensorflow tensorboard
!pip uninstall -y -q tensorflow tensorboard
!pip install -U -q tf-nightly tb-nightly tensorboard_plugin_profile
[当您运行Tensorboard时仍然看不到Profile选项卡,您可以执行此代码段,然后重新启动Tensorboard(杀死进程)。
!pip install -U tensorboard_plugin_profile
这是我添加的一些代码片段。
基于文档。
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from datetime import datetime
from packaging import version
import os
# Imports
from tensorflow.keras.applications import MobileNetV2
from tensorflow.keras.layers import *
from tensorflow.keras.models import *
import matplotlib.pyplot as plt
%matplotlib inline
import tensorflow as tf
print(tf.__version__) # This should return 2.2.0-dev20200408 (as of date ) or higher
检查GPU是否可用。
device_name = tf.test.gpu_device_name()
if not device_name:
raise SystemError('GPU device not found')
print('Found GPU at: {}'.format(device_name))
用于运行Tensorboard。
# Launch TensorBoard and navigate to the Profile tab to view performance profile
%tensorboard --logdir=logs
如果成功执行,它将显示在下面的图像附近。 (注意:为了更快的训练,将时间段数减少到5个)
希望这会对您有所帮助。如果需要,我可以编辑并提供完整的Google Colab Notebook代码。