【问题标题】:Setting the profile_batch argument in the TensorBoard callback在 TensorBoard 回调中设置 profile_batch 参数
【发布时间】:2020-07-12 21:18:33
【问题描述】:

我正在探索带有 Keras TensorBoard 回调的 TensorFlow Profiler。我为 profile_batch 参数尝试了一堆不同的范围值,但 Profiler 似乎只显示以下内容:

这里是a gist 来复制这个。我很感激任何帮助。

编辑

我应该提供的信息表明,在卸载 TensorBoard 2.1.1 并安装 tb-nightly 和 TensorFlow Profiler 插件后,它可以在 Google Colab 上完美运行。但是在云提供商上运行的笔记本上,如果不正确设置 CUDA 驱动程序(特别是 CUPTI),它可能无法工作。 TensorFlow Profiler 团队的 Qiumin 在this discussion thread 帮助我。

【问题讨论】:

    标签: python tensorflow keras tensorboard


    【解决方案1】:

    我在 Google Colab 中使用包含您的 Gist 的代码执行了代码,并遵循了 link 中的 Tensorflow Profiler 文档

    您应该检查您的 TensorFlowTensorboardTensorFlow Profiler 版本。

    按照文档中的说明运行此 sn-p 以确保 最新 版本。

    # 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 选项卡时,您可以执行此 sn-p 然后重新启动 Tensorboard(终止进程)。

    !pip install -U tensorboard_plugin_profile
    

    这是我添加的几个代码 sn-ps。

    根据文档。

    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
    
    

    如果成功执行,它应该显示接近下图。 (注意:将 Epoch 数减少到 5 以加快训练速度)

    希望这会对您有所帮助。
    如果需要,我可以编辑并提供完整的 Google Colab Notebook 代码

    【讨论】:

      猜你喜欢
      • 2020-03-22
      • 2013-05-21
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      • 2019-02-13
      • 2013-01-09
      • 2016-03-01
      • 1970-01-01
      相关资源
      最近更新 更多