执行 tensorboard --logdir logs之后遇到的浏览器中输入http://localhost:6006 网址打不开的问题

本文介绍了解决在Windows环境下使用TensorBoard时遇到的浏览器无法访问http://localhost:6006的问题,包括修改主机用户名为localhost及正确启动TensorBoard服务的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


该博文撰写时间较早, 适用于 windows 用户本地运行和访问,解决  http://localhost:6006  网址都打不开的问题;

如果是服务器开启服务,然后本机浏览器端通过 ip + 端口 方式进行访问,请直接移步参考我的另一篇博文:

tensorboard: command not found 命令报错 | 简记


最近学习莫凡的Python的TensorFlow视频教程,学习到Tensorboard 可视化好帮手 1这一节时,执行 tensorboard --logdir logs之后遇到的浏览器中输入http://localhost:6006 网址打不开的问题。

视频教程链接如下:Tensorboard 可视化好帮手 1

下载Tensorboard 可视化好帮手 1的相关代码如下(保存代码的文件名为testView.py):

import tensorflow as tf


def add_layer(inputs, in_size, out_size, activation_function=None):
    # add one more layer and return the output of this layer
    with tf.name_scope('layer'):
        with tf.name_scope('weights'):
            Weights = tf.Variable(tf.random_normal([in_size, out_size]), name='W')
        with tf.name_scope('biases'):
            biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, name='b')
        with tf.name_scope('Wx_plus_b'):
            Wx_plus_b = tf.add(tf.matmul(inputs, Weights), biases)
        if activation_function is None:
            outputs = Wx_plus_b
        else:
            outputs = activation_function(Wx_plus_b, )
        return outputs


# define placeholder for inputs to network
with tf.name_scope('inputs'):
    xs = tf.placeholder(tf.float32, [None, 1], name='x_input')
    ys = tf.placeholder(tf.float32, [None, 1], name='y_input')

# add hidden layer
l1 = add_layer(xs, 1, 10, activation_function=tf.nn.relu)
# add output layer
prediction = add_layer(l1, 10, 1, activation_function=None)

# the error between prediciton and real data
with tf.name_scope('loss'):
    loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
                                        reduction_indices=[1]))

with tf.name_scope('train'):
    train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)

sess = tf.Session()

# tf.train.SummaryWriter soon be deprecated, use following
if int((tf.__version__).split('.')[1]) < 12 and int((tf.__version__).split('.')[0]) < 1:  # tensorflow version < 0.12
    writer = tf.train.SummaryWriter('logs/', sess.graph)
else: # tensorflow version >= 0.12
    writer = tf.summary.FileWriter("logs/", sess.graph)

# tf.initialize_all_variables() no long valid from
# 2017-03-02 if using tensorflow >= 0.12
if int((tf.__version__).split('.')[1]) < 12 and int((tf.__version__).split('.')[0]) < 1:
    init = tf.initialize_all_variables()
else:
    init = tf.global_variables_initializer()
sess.run(init)

①打开cmd命令窗口,进入该代码文件所在文件夹目录,执行

python testView.py

发现生成 logs 文件夹 ,文件夹内有文件  events.out.tfevents.1531791823.ZQL ,后缀ZQL即为我电脑的用户名

②接着执行

tensorboard --logdir logs

输出:TensorBoard 1.9.0 at http://ZQL:6006 (Press CTRL+C to quit)

我的用户名出现在了这个要打开的链接里,此时我打开chrome浏览器,访问    http://localhost:6006 或者 http://ZQL:6006 ,网址都打不开。

我强烈怀疑是用户名的原因,于是把主机的用户名   ZQL   修改为   localhost  (Win10系统主机用户名修改(修改后需要重启电脑),修改方法请自行百度) 

最后,修改完用户名之后,再次重复①②两个步骤,输出:TensorBoard 1.9.0 at http://localhost:6006 (Press CTRL+C to quit)

此时在chrome浏览器,访问  http://localhost:6006 或者   http://127.0.0.1:6006便可成功打开我们想要的Tensorboard 可视化页面


声明重申:

  • 本博文适用于 windows 用户本地运行和访问,解决  http://localhost:6006  网址都打不开的问题;
  • 如果是服务器开启服务,然后本机浏览器端通过 ip + 端口 方式进行访问,请直接移步参考我的另一篇博文:

tensorboard: command not found 命令报错 | 简记https://positive.blog.csdn.net/article/details/109722702


 

# 执行预览命令(GPU设为0) python run_train.py --view='train' --gpu='0' # 预期结果:弹出图像窗口显示增强后的训练样本 # === 步骤4:启动训练 === # 测试运行(观察是否报错) python run_train.py --gpu='0' # 正式训练(后台运行) # Linux/macOS: nohup python run_train.py --gpu='0' > train.log 2>&1 & # Windows: start /B python run_train.py --gpu="0" > train.log 2>&1 # === 步骤5:监控训练 === # 监控显存使用(每1秒刷新) # Linux/macOS: watch -n 1 nvidia-smi # Windows: # 创建 watch_gpu.bat 文件,内容: :loop nvidia-smi timeout /t 1 > nul cls goto loop # 查看训练日志(实时更新) # Linux/macOS: tail -f train.log # Windows: # 创建 tail_log.bat 文件,内容: @echo off :loop tail -n 10 train.log timeout /t 1 > nul cls goto loop # === 步骤6:TensorBoard可视化 === # 1. 新开终端窗口 # 2. 进入项目目录 cd /path/to/hovernet_project # 3. 启动TensorBoard tensorboard --logdir=logs --port=6006 # 4. 浏览器访问 # 打开 Chrome/Firefox 输入http://localhost:6006 这一部分我不理解的原因: 1)python run_train.py --view='train' --gpu='0'这不就是直接开始训练了吗,怎么又说是预览?“# 预期结果:弹出图像窗口显示增强后的训练样本”这句话什么意思? 2)start /B python run_train.py --gpu="0" > train.log 2>&1这条代码我看不懂 3)我现在很不理解,我已经开始训练了,那么在训练结束前,我怎么输入监控训练部分的指令?# 创建 watch_gpu.bat 文件,内容: :loop nvidia-smi timeout /t 1 > nul cls goto loop # 查看训练日志(实时更新) # Linux/macOS: tail -f train.log # Windows: # 创建 tail_log.bat 文件,内容: @echo off :loop tail -n 10 train.log timeout /t 1 > nul cls goto loop # === 步骤6:TensorBoard可视化 === # 1. 新开终端窗口 # 2. 进入项目目录 cd /path/to/hovernet_project # 3. 启动TensorBoard tensorboard --logdir=logs --port=6006 # 4. 浏览器访问 # 打开 Chrome/Firefox 输入http://localhost:6006 这部分怎么实现
最新发布
08-15
评论 30
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

墨理学AI

不必打赏,关注博主公众号即可

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值