scverse / scvi-tools

Deep probabilistic analysis of single-cell and spatial omics data
http://scvi-tools.org/
BSD 3-Clause "New" or "Revised" License
1.25k stars 355 forks source link

scvi.model.PEAKVI.setup_anndata(adata): AttributeError: type object 'PEAKVI' has no attribute 'setup_anndata' #3008

Closed danli349 closed 1 month ago

danli349 commented 1 month ago

Hello

When I run the code in tutorial https://docs.scvi-tools.org/en/stable/tutorials/notebooks/atac/PeakVI.html

How can I solve this error?

scvi.model.PEAKVI.setup_anndata(adata)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[11], line 1
----> 1 scvi.model.PEAKVI.setup_anndata(adata)

AttributeError: type object 'PEAKVI' has no attribute 'setup_anndata'

import os
import tempfile
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import pooch
import scanpy as sc
import scvi
import torch

sc.logging.print_header()

2024-10-02 16:02:05.284971: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib
2024-10-02 16:02:05.285046: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
scanpy==1.9.8 anndata==0.8.0 umap==0.5.3 numpy==1.23.4 scipy==1.8.1 pandas==1.4.2 scikit-learn==1.3.2 statsmodels==0.12.1 igraph==0.10.8 louvain==0.8.1 pynndescent==0.5.8

Thanks a lot

canergen commented 1 month ago

Please install the most recent version of scvi-tools 1.2.0. We changed the API in (I'm guessing a bit here) 0.16.

danli349 commented 1 month ago

@canergen Why when I use python -m pip install scvi-tools to install scvi-tools, I can only install scvi-tools 0.20.3? and can't import it:

import scvi
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[4], line 9
      7 import pooch
      8 import scanpy as sc
----> 9 import scvi
     10 import torch
     12 sc.logging.print_header()

File [~/miniconda3/lib/python3.8/site-packages/scvi/__init__.py:7](http://localhost:8888/~/miniconda3/lib/python3.8/site-packages/scvi/__init__.py#line=6)
      4 import logging
      6 from ._constants import REGISTRY_KEYS
----> 7 from ._settings import settings
      9 # this import needs to come after prior imports to prevent circular import
     10 from . import autotune, data, model, external, utils

File [~/miniconda3/lib/python3.8/site-packages/scvi/_settings.py:7](http://localhost:8888/~/miniconda3/lib/python3.8/site-packages/scvi/_settings.py#line=6)
      4 from typing import Literal, Union
      6 import torch
----> 7 from pytorch_lightning import seed_everything
      8 from rich.console import Console
      9 from rich.logging import RichHandler

File [~/miniconda3/lib/python3.8/site-packages/pytorch_lightning/__init__.py:40](http://localhost:8888/~/miniconda3/lib/python3.8/site-packages/pytorch_lightning/__init__.py#line=39)
     37 from pytorch_lightning.trainer import Trainer  # noqa: E402
     39 # this import needs to go last as it will patch other modules
---> 40 import pytorch_lightning._graveyard  # noqa: E402, F401  # isort: skip
     42 __all__ = ["Trainer", "LightningDataModule", "LightningModule", "Callback", "seed_everything"]
     44 # for compatibility with namespace packages

File [~/miniconda3/lib/python3.8/site-packages/pytorch_lightning/_graveyard/__init__.py:26](http://localhost:8888/~/miniconda3/lib/python3.8/site-packages/pytorch_lightning/_graveyard/__init__.py#line=25)
     24 import pytorch_lightning._graveyard.trainer
     25 import pytorch_lightning._graveyard.training_type
---> 26 import pytorch_lightning._graveyard.utilities  # noqa: F401

File [~/miniconda3/lib/python3.8/site-packages/pytorch_lightning/_graveyard/utilities.py:25](http://localhost:8888/~/miniconda3/lib/python3.8/site-packages/pytorch_lightning/_graveyard/utilities.py#line=24)
     17 def _get_gpu_memory_map() -> None:
     18     # TODO: Remove in v2.0.0
     19     raise RuntimeError(
     20         "`pytorch_lightning.utilities.memory.get_gpu_memory_map` was deprecated in v1.5 and is no longer supported"
     21         " as of v1.9. Use `pytorch_lightning.accelerators.cuda.get_nvidia_gpu_stats` instead."
     22     )
---> 25 pl.utilities.memory.get_gpu_memory_map = _get_gpu_memory_map

AttributeError: partially initialized module 'pytorch_lightning' has no attribute 'utilities' (most likely due to a circular import)
canergen commented 1 month ago

I assume that you use Python 3.8. Please use at least Python 3.10 for the newest release. It looks like your torch installation is broken. Please set up a new environment and follow our installation guideline.