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

rank_zero_only moved to lightning.fabric.utilities.rank_zero #2

Open
stroebel opened this issue Aug 5, 2023 · 4 comments
Open

rank_zero_only moved to lightning.fabric.utilities.rank_zero #2

stroebel opened this issue Aug 5, 2023 · 4 comments

Comments

@stroebel
Copy link

stroebel commented Aug 5, 2023

https://github.com/intro-stat-learning/ISLP/blob/bd0af3474fb4b6306c749a194b350199cd332a49/ISLP/torch/lightning.py#L17C51-L17C51

The fix for this is possibly to pin pytorch_lightning to <2.0 or to change the import to from pytorch_lightning.utilities.rank_zero import rank_zero_only.

I can confirm that the import at that location works. I haven't tested it against the lab for Ch10 yet though.

There is a similar issue for the seed_everything import for ch10. That can be handled by installing the entire lightning package and changing the import to from lightning_fabric.utilities.seed import seed_everything. Pinning pytorch_lightning might be the better course of action in this case.

@jonathan-taylor
Copy link
Collaborator

jonathan-taylor commented Aug 20, 2023

I think these imports were the earlier locations for these libraries. This import is fine for pytorch_lightning==2.0.6

What version of ISLP/ISLP_labs are you trying to run this on and encountering errors? Do you have a traceback?

In terms of pinning libraries, this is what tags on ISLP_labs will do, though I see these have somehow become unpinned on v2: https://github.com/intro-stat-learning/ISLP_labs/blob/v2/requirements.txt.

This is the frozen version for v2 https://github.com/intro-stat-learning/ISLP_labs/blob/v2_devel/requirements.txt -- when we push a new tag I will ensure that the requirements are frozen once again.

@stroebel
Copy link
Author

I managed to some of the way through the Ch10 lab using the changes that I recommended above. I hit a roadblock again with lightning requiring Accuracy to be passed a positional argument.

It looks like I am a few patch versions behind for ISLP, I will update and see if that fixes my issue.

image image
TypeError                                 Traceback (most recent call last)
[/Volumes/untitled/tx/learning/deep_learning.py](https://file+.vscode-resource.vscode-cdn.net/Volumes/untitled/tx/learning/deep_learning.py) in line 2
      [167](file:///Volumes/untitled/tx/learning/deep_learning.py?line=166) # %%
----> [168](file:///Volumes/untitled/tx/learning/deep_learning.py?line=167) mnist_module = SimpleModule.classification(mnist_model)
      [169](file:///Volumes/untitled/tx/learning/deep_learning.py?line=168) mnist_logger = CSVLogger("logs", name="MNIST")

File [~/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py:216](https://file+.vscode-resource.vscode-cdn.net/Volumes/untitled/tx/learning/~/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py:216), in SimpleModule.classification(model, metrics, device, **kwargs)
    [214](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=213) loss = nn.CrossEntropyLoss()
    [215](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=214) if 'accuracy' not in metrics:
--> [216](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=215)     metrics['accuracy'] = Accuracy()
    [217](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=216) if device is not None:
    [218](file:///Users/kolmogrov/mambaforge/envs/learning/lib/python3.10/site-packages/ISLP/torch/lightning.py?line=217)     for key, metric in metrics:

TypeError: Accuracy.__new__() missing 1 required positional argument: 'task'

ps. Thank you for your book. I have worked through the rest of the labs and they are great.

@jonathan-taylor
Copy link
Collaborator

jonathan-taylor commented Aug 21, 2023 via email

@jonathan-taylor
Copy link
Collaborator

jonathan-taylor commented Aug 21, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants