title: Tensorboard does not work properly when used from google Colab
body: <p>I am having a hard time to understand how to get Tensorboard work properly from a notebook running on Google Colab. I will post below a series of code snippets that I use to work with tensorboard.</p>
  <p>TensorFlow version:  2.2.0 <br>
  Eager mode:  True <br>
  Hub version:  0.8.0 <br>
  GPU is available <br></p>
  <pre class="lang-py prettyprint-override"><code>%load_ext tensorboard
  import tensorflow as tf
  from tensorboard.plugins.hparams import api as hp
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>callbacks = [
          
          EarlyStopping(monitor=monitor_metric,
                        min_delta=minimum_delta,
                        patience=patience_limit,
                        verbose=verbose_value,
                        mode=mode_value,
                        restore_best_weights=True),
  
          ModelCheckpoint(filepath=weights_fname,
                          monitor=monitor_metric,
                          verbose=verbose_value,
                          save_best_only=True,
                          save_weights_only=True),
          
          tf.keras.callbacks.TensorBoard(logdir), #used here
  
          TensorBoardColabCallback(tbc),
          
          hp.KerasCallback(logdir, hparams) #used here
      ]
      
      return callbacks
  </code></pre>
  <p>Initializing Hyper-parameters that will be logged by Tensorboard</p>
  <pre class="lang-py prettyprint-override"><code>HP_HIDDEN_UNITS = hp.HParam('batch_size', hp.Discrete([128]))
  HP_EMBEDDING_DIM = hp.HParam('embedding_dim', hp.Discrete([50, 100]))
  HP_LEARNING_RATE = hp.HParam('learning_rate', hp.Discrete([0.01])) # Adam default: 0.001, SGD default: 0.01, RMSprop default: 0.001
  HP_DECAY_STEPS_MULTIPLIER = hp.HParam('decay_steps_multiplier', hp.Discrete([10, 100]))
  
  METRIC_ACCURACY = &quot;hamming_loss&quot;
  </code></pre>
  <p>Write the hp parameters file to the logging directory of Tensorboard.</p>
  <pre class="lang-py prettyprint-override"><code>hp_logging_directory=os.path.join(os.getcwd(), &quot;model_one/logs/hparam_tuning&quot;)
  
  with tf.summary.create_file_writer(hp_logging_directory).as_default():
      hp.hparams_config(
      hparams=[HP_HIDDEN_UNITS, HP_EMBEDDING_DIM, HP_LEARNING_RATE, HP_DECAY_STEPS_MULTIPLIER],
      metrics=[hp.Metric(METRIC_ACCURACY, display_name='hamming_loss')],
    )
      
  try:
      os.path.exists(hp_logging_directory)
      print(&quot;Directory of hyper parameters logging exists!&quot;)
  except Exception as e:
      print(e)
      print(&quot;Directory not found!&quot;)
  </code></pre>
  <p>Calling the Tensorboard API</p>
  <pre class="lang-py prettyprint-override"><code>%tensorboard --logdir model_one/logs/hparam_tuning
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7xJrl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7xJrl.png" alt="enter image description here" /></a></p>
  <p>Links I have seen:</p>
  <ul>
  <li><a href="https://www.tensorflow.org/tensorboard/hyperparameter_tuning_with_hparams" rel="nofollow noreferrer">https://www.tensorflow.org/tensorboard/hyperparameter_tuning_with_hparams</a></li>
  <li>Stack Overflow <a href="https://stackoverflow.com/questions/47818822/can-i-use-tensorboard-with-google-colab">question</a> -&gt; Tried many different options from this question without any luck.</li>
  </ul>
  <p>I have also installed the TensorboardColab module</p>
  <pre class="lang-py prettyprint-override"><code>from tensorboardcolab import *
  
  tbc = TensorBoardColab() # To create a tensorboardcolab object it will automatically creat a link
  writer = tbc.get_writer() # To create a FileWriter
  writer.add_graph(tf.get_default_graph()) # add the graph 
  writer.flush()
  </code></pre>
  <p>Executing the above I get the following error: <code>AttributeError: module 'tensorboard.summary._tf.summary' has no attribute 'FileWriter'</code></p>
  <p>When I try to access the IP localhost:6006, I get the error that <em>This site can’t be reached</em></p>
  <p>Please check my <a href="https://colab.research.google.com/drive/1FqQjjB2xFFQCiAqZacvVsl5SU0kcJwGd?usp=sharing" rel="nofollow noreferrer">colab notebook</a> and kindly write in the comments if you miss any additional information that I might forget to include.</p>