Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W&B Bug in Kaggle Notebook #1372

Closed
glenn-jocher opened this issue Nov 12, 2020 · 17 comments
Closed

W&B Bug in Kaggle Notebook #1372

glenn-jocher opened this issue Nov 12, 2020 · 17 comments
Assignees
Labels
bug Something isn't working Stale

Comments

@glenn-jocher
Copy link
Member

glenn-jocher commented Nov 12, 2020

🐛 Bug

It is impossible to select a W&B option in the Kaggle notebook when training (on Chrome at least, other browsers not tested). This problem is compounded by the fact that wandb appears to be a default package in the kaggle notebook environment, meaning the issue is impossible to avoid by default. @AyushExel can you take a look at this please?
Screenshot 2020-11-12 at 12 12 29

To Reproduce (REQUIRED)

  1. Run Setup cell
  2. Run Train cell here and try to select a W&B option

Screenshot 2020-11-12 at 12 13 49

Environment

https://www.kaggle.com/ultralytics/yolov5

@glenn-jocher glenn-jocher added bug Something isn't working TODO labels Nov 12, 2020
@glenn-jocher glenn-jocher self-assigned this Nov 12, 2020
@AyushExel
Copy link
Contributor

@glenn-jocher seems like a kaggle kernel specific problem. This doesn't happen on colab. There's a simple workaround that I just tested. Calling wandb.login() manually solves this problem.
Screenshot (171)

@glenn-jocher
Copy link
Member Author

@AyushExel what do you think the best way to handle this is uniformly between the Colab and Kaggle notebooks? We need to maintain a single base notebook for reduced maintenance.

I was thinking maybe a seperate code block before train, that would install and init with a single click?

In any case you probably want to pass this failure mode up to the maintainers of the login code to see if they can get this working natively in kaggle also.

@AyushExel
Copy link
Contributor

@glenn-jocher Yes a separate init block before training would be the way to go for now. I'll pass this on to the maintainers. Right now the team is busy launching this awesome dataset visualization feature that I told you about. But this will be fixed as soon as they're done with the launch.

@glenn-jocher
Copy link
Member Author

glenn-jocher commented Nov 22, 2020

Saving this here, can be inlined after existing # Start tensorboard (optional) cell.

# Start Weights & Biases (optional)
%pip install -q wandb  #  use 'wandb disable'/'wandb enable' to turn off/on
!wandb login  

@glenn-jocher
Copy link
Member Author

@AyushExel I tested the Kaggle notebook again and this bug is resolved now :)

It appears that wandb is no longer a default installed package in their notebook environment, so the model trains without asking for a wandb login now. When I try to install wandb though I'm not able to paste in my key still. This happens to me in Chrome, I have not tested other browsers. The same op works fine in the Colab notebook, but Kaggle in particular seems to have issues with their UI when it comes to inserting values at prompts. Have you been able to complete this login in a kaggle notebook?

Screen Shot 2020-12-08 at 7 31 06 AM

@AyushExel
Copy link
Contributor

@glenn-jocher I'll file a ticket today to get this fixed. I filed them for media panel viewing error and Recursion depth error but this error slipped out of my mind.
Also, I needed help with a code snippet from yolo repo. Can you please check your slack?

@glenn-jocher
Copy link
Member Author

@AyushExel great, thanks! I just arrived in California, I have to take care of a few things, but I will get back on Slack later today.

@glenn-jocher
Copy link
Member Author

@AyushExel verified this issue still exists in the latest (version 9) notebook today March 4th.

@AyushExel
Copy link
Contributor

AyushExel commented Mar 5, 2021

The issue occurs because Kaggle doesn't allow passing password in traditional way. you cannot directly copy a secret in kaggle console. Here the workaround is to save the API key as a kaggle secret.
Steps:
Click on add-ons in the kernel -> secrets -> add secret
Now copy the api key from wandb.ai/settings under any name you desire( in this case it's "wandb-key")
Screenshot from 2021-03-05 21-14-45

import wandb
 from kaggle_secrets import UserSecretsClient
 user_secrets = UserSecretsClient() 

personal_key_for_api = user_secrets.get_secret("wandb-key")

! wandb login $personal_key_for_api

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@glenn-jocher
Copy link
Member Author

Removing TODO as this is now fixed with the new python login commands now in our Google and Kaggle notebooks:
https://colab.research.google.com/github/ultralytics/yolov5/blob/master/tutorial.ipynb#scrollTo=2fLAV42oNb7M&line=1&uniqifier=1

# Weights & Biases  (optional)
%pip install -q wandb
import wandb
wandb.login()

@valmetisrinivas
Copy link

Hello, I am trying to run my Kaggle notebook in offline mode (with internet off) for a code submission competition. While training WANDB is getting activated and returning an error as it cannot access my WANDB account due to the internet being off. How to avoid wandb while training is on in the kernel? Appreciate inputs.

@glenn-jocher
Copy link
Member Author

@valmetisrinivas you can avoid the WANDB activation by removing the WANDB library import and the WANDB logging code from your notebook. This will prevent any attempts to access your WANDB account when running the code. Simply comment out or remove the following lines:

import wandb
wandb.init()

By doing this, you can run your Kaggle notebook in offline mode without any issues related to WANDB. Good luck with your code submission competition!

@valmetisrinivas
Copy link

@glenn-jocher , I did try what you suggested and a few more. But none had worked. Finally, os.environ[“WANDB_DISABLED”] = “true” as suggested here worked

@glenn-jocher
Copy link
Member Author

@valmetisrinivas glad to hear that you found a workaround for disabling WANDB during training by setting os.environ["WANDB_DISABLED"] = "true". Thank you for sharing the solution and the link to the discussion. This will be helpful for others who may encounter a similar issue. If you have any further questions or need any more assistance, feel free to ask.

Happy coding!

@valmetisrinivas
Copy link

valmetisrinivas commented Aug 23, 2023 via email

@glenn-jocher
Copy link
Member Author

@valmetisrinivas Glad to hear that you found a workaround for disabling WANDB during training by setting os.environ["WANDB_DISABLED"] = "true". Thank you for sharing the solution. This will be helpful for others who may encounter a similar issue. If you have any further questions or need any more assistance, feel free to ask.

Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

3 participants