【debug】Reusing TensorBoard on port 6006

项目场景:

用tensoboard 在jupyter notebook 中可视化train/loss


问题描述

如果跑过一次示例, 再跑第二次tensorboard就会坚持端口“6006”被使用了, 但是其实并没有, 就算杀死了已经在进行的process,还是会报这个错, 以及展示白板。

Reusing TensorBoard on port 6006 (pid 15092), started 0:14:16 ago. (Use '!kill 15092' to kill it.)

在这里插入图片描述
!!!but no process is using port “6006”

原因分析:

tensorboard 的官方团队回应说这是一个bug,因为tensorboard 没有动态清除.tensorboard-info 的习惯(缓存), 所以除非认为手动清除.tensorboard- info, tensorboard 会一直以为你在使用那个之前使用的端口。

解决方案:

  1. crude solution:
    change the port that tensorboard is bind to every time after you run.
  2. the hard way:
    find the darn tensorbard-info file and remove it

从官方文档中可以看见, .tensorboard-info 存在python 指定的放temp file 的地方
我们将用python 递归删除.tensorboard-info
在这里插入图片描述

找到.tensorboard-info 的path

tb_info_dir = os.path.join(tempfile.gettempdir(), '.tensorboard-info')

递归删除.tensorbard-info

import shutil
tb_info_dir = os.path.join(tempfile.gettempdir(), '.tensorboard-info')
shutil.rmtree(tb_info_dir)

已经验证可以实现tensorboard临时文件删除,解决反复执行端口占用的问题

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值