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

Which PyTorch Lightning version to use? #7

Closed
sgvaze opened this issue Jul 13, 2022 · 2 comments
Closed

Which PyTorch Lightning version to use? #7

sgvaze opened this issue Jul 13, 2022 · 2 comments

Comments

@sgvaze
Copy link

sgvaze commented Jul 13, 2022

Hello, thanks for the great work!

I am trying to run your code, but there are issues with PyTorch Lightning (specifically the API changes very quickly).

If run with the latest version (1.6.5 at the moment), an error is thrown because val_dataloaders is not a valid argument for Trainer.validate:

trainer.validate(model, val_dataloaders = dloaders, ckpt_path=None, verbose=True) # set ckpt_path to None

However, if I revert to 1.3.1 (specified here), then an error is thrown as it cannot import lightning from pytorch_lightning.core (see full traceback below).

After some trial and error, I found 1.5.1 works. Perhaps this could be specified in the README?

P.S:

  File "/private/home/sgvaze/CIRPLANT/trainval_oscar.py", line 242, in <module>
    from _trainval_base import init_main
  File "/private/home/sgvaze/CIRPLANT/_trainval_base.py", line 34, in <module>
    from pytorch_lightning.core import lightning
  File "/private/home/sgvaze/miniconda3/envs/cirr/lib/python3.9/site-packages/pytorch_lightning/__init__.py", line 20, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/private/home/sgvaze/miniconda3/envs/cirr/lib/python3.9/site-packages/pytorch_lightning/metrics/__init__.py", line 15, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/private/home/sgvaze/miniconda3/envs/cirr/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File "/private/home/sgvaze/miniconda3/envs/cirr/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.utils import deprecated_metrics, void
  File "/private/home/sgvaze/miniconda3/envs/cirr/lib/python3.9/site-packages/pytorch_lightning/metrics/utils.py", line 22, in <module>
    from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/private/home/sgvaze/miniconda3/envs/cirr/lib/python3.9/site-packages/torchmetrics/utilities/data.py)```
@Cuberick-Orion
Copy link
Owner

Cuberick-Orion commented Jul 14, 2022

Hi sgvaze,

Thanks for pointing it out -- indeed, the PytorchLightning API changes quite frequently. I will add the recommended version as 1.5.1 in README.

As a side note, for the most part, I found that the errors associated with API changes can usually be resolved with minor changes though. In the case of val_dataloaders, I believe the newer versions use the argument dataloaders instead.

@Cuberick-Orion
Copy link
Owner

Cuberick-Orion commented Jul 14, 2022

Installation instruction updated at a294f19.

pip requirement updated at 81722fd.

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