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

Problem with solo - PyTorch Lightning #75

Closed
mari-ga opened this issue Aug 30, 2022 · 4 comments
Closed

Problem with solo - PyTorch Lightning #75

mari-ga opened this issue Aug 30, 2022 · 4 comments

Comments

@mari-ga
Copy link

mari-ga commented Aug 30, 2022

Hi everyone!

I've been facing an error for some time. When I first installed solo 1.3, PyTorch 1.3.1 was installed by default. With this configuration, it was impossible to even call solo on terminal (I'm working on Mac OS Monterey 12.4).
The error was the following one:

File "/opt/anaconda3/envs/demul/bin/solo", line 5, in <module>
    from solo.solo import main
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/solo/solo.py", line 15, in <module>
    from pytorch_lightning.callbacks.early_stopping import EarlyStopping
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/__init__.py", line 20, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/metrics/__init__.py", line 15, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/opt/anaconda3/envs/demul/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 "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.utils import deprecated_metrics
  File "/opt/anaconda3/envs/demul/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

This error is linked to the version of PyTorch, so updating the library to 1.3.8 or higher was a solution.
Anyways, after installing PyTorch lightning 1.3.8 and (later PyTorch lightning 1.7.3), calling the tool on terminal is possible, but it's producing the following error:

Global seed set to 0
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
Cuda is not available, switching to cpu running!
Global seed set to 2732
/opt/anaconda3/envs/demul/lib/python3.9/site-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function setup_anndata is deprecated; Please use the model-specific setup_anndata methods instead. The global method will be removed in version 0.15.0.
  warnings.warn(msg, category=FutureWarning)
INFO     No batch_key inputted, assuming all cells are same batch                                                                                                                        
INFO     No label_key inputted, assuming all cells have same label                                                                                                                       
INFO     Using data from adata.X                                                                                                                                                         
INFO     Successfully registered anndata object containing 4889 cells, 33694 vars, 1 batches, 1 labels, and 0 proteins. Also registered 0 extra categorical covariates and 0 extra       
         continuous covariates.                                                                                                                                                          
INFO     Please do not further modify adata until model is trained.                                                                                                                      
/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:53: LightningDeprecationWarning: pytorch_lightning.utilities.warnings.rank_zero_deprecation has been deprecated in v1.6 and will be removed in v1.8. Use the equivalent function from the pytorch_lightning.utilities.rank_zero module instead.
  new_rank_zero_deprecation(
/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/utilities/warnings.py:58: LightningDeprecationWarning: The `pytorch_lightning.loggers.base.LightningLoggerBase` is deprecated in v1.7 and will be removed in v1.9. Please use `pytorch_lightning.loggers.logger.Logger` instead.
  return new_rank_zero_deprecation(*args, **kwargs)
Traceback (most recent call last):
  File "/opt/anaconda3/envs/demul/bin/solo", line 8, in <module>
    sys.exit(main())
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/solo/solo.py", line 251, in main
    vae.train(
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/scvi/model/base/_training_mixin.py", line 69, in train
    runner = TrainRunner(
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/scvi/train/_trainrunner.py", line 66, in __init__
    self.trainer = Trainer(max_epochs=max_epochs, gpus=gpus, **trainer_kwargs)
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/scvi/train/_trainer.py", line 138, in __init__
    super().__init__(
  File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/utilities/argparse.py", line 345, in insert_env_defaults
    return fn(self, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'flush_logs_every_n_steps'

This error seems to be related to PyTorch Lightning. I called the tool with 2 different datasets and got similar errors, both pointing PyTorch Lightning as the reason.
Does anyone else have this error? Any help would be very appreciated.
Thank you very much in advance!

@cherriyoush
Copy link

hi,I have meet the same problem too,I try downgrade torchmetrics version pip uninstall torchmetrics==0.9.3 & pip install torchmetrics==0.6.0, then it works

@mari-ga
Copy link
Author

mari-ga commented Sep 5, 2022

hi,I have meet the same problem too,I try downgrade torchmetrics version pip uninstall torchmetrics==0.9.3 & pip install torchmetrics==0.6.0, then it works

Sadly, it didn't work, I'm getting a different error related to other libraries:

Traceback (most recent call last): File "/opt/anaconda3/envs/demul/bin/solo", line 5, in <module> from solo.solo import main File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/solo/solo.py", line 15, in <module> from pytorch_lightning.callbacks.early_stopping import EarlyStopping File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/__init__.py", line 34, in <module> from pytorch_lightning.callbacks import Callback # noqa: E402 File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/callbacks/__init__.py", line 25, in <module> from pytorch_lightning.callbacks.progress import ProgressBarBase, RichProgressBar, TQDMProgressBar File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/callbacks/progress/__init__.py", line 22, in <module> from pytorch_lightning.callbacks.progress.rich_progress import RichProgressBar # noqa: F401 File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/pytorch_lightning/callbacks/progress/rich_progress.py", line 26, in <module> _RICH_AVAILABLE: bool = _package_available("rich") and _compare_version("rich", operator.ge, "10.2.2") File "/opt/anaconda3/envs/demul/lib/python3.9/site-packages/torchmetrics/utilities/imports.py", line 54, in _compare_version pkg_version = pkg.__version__ # type: ignore AttributeError: module 'rich' has no attribute '__version__'

@davek44
Copy link
Collaborator

davek44 commented Sep 20, 2022

Hi all, I'm not familiar with pytorch lightning. We developed Solo for vanilla pytorch. I'll put this on my queue to look into, but I can't promise a quick fix. You might look into whether the scVI developers have their codebase working for pytorch lightning. Otherwise, I'd recommend a clean anaconda install without pytorch lightning.

@mari-ga
Copy link
Author

mari-ga commented Sep 24, 2022

Hi all, I'm not familiar with pytorch lightning. We developed Solo for vanilla pytorch. I'll put this on my queue to look into, but I can't promise a quick fix. You might look into whether the scVI developers have their codebase working for pytorch lightning. Otherwise, I'd recommend a clean anaconda install without pytorch lightning.

Thank you very much, the version from scVI is working in line.

@mari-ga mari-ga closed this as completed Sep 24, 2022
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

3 participants