【问题标题】:running tensorboard for the code in "Hands-On Tensorboard for Developers" by Joe Laba为 Joe Laba 的“Hands-On Tensorboard for Developers”中的代码运行 tensorboard
【发布时间】:2020-08-08 17:22:26
【问题描述】:

我正在尝试在 Windows 10 机器上运行本系列视频 1.3 中的代码。我正在使用来自 Miniconda3 发行版的 VScode IDE 和 Python 3.7 64 位 IDE。我已经解决了 tensorflow、tensorboard 和 Cuda 版本之间的许多配置错误,并生成了一个运行文件。从目录运行 tensorboard --logfile=./runfile 现在运行没有错误,但它什么也不做。不输出 URL,当我尝试从 Firefox 浏览器打开 localhost:6006 时,它找不到它。我喜欢拼图,但现在很沮丧。

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

#import numpy as np #Change all calls to numpy instead of np or set np = numpy
import os
import sys
import argparse

"""
This code implements the tensor board programming from 
the book "Hands-On TensorBoard for PyTorch Developers [Video]" by joe Laba
The book/videos use Tensorboard 2.0.2, Torch 1.3.1.
It requires the use of the Python 3.7 64 bit environment which comes from 
the Miniconda3 folder. This upgrades to the following packages;
numpy (1.17.2)
pillow (7.1.1)
python (3.7.1)
pytorch (1.2.0)
scipy(1.3.1)
tensorboard(2.1.1)
tensorflow(2.1.0)
tensorflow-gpu (2.1.0)
theano(1.0.1)
torchvision (0.4.0)

Which compiles with no errors
NVidia driver 441.22
cuDnn 7.6.5
Cuda 10.2.95

"""
###################################################################
# Variables                                                       #
# When launching project or scripts from Visual Studio,           #
# input_dir and output_dir are passed as arguments automatically. #
# Users could set them from the project setting page.             #
###################################################################

input_dir = None
output_dir = None
log_dir = None

#################################################################################
# PyTorch imports.                                                               #
#################################################################################
import tensorflow
import tensorboard
#from tensorflow.python.keras.callbaccks import Tensorboard
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.utils.tensorboard import SummaryWriter



def main():
    print("I am now in main")
    # Set up Tensorboard
    #Writer will output to ./runs/ directory by default
    writer = SummaryWriter()

    for x in range(5):
        y=100*x
        writer.add_scalar ('y',y,x)

    writer.close()
    print("done with writer")
    print("more done with writer")


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--input_dir", type=str, 
                        default=None, 
                        help="Input directory where where training dataset and                  metadata are saved", 
                        required=False
                        )
    parser.add_argument("--output_dir", type=str, 
                        default=None, 
                        help="Input directory where where logs and models are saved", 
                        required=False
                        )

    args, unknown = parser.parse_known_args()
    input_dir = args.input_dir

    main() #This causes main to run

【问题讨论】:

    标签: python-3.x tensorboard


    【解决方案1】:

    在研究了 VS2019 环境和 PED-514 的源文档之后 我删除了多个未使用的环境。 然后我做了pip3卸载......多个版本的tensorflow,tensorboard和numpy。 然后我 pip install 了兼容版本的 tensorflow (2.1.0)、tensorboard (2.1.1) 和 numpy (1.18.3)。现在事情看起来很棒。

    【讨论】:

      猜你喜欢
      • 2016-08-16
      • 2018-12-04
      • 2020-12-19
      • 2021-11-04
      • 2019-12-18
      • 2016-08-03
      • 1970-01-01
      • 2020-12-29
      • 2020-04-14
      相关资源
      最近更新 更多