wandb: wandb.login() hangs and then disconnects me every time I try on Google Colab

Description I’ve been using wandb and Google Colab successfully for the last couple of months. But over the last week, I have had so many connection issues.

One thing that has been happening all morning (the last 4 hours) is that when I run this code block, Colab hangs, then disconnects, and cannot reconnect for several minutes.

!pip install wandb -qqq
import wandb
from wandb.keras import WandbCallback
wandb.login()

It installs wandb and does both imports fine. But it hangs when it tries to do wandb.login().

Here’s the link but there isn’t much to see since no error message comes up.

Environment

  • Environment: Google Colab

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 13
  • Comments: 34 (5 by maintainers)

Most upvoted comments

We actually haven’t seen this one before. I’m not able to make it happen consistently. For others that are coming to this issue, the brute force way to login colab without producing this hang is:wandb.login(key="XXXXX"). Where key is your wandb API key from https://wandb.ai/authorize

It’s important to do do this in it’s own cell and not to save the notebook with your key in it to prevent other users viewing your notebook from having your credentials.

@maPiche thanks! I was able to reproduce the issue but I don’t understand the root cause. It seems to have something to do with some other data that’s been rendered in your notebook. If I create a new colab and call wandb.login() it works fine. I was able to find a super hacky workaround:

import sys

def wandb_colab_login():
  """Temporary hack to prevent colab from hanging"""
  sys.modules["google.colab2"] = sys.modules["google.colab"]
  del sys.modules["google.colab"]
  wandb.login()
  sys.modules["google.colab"] = sys.modules["google.colab2"]
wandb_colab_login()

I’ll keep digging and see if I can figure out what’s actually happening here… Thanks for reporting and providing the notebook!

Experiencing this issue at the moment, fwiw.

My “hack” around the issue was to use: wandb.login(relogin=True)

I’m not sure if this is a proper solution, as it worked after a few attempts at the original, parameter-less call, but I’ll update this issue with additional insights if I have any.

@ariG23498 setting wandb.init(settings=wandb.Settings(start_method="thread")) didn’t work because I was not logged in and so nothing happened.

@vanpelt setting wandb.login(key="XXXXX") in its own cell seems to have worked! Thank you!

Out of interest, why does it have to be in its own cell?