[英]Can not get pytorch working with tensorboard
我正在閱讀本教程以使用張量板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.
有沒有人有什么建議?
錯誤日志說,除其他外,
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
。
我遇到了同樣的錯誤,我通過以下步驟解決了:
我覺得是版本問題。
運行這個:
pip install tensorboard==1.14.0
(不是 pip 安裝張量板==1.14)
或者只是安裝 tensorboard 1.14.0,其中包含 tensorboard 1.14.0:
pip install tensorflow==1.14.0
這個版本的 tensorflow 在 pytorch 1.2 中為我工作。
你試過瞄准嗎? 它是為 PyTorch 構建的。 用於記錄和比較指標的最簡單、最方便的工具(TensorBoard 中沒有許多高級比較功能)。
我已經搞定了:
conda install -y tensorboard
之前沒有問題,所以我不知道為什么那行不通。 這是最簡單的。
我遇到了同樣的錯誤,當時我的 conda 也沒有工作,所以我選擇使用tensorboardX
,它與tensorboard
(也是它的操作)。
只需安裝它pip install tensorboardX
您可以使用from tensorboardX import SummaryWriter
導入它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.