简体   繁体   English

为 Joe Laba 的“Hands-On Tensorboard for Developers”中的代码运行 tensorboard

[英]running tensorboard for the code in “Hands-On Tensorboard for Developers” by Joe Laba

I am attempting to run the code in Video 1.3 of this series on a Windows 10 machine.我正在尝试在 Windows 10 机器上运行本系列视频 1.3 中的代码。 I am using the VScode IDE with Python 3.7 64 bit IDE from the Miniconda3 distribution.我正在使用来自 Miniconda3 发行版的 VScode IDE 和 Python 3.7 64 位 IDE。 I have solved many config errors between versions of tensorflow, tensorboard, and Cuda and have generated a run file.我已经解决了 tensorflow、tensorboard 和 Cuda 版本之间的许多配置错误,并生成了一个运行文件。 Running tensorboard --logfile=./runfile from the directory now runs without and error but it does nothing.从目录运行 tensorboard --logfile=./runfile 现在运行没有错误,但它什么也不做。 Does not output a URL and when I try to open localhost:6006 from my Firefox browser, it can't find it.不是 output 和 URL 并且当我尝试从我的 Firefox 浏览器打开 localhost:6006 时,它找不到它。 I love puzzles but am now frustrated.我喜欢拼图,但现在很沮丧。

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

After researching the source docs for VS2019 environments and PED-514 I removed multiple unused environments.在研究了 VS2019 环境和 PED-514 的源文档后,我删除了多个未使用的环境。 then I did pip3 uninstall... of multiple versions of tensorflow, tensorboard and numpy.然后我做了 pip3 卸载... tensorflow、张量板和 numpy 的多个版本。 then I did pip install of compatible versions of tensorflow (2.1.0), tensorboard (2.1.1) and numpy (1.18.3).然后我安装了 pip 兼容版本的 tensorflow (2.1.0)、张量板 (2.1.1) 和 numpy (1.183)。 Now things look great.现在事情看起来很棒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM