tensorflow / tensorboard

TensorFlow's Visualization Toolkit
Apache License 2.0
6.71k stars 1.66k forks source link

How to run already exist “events” from “logs” for Tensorboard in Google Colaboratory? #2167

Closed Alla-Abdella closed 2 years ago

Alla-Abdella commented 5 years ago

I have run a code for a Deep Generative model. And the code generates logs, checkpoints, and events files for Tensorboard:

Example of what shown in the files " Google Colab:

folder: content

.............experiments

.................mnist-experiment

........................checkpoints

........................logs

............................events.out.tfevents.15454....

I want to run the event file "events.out.tfevents.15454...." on Tensorboard in Colab and see the results their.

I tried this code:

You can change the directory name

LOG_DIR = 'tb_logs'

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

import os if not os.path.exists(LOG_DIR): os.makedirs(LOG_DIR)

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

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

!curl -s http://localhost:4040/api/tunnels | python3 -c \ "import sys, json; print(json.load(sys.stdin)['tunnels'][0] ['public_url'])" The code opens : inflating: ngrok https://0f1795c4.ngrok.io

However, it's empty. Nothing is shown in the Tensorboard What's missing to run the event file shown in the directory?

rmothukuru commented 5 years ago

@alla15747 , Can you please provide the information of the Browser you are using?

Alla-Abdella commented 5 years ago

@rmothukuru Thanks for your responding. my browser is Google chrome.

wchargin commented 5 years ago

Hi @alla15747! You can run TensorBoard directly within Colab without needing to configure ngrok or set up any tunnels at all. We have a tutorial on how to do that here:

https://www.tensorflow.org/tensorboard/r2/tensorboard_in_notebooks

For a quick summary:

  1. Make sure that you’re on the latest version of TensorFlow, either the stable branch or the TF 2.0 preview:

    # Either:
    !pip install -qU tf-nightly  # for stable branch
    # Or:
    !pip install -qU tf-nightly-2.0-preview  # for TF 2.0 preview
  2. Load the TensorBoard notebook extensions:

    %load_ext tensorboard
  3. Invoke TensorBoard starting with a %-sign:

    %tensorboard --logdir {LOG_DIR}

    You don’t need to specify port or host; this will be determined automatically.

Please let us know whether this works for you.

Alla-Abdella commented 5 years ago

Hi William, Thanks for your time and answer.

Unfortunately, it is not working.

To rephrase my question: First, I'm using Tensorflow and keras. The event file already created in the content colab after I trained my neural network. Now, simply, I just want to read the event file has been created in tensorboard.

Thank you!

wchargin commented 5 years ago

The workflow that I described works with TensorFlow and Keras, and works just fine with event files that have already been created in Colab. Your use case is basically exactly what this functionality is for.

You say, “Unfortunately, it is not working”. What’s not working? How?

IIIBlueberry commented 5 years ago

The workflow that I described works with TensorFlow and Keras, and works just fine with event files that have already been created in Colab. Your use case is basically exactly what this functionality is for.

You say, “Unfortunately, it is not working”. What’s not working? How?

I tried the demo link https://colab.research.google.com/github/tensorflow/tensorboard/blob/master/docs/r2/tensorboard_in_notebooks.ipynb but then i executing '%tensorboard --logdir logs' tensorboard does not show up i using firefox btw

wchargin commented 5 years ago

In Firefox, you may need to explicitly enable service workers:

Firefox Nightly: Go to about:config and set dom.serviceWorkers.enabled to true; restart browser.

In my testing, this also works in Firefox 60.6.1esr (no nightly needed).

We’ll add this to the documentation. Thanks for bringing it to our attention.

IIIBlueberry commented 5 years ago

In Firefox, you may need to explicitly enable service workers:

Firefox Nightly: Go to about:config and set dom.serviceWorkers.enabled to true; restart browser.

In my testing, this also works in Firefox 60.6.1esr (no nightly needed).

We’ll add this to the documentation. Thanks for bringing it to our attention.

But, 'dom.serviceWorkers.enabled' is already default to true on my firefox 66.0.3

JesminNipu commented 4 years ago

Hi @alla15747! You can run TensorBoard directly within Colab without needing to configure ngrok or set up any tunnels at all. We have a tutorial on how to do that here:

https://www.tensorflow.org/tensorboard/r2/tensorboard_in_notebooks

For a quick summary:

  1. Make sure that you’re on the latest version of TensorFlow, either the stable branch or the TF 2.0 preview:
    # Either:
    !pip install -qU tf-nightly  # for stable branch
    # Or:
    !pip install -qU tf-nightly-2.0-preview  # for TF 2.0 preview
  2. Load the TensorBoard notebook extensions:
    %load_ext tensorboard
  3. Invoke TensorBoard starting with a %-sign:

    %tensorboard --logdir {LOG_DIR}

    You don’t need to specify port or host; this will be determined automatically.

Please let us know whether this works for you.

ERROR: Failed to launch TensorBoard (exited with 1). Contents of stderr: Traceback (most recent call last): File "/usr/local/bin/tensorboard", line 8, in sys.exit(run_main()) File "/usr/local/lib/python3.6/dist-packages/tensorboard/main.py", line 59, in run_main default.get_plugins() + default.get_dynamic_plugins(), File "/usr/local/lib/python3.6/dist-packages/tensorboard/default.py", line 115, in get_dynamic_plugins for entry_point in pkg_resources.iter_entry_points('tensorboard_plugins') File "/usr/local/lib/python3.6/dist-packages/tensorboard/default.py", line 115, in for entry_point in pkg_resources.iter_entry_points('tensorboard_plugins') File "/usr/local/lib/python3.6/dist-packages/pkg_resources/init.py", line 2442, in load self.require(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/pkg_resources/init.py", line 2465, in require items = working_set.resolve(reqs, env, installer, extras=self.extras) File "/usr/local/lib/python3.6/dist-packages/pkg_resources/init.py", line 791, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.VersionConflict: (grpcio 1.15.0 (/usr/local/lib/python3.6/dist-packages), Requirement.parse('grpcio>=1.24.3'))

wchargin commented 4 years ago

@JesminNipu: What you have posted seems unrelated to this issue. It’s a Python package version conflict, which I can’t reproduce on current Colab, and which is not related to service workers. If you continue to experience this issue, please open a new issue and follow the instructions in the issue template: https://github.com/tensorflow/tensorboard/issues/new/choose

sanatmpa1 commented 2 years ago

@alla15747,

We are checking to see if this is still an issue. Can you try using tensorboard --inspect --event_file=myevents.out and let us know if that's what you're looking for?. Also you can refer this link for a detailed answer. Thanks!

sanatmpa1 commented 2 years ago

@alla15747,

Closing this issue due to recent activity. Please reopen the issue if it still persists. Thanks!