BayraktarLab / cell2location

Comprehensive mapping of tissue cell architecture via integrated single cell and spatial transcriptomics (cell2location model)
https://cell2location.readthedocs.io/en/latest/
Apache License 2.0
311 stars 57 forks source link

PyroModule' object has no attribute 'per_cluster_mu_fg_unconstrained' #237

Open BenjaminDEMAILLE opened 1 year ago

BenjaminDEMAILLE commented 1 year ago

Hi ! I ran the command mod.train(max_epochs=250, use_gpu=True) on M1 Max MacBook Pro and I got this error :

GPU available: True (mps), used: False
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
HPU available: False, using: 0 HPUs
/Users/benjamin/Library/Python/3.9/lib/python/site-packages/pytorch_lightning/trainer/trainer.py:1789: UserWarning: MPS available but not used. Set `accelerator` and `devices` using `Trainer(accelerator='mps', devices=1)`.
  rank_zero_warn(
/Users/benjamin/Library/Python/3.9/lib/python/site-packages/pytorch_lightning/trainer/configuration_validator.py:105: UserWarning: You passed in a `val_dataloader` but have no `validation_step`. Skipping val loop.
  rank_zero_warn("You passed in a `val_dataloader` but have no `validation_step`. Skipping val loop.")
Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?1c0522c7-f7c3-4c23-9945-ed3484de2bd2)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[11], line 1
----> 1 mod.train(max_epochs=250, use_gpu=False)

File ~/Library/Python/3.9/lib/python/site-packages/cell2location/models/reference/_reference_model.py:157, in RegressionModel.train(self, max_epochs, batch_size, train_size, lr, **kwargs)
    154 kwargs["train_size"] = train_size
    155 kwargs["lr"] = lr
--> 157 super().train(**kwargs)

File ~/Library/Python/3.9/lib/python/site-packages/scvi/model/base/_pyromixin.py:146, in PyroSviTrainMixin.train(self, max_epochs, use_gpu, train_size, validation_size, batch_size, early_stopping, lr, training_plan, plan_kwargs, **trainer_kwargs)
    136 trainer_kwargs["callbacks"].append(PyroJitGuideWarmup())
    138 runner = TrainRunner(
    139     self,
    140     training_plan=training_plan,
   (...)
    144     **trainer_kwargs,
    145 )
--> 146 return runner()

File ~/Library/Python/3.9/lib/python/site-packages/scvi/train/_trainrunner.py:82, in TrainRunner.__call__(self)
     79 if hasattr(self.data_splitter, "n_val"):
     80     self.training_plan.n_obs_validation = self.data_splitter.n_val
---> 82 self.trainer.fit(self.training_plan, self.data_splitter)
     83 self._update_history()
...
   1268         return modules[name]
-> 1269 raise AttributeError("'{}' object has no attribute '{}'".format(
   1270     type(self).__name__, name))

AttributeError: 'PyroModule' object has no attribute 'per_cluster_mu_fg_unconstrained

How can I do ?

vitkl commented 1 year ago

Please provide package versions: cell2location, torch, pytorch-lightning, scvi-tools

BenjaminDEMAILLE commented 1 year ago

cell2location 0.1.2 torch 1.13.1 pytorch-lightning 1.7.7 scvi-tools 0.19.0

vitkl commented 1 year ago

Try installing the latest cell2location 0.1.3. Try creating the conda environment from scratch. This suggests an issue with pyro.