question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visualization in tutorial not working in colab and remote setup

See original GitHub issue

I have tried running this tutorial both in google colab and in jupyterlab on a remote server setup.

https://ax.dev/tutorials/tune_cnn.html

Both times the render()-call returns an empty output.

This is the code, no changes from tutorial except installation of ax:

!pip install ax-platform
%%
import torch
import numpy as np

from ax.plot.contour import plot_contour
from ax.plot.trace import optimization_trace_single_method
from ax.service.managed_loop import optimize
from ax.utils.notebook.plotting import render, init_notebook_plotting
from ax.utils.tutorials.cnn_utils import load_mnist, train, evaluate, CNN

init_notebook_plotting()
%%
torch.manual_seed(12345)
dtype = torch.float
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
%%
BATCH_SIZE = 512
train_loader, valid_loader, test_loader = load_mnist(batch_size=BATCH_SIZE)
%%
def train_evaluate(parameterization):
    net = CNN()
    net = train(net=net, train_loader=train_loader, parameters=parameterization, dtype=dtype, device=device)
    return evaluate(
        net=net,
        data_loader=valid_loader,
        dtype=dtype,
        device=device,
    )
%%
best_parameters, values, experiment, model = optimize(
    parameters=[
        {"name": "lr", "type": "range", "bounds": [1e-6, 0.4], "log_scale": True},
        {"name": "momentum", "type": "range", "bounds": [0.0, 1.0]},
    ],
    evaluation_function=train_evaluate,
    objective_name='accuracy',
)
%%
render(plot_contour(model=model, param_x='lr', param_y='momentum', metric_name='accuracy'))

switching to classic jupyter notebook (in remote setup) as suggested in https://github.com/facebook/Ax/issues/94 doesn’t change anything.

pip freezes for both environments:

colab_pip_freeze.txt

jupyterlab_pip_freeze.txt

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
saitcakmakcommented, Apr 11, 2022

Here’s a simple workaround. Add

import plotly.io as pio
pio.renderers.default = "colab"

to the NB running on colab. The figure renders and is interactive 😃 (for smaller notebook file size at the expense of non-interactive plots, you can use “png” as the renderer)

Note: You also need to do !pip install kaleido.

Screen Shot 2022-04-11 at 4 19 06 PM
1reaction
2timesjaycommented, Jul 14, 2020

Still investigating colab half of this issue (realized this one was the right one to host discussion on).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Google Colab for Deep Learning
Since a Colab notebook can be accessed remotely from any machine through a browser, it's well suited for commercial purposes as well. In...
Read more >
Google Colab Tutorial for Data Scientists - DataCamp
A brief guide for navigating google colab to carry out data science coding and collaborating with other data scientists.
Read more >
Quick guide to run TensorBoard in Google Colab - DLology
We are going train a Keras model on Colab and visualize it while training with TensorBoard. But there is one thing we need...
Read more >
Web visualizer and Jupyter — Open3D 0.16.0 documentation
You first start the visualization server on a local or remote machine, and then the 3D models can be viewed from any device...
Read more >
PDF Google Colab - Tutorialspoint
in this tutorial, please notify us at contact@tutorialspoint.com ... Most importantly, it does not require a setup and the notebooks that ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found