Error related to pytorch lightning
Closed this issue · 3 comments
When I download pytorch ligthning version 1.3.3 and try to run the code, I got this message.
How can I fix the code to run it?
File "/opt/conda/lib/python3.7/site-packages/pytorch_lightning/metrics/utils.py", line 22, in
from torchmetrics.utilities.data import get_num_classes as _get_num_classes
ImportError: cannot import name 'get_num_classes' from 'torchmetrics.utilities.data' (/opt/conda/lib/python3.7/site-packages/torchmetrics/utilities/data.py)
This seems to be something related to pytorch lightning, because when I change to version 1.6.1, I receive other error:
File "./humus_examples/train_humus_fastmri.py", line 27, in
from pl_modules.humus_module import HUMUSNetModule
File "/workspace/MRISRNET/pl_modules/humus_module.py", line 7, in
from fastmri.pl_modules import MriModule
File "/opt/conda/lib/python3.7/site-packages/fastmri/pl_modules/init.py", line 8, in
from .mri_module import MriModule
File "/opt/conda/lib/python3.7/site-packages/fastmri/pl_modules/mri_module.py", line 20, in
class DistributedMetricSum(pl.metrics.Metric):
AttributeError: module 'pytorch_lightning' has no attribute 'metrics'
Which part of the code should I modify to run the code with updated pytorch lightning version?
Thanks for raising this issue. It looks like pytorch-lightning==1.3.3
is not compatible with newer versions of torchmetrics
. A quick fix in your case would be to downgrade torchmetrics
to v0.7.3
:
pip3 install torchmetrics==0.7.3
I updated the requirements and installation instructions accordingly in the README.
I don't recommend using a newer version of pytorch-lightning
as it would take a bit more work to make it compatible with the current version of the code.
It works now, thank you!
At first it seems to be working so I closed the issue, but actually wasn't... which led to another issue. Since it seems to be a different issue, I opened another one.