无法让 pytorch 与 tensorboard 一起工作

新手上路,请多包涵

我正在通过本教程使用 tensorboard 设置 pytorch(v1.3.0 到 conda) https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html#

但在台阶上

from torch.utils.tensorboard import SummaryWriter

# default `log_dir` is "runs" - we'll be more specific here
writer = SummaryWriter('runs/fashion_mnist_experiment_1')

我一直收到错误

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
C:\ProgramData\Anaconda3\envs\fastai_v1\lib\site-packages\torch\utils\tensorboard__init__.py in
      1 try:
----> 2     from tensorboard.summary.writer.record_writer import RecordWriter  # noqa F401
      3 except ImportError:

ModuleNotFoundError: No module named 'tensorboard.summary'; 'tensorboard' is not a package

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
c:\Users\matt\Documents\code\playground\tensorboard.py in
----> 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')

C:\ProgramData\Anaconda3\envs\fastai_v1\lib\site-packages\torch\utils\tensorboard__init__.py in
      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.

有没有人有什么建议?

原文由 foobar8675 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 903
2 个回答

错误日志说,除其他外,

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

因此,当它尝试导入 TensorBoard 时,它无法这样做,因为它在搜索路径中找不到它。您可以安装最新版本(无需指定任何版本号),如:

 $ conda install -c conda-forge tensorboard

除此之外,您可能还需要安装 protobuf:

 $ conda install -c conda-forge protobuf

这些安装应该修复 ImportError s。

原文由 kmario23 发布,翻译遵循 CC BY-SA 4.0 许可协议

我遇到了同样的错误,我通过以下步骤解决了:

  1. 从 conda 环境中删除了所有 Tensorflow 或 Tensorboard 安装。
  2. 然后通过激活相同的 conda 环境,键入“pip install -U tb-nightly”
  3. 然后输入“pip install -U future”
  4. 完毕

原文由 soumya ranjan Tripathy 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题