我可以将 TensorBoard 与 Google Colab 一起使用吗? [英] Can I use TensorBoard with Google Colab?

查看:43
本文介绍了我可以将 TensorBoard 与 Google Colab 一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Google Colab 上训练 TensorFlow 模型时,有没有办法使用 TensorBoard?

Is there any way to use TensorBoard when training a TensorFlow model on Google Colab?

推荐答案

你可能想给官方 %tensorboard 魔法,从 TensorFlow 1.13 开始可用.

You probably want to give the official %tensorboard magic a go, available from TensorFlow 1.13 onward.

%tensorboard 魔法存在之前,标准的方法是实现这一点是使用代理网络流量到 Colab VMngrok.Colab 示例可以在此处找到.

Prior to the existence of the %tensorboard magic, the standard way to achieve this was to proxy network traffic to the Colab VM using ngrok. A Colab example can be found here.

这些是步骤(代码片段代表 colab 中代码"类型的单元格):

These are the steps (the code snippets represent cells of type "code" in colab):

  1. 让 TensorBoard 在后台运行.
    灵感来自这个答案.

LOG_DIR = '/tmp/log'
get_ipython().system_raw(
    'tensorboard --logdir {} --host 0.0.0.0 --port 6006 &'
    .format(LOG_DIR)
)

  • 下载并解压缩 ngrok.
    将传递给 wget 的链接替换为适用于您的操作系统的正确下载链接.

  • Download and unzip ngrok.
    Replace the link passed to wget with the correct download link for your OS.

    ! wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
    ! unzip ngrok-stable-linux-amd64.zip
    

  • 启动 ngrok 后台进程...

  • Launch ngrok background process...

    get_ipython().system_raw('./ngrok http 6006 &')
    

    ...并检索公共网址.来源

    ...and retrieve public url. Source

    ! curl -s http://localhost:4040/api/tunnels | python3 -c 
        "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])"
    

  • 这篇关于我可以将 TensorBoard 与 Google Colab 一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆