tensorboard-PermissionError-13

症状

运行 tensorboard --logdir .

报错

tensorboard 8 <module>
sys.exit(run_main())

main.py 75 run_main
app.run(tensorboard.main, flags_parser=tensorboard.configure)

app.py 299 run
_run_main(main, args)

app.py 250 _run_main
sys.exit(main(argv))

program.py 290 main
return runner(self.flags) or 0

program.py 308 _run_serve_subcommand
self._register_info(server)

program.py 356 _register_info
manager.write_info_file(info)

manager.py 262 write_info_file
with open(_get_info_file_path(), "w") as outfile:

PermissionError:
13
Permission denied

原因

当前用户没有/tmp/.tensorboard-info的读写权限, 故而tensorborad无法写入临时目录

对策

  • 若有root权限

    sudo chmod 777 /tmp/.tensorboard-info
    sudo chown root:root /tmp/.tensorboard-info

    然后运行tensorboard --logdir .

  • 若无root权限

    # 申明环境变量
    export TMPDIR=/tmp/$USER;
    # 创建目录
    mkdir -p $TMPDIR;

    然后运行tensorboard --logdir .