无法让 pytorch 与张量板一起工作

foo*_*675 14 python data-visualization machine-learning tensorboard pytorch

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

但在台阶上

from torch.utils.tensorboard import SummaryWriter

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

我不断收到错误

---------------------------------------------------------------------------
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.
Run Code Online (Sandbox Code Playgroud)

有没有人有什么建议?

kma*_*o23 7

错误日志说,除其他外,

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
Run Code Online (Sandbox Code Playgroud)

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

$ conda install -c conda-forge protobuf
Run Code Online (Sandbox Code Playgroud)

这些安装应该修复ImportErrors。


sou*_*thy 6

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

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


Qia*_* Na 5

我认为这是版本问题。

只需运行这个:

pip install tensorboard==1.14.0
Run Code Online (Sandbox Code Playgroud)

(不是 pip install tensorboard==1.14)

或者只安装tensoflow 1.14.0,其中包含tensorboard 1.14.0:

pip install tensorflow==1.14.0
Run Code Online (Sandbox Code Playgroud)

这个版本的张量流在 pytorch 1.2 中为我工作。