【问题标题】:How do I use tensorboard with pytorch?如何在 pytorch 中使用 tensorboard?
【发布时间】:2020-05-18 09:16:32
【问题描述】:

我正在关注 pytorch tensorboard 教程:https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html

但由于以下错误,我什至无法启动:

from torch.utils.tensorboard import SummaryWriter
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~/apps/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/tensorboard/__init__.py in <module>
      1 try:
----> 2     from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
      3 except ImportError:

ModuleNotFoundError: No module named 'tensorboard'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-4-c8ffdef1cfab> in <module>
----> 1 from torch.utils.tensorboard import SummaryWriter
      2 
      3 # default `log_dir` is "runs" - we'll be more specific here
      4 writer = SummaryWriter('runs/fashion_mnist_experiment_1')

~/apps/anaconda3/envs/torch/lib/python3.7/site-packages/torch/utils/tensorboard/__init__.py in <module>
      2     from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
      3 except ImportError:
----> 4     raise ImportError('TensorBoard logging requires TensorBoard with Python summary writer installed. '
      5                       'This should be available in 1.14 or above.')
      6 from .writer import FileWriter, SummaryWriter  # noqa F401

ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.

我通过 conda 安装了 pytorch 1.14。我应该安装其他东西吗?

【问题讨论】:

  • 他们可能应该让您知道您需要在该教程中安装 tensorboard。看一下pytorch tensorboard docs,里面说明需要先安装tensorboard。
  • @jodag 谢谢。我知道了。那我应该怎么安装呢?
  • 我一般使用pip install tensorboard,但也可能有conda方法。
  • 谢谢@jodag。如果您向这些 cmets 发布一个小答案,我会接受。

标签: python python-3.x pytorch tensorboard


【解决方案1】:

该教程可能会让您知道您需要安装 tensorboard。看一下pytorch tensorboard docs,里面说明需要先安装tensorboard。

基本上你可以使用

安装 tensorboard
pip install tensorboard

然后通过运行启动张量板服务器

tensorboard --logdir=runs

runs 目录是您的摘要编写器将写入的位置,也是 tensorboard 服务器读取的位置以了解要可视化的内容。

【讨论】:

    猜你喜欢
    • 2020-01-23
    • 2021-04-25
    • 2018-10-03
    • 2021-04-03
    • 2020-04-06
    • 2021-04-10
    • 2021-07-16
    • 2021-04-06
    • 2020-06-02
    相关资源
    最近更新 更多