Login or init error in google colab

I am getting some errors when running wandb on google colab.

  1. wandb.login() not working
    It will run for a while, and then the screen will change to a white Google Chrome error screen, showing error code 5.

If I refresh Chrome and go back to colab, wandb.login is still running and if you force it to stop, you will see an error message like below.

---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-2-f4bc2b362420> in <cell line: 1>()
----> 1 wandb.login()

7 frames
/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in login(anonymous, key, relogin, host, force, timeout)
     75         return True
     76     kwargs = dict(locals())
---> 77     configured = _login(**kwargs)
     78     return True if configured else False
     79 

/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in _login(anonymous, key, relogin, host, force, timeout, _backend, _silent, _disable_warning, _entity)
    296 
    297     if not key:
--> 298         wlogin.prompt_api_key()
    299 
    300     # make sure login credentials get to the backend

/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in prompt_api_key(self)
    219 
    220     def prompt_api_key(self):
--> 221         key, status = self._prompt_api_key()
    222         if status == ApiKeyStatus.NOTTY:
    223             directive = (

/usr/local/lib/python3.10/dist-packages/wandb/sdk/wandb_login.py in _prompt_api_key(self)
    199         while True:
    200             try:
--> 201                 key = apikey.prompt_api_key(
    202                     self._settings,
    203                     api=api,

/usr/local/lib/python3.10/dist-packages/wandb/sdk/lib/apikey.py in prompt_api_key(settings, api, input_callback, browser_callback, no_offline, no_create, local)
     88     if jupyter and "google.colab" in sys.modules:
     89         log_string = term.LOG_STRING_NOCOLOR
---> 90         key = wandb.jupyter.attempt_colab_login(app_url)
     91         if key is not None:
     92             write_key(settings, key, api=api)

/usr/local/lib/python3.10/dist-packages/wandb/jupyter.py in attempt_colab_login(app_url)
    321     )
    322     try:
--> 323         return output.eval_js("_wandbApiKey")
    324     except MessageError:
    325         return None

/usr/local/lib/python3.10/dist-packages/google/colab/output/_js.py in eval_js(script, ignore_result, timeout_sec)
     38   if ignore_result:
     39     return
---> 40   return _message.read_reply_from_input(request_id, timeout_sec)
     41 
     42 

/usr/local/lib/python3.10/dist-packages/google/colab/_message.py in read_reply_from_input(message_id, timeout_sec)
     94     reply = _read_next_input_message()
     95     if reply == _NOT_READY or not isinstance(reply, dict):
---> 96       time.sleep(0.025)
     97       continue
     98     if (

KeyboardInterrupt: 

The commands below sometimes work to log in.

! wandb login

Sometimes wandb.init() doesn’t work well even if the login is successful. When i run wandb.init() or run the next cell after init, colab runtime will be disconnected and reconnected after a small wait. After that, logging is sometimes fine. However, this disconnection is very disruptive for iterative experiments.

Hey gnokim,

Sorry to hear this is happening. I have a few questions to help me investigate this issue further:

  • What version of wandb are you running?
  • Even after resetting the Colab runtime, does this still occur?
  • What happens when you try to log in via wandb.login(key='YOUR_API_KEY')?
  • Could you elaborate on what you mean by “wandb.init() doesn’t work well even if the login is successful” ? Does this mean you are able to initialize a wandb run, but it is slow? Or is it unable to be spun up at all?

Thanks for providing this information!

Best,

Uma

1 Like

Hi gnokim, since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!

Sorry for the late reply, I missed yours, I’m still stuck on the issue, I’ll reply soon.

https://drive.google.com/drive/folders/1tnNOmO7dYMnVPk6TjbBF_qmOXfnHxklX?usp=sharing

The code below sometimes works and sometimes doesn’t.
wandb.login(key=‘YOUR_API_KEY’)

The main problem is that it doesn’t run smoothly from login to init.

Hey @gno33, I recommend continuing to use the workaround with ! wandb login for the time being, as well as trying the following:

  • Running wandb in offline mode. Documentation can be found here and here’s the documentation on saving metrics offline and syncing them to wandb later
  • Disabling any firewalls that could be interfering with the network

Please let me know if any of these suggestions help in any way.

Hi @gno33, since we have not heard back from you we are going to close this request. If you would like to re-open the conversation, please let us know!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.