根据这个官方 Tensorboard 插件示例:
https://github.com/tensorflow/tensorboard-plugin-example
使用自定义 Tensorboard 插件的唯一方法是构建包含该插件的自定义 Tensorboard。这看起来很奇怪(我想集成自定义插件的更好方法是以某种方式将其注册到“标准”Tensorboard,或者将其名称/路径作为参数传递给 Tensorboard)。这是一种奇怪的方法,但我可以忍受。真正困扰我的是,从上面的示例来看,启动自定义 Tensorboard 的唯一方法是使用“bazel run”命令
bazel run //greeter_tensorboard -- --logdir=/tmp/greeter_demo
或者也许我错了,可以在没有 Bazel 的情况下启动自定义 TensorBoard 吗?我对 Python 和 Tensorboard 都很陌生,所以我无法找到不同的启动方式。不幸的是,该示例附带的 README.md 并没有过多介绍如何部署 Tensorboard 插件,而是提供了 Tensorboard README 和 Bazel 文档的链接。但我无法在那里找到有关部署插件和自定义张量板的任何有用信息。
Integration
Once you have a plugin (or, more realistically, as you are developing it), you will want to use it inside TensorBoard. To do that, we recommend you fork this repository; it has everything set up for you.
Basically, the way you integrate a new plugin is by creating a custom TensorBoard build. The custom build needs to change two things:
- It needs to use its own main.py file, which imports the standard TensorBoard plugins, and adds a new one on the backend.
- It needs to provide its own index.html file, which imports the new TensorBoard plugin frontend, and registers it as a dashboard.
If you want to really understand what’s going on with the integration, you’ll need to understand Bazel, our build system. You can read the Bazel docs and also our compilation of useful tips.
如果这是启动自定义张量板的唯一方法,这意味着我的自定义张量板的每个用户都必须安装 Bazel,并从 C++ 和 Python 源构建自定义张量板。但我什至无法让 Bazel 在 Windows 上构建这个 Greeter 示例,因为 VC15 编译器(Visual Studio 2017 附带的编译器)无法编译 TensorBoard 中使用的 C++(我猜是因为 VC 不完全支持现代 C++ 标准)。我只能在 Linux 上构建它。 所以我的问题是:自定义张量板到底应该如何分发和启动?没有 Bazel 是否可以做到这一点?
最佳答案
我已经弄清楚如何创建自定义 Greeter 演示张量板的发行版并在没有 Bazel 的情况下运行它。假设 Greeter 演示张量板代码已克隆到 ~/tensorboard-plugin-example 中。使用以下命令构建插件和张量板后:
bazel run //greeter_plugin:greeter_demo
bazel run //greeter_tensorboard -- --logdir=/tmp/greeter_demo
将greeter_tensorboard目录从~/tensorboard-plugin-example复制到~/
将~/tensorboard-plugin-example/greeter_plugin目录复制到~/greeter_tensorboard
将文件 assets.zip 从 ~/tensorboard-plugin-example/bazel-bin/greeter_tensorboard 复制到 ~/greeter_tensorboard>
您现在可以使用以下命令启动自定义 Greeter 张量板:
python ~/greeter_tensorboard/main.py --logdir=/tmp/greeter_demo
假设运行/tmp/greeter_demo目录下已经生成了测试数据
bazel run //greeter_plugin:greeter_demo
命令。
关于python - 部署 Tensorboard 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53637674/