我正在尝试在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
研究了VS2019环境和PED-514的源文档之后我删除了多个未使用的环境。然后我做了pip3卸载...多个版本的tensorflow,tensorboard和numpy。然后我做了兼容版本的tensorflow(2.1.0),tensorboard(2.1.0)和numpy(1.18.3)的pip安装。现在情况看起来不错。