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

No module named 'dgl.contrib' #5

Open
Yun-Ching-Chen opened this issue Jul 6, 2023 · 8 comments
Open

No module named 'dgl.contrib' #5

Yun-Ching-Chen opened this issue Jul 6, 2023 · 8 comments

Comments

@Yun-Ching-Chen
Copy link

Hi,

I installed deepvelo but it gives me error when I import it in python:

============================================================
ModuleNotFoundError Traceback (most recent call last)
in
----> 1 import deepvelo

/opt/conda/lib/python3.8/site-packages/deepvelo/init.py in
----> 1 from .train import *

/opt/conda/lib/python3.8/site-packages/deepvelo/train.py in
7 from scvelo import logging as logg
8
----> 9 import deepvelo.data_loader.data_loaders as module_data
10 import deepvelo.model.loss as module_loss
11 import deepvelo.model.metric as module_metric

/opt/conda/lib/python3.8/site-packages/deepvelo/data_loader/data_loaders.py in
7 import dgl
8 import hnswlib
----> 9 from dgl.contrib.sampling import NeighborSampler
10 from torch.utils.data import Dataset
11 from sklearn.metrics import pairwise_distances

ModuleNotFoundError: No module named 'dgl.contrib'

I think I installed dgl properly and I can import dgl in python without any issue.

I found the class NeighborSampler is under dgl.dataloading:
https://docs.dgl.ai/en/1.1.x/generated/dgl.dataloading.NeighborSampler.html

Which dgl version would you recommend for deepvelo? Or would deepvelo be compatible with the latest dgl soon?

Thank you very much,
Yun-Ching

@subercui
Copy link
Member

subercui commented Aug 22, 2023

Hi @Yun-Ching-Chen , thank you for the question! Sorry for the late reply

I would suggest using dgl>=0.4.3,<0.8.0. We haven't tested the later dgl versions. Please let me know how it works

@WeipengMO
Copy link

WeipengMO commented Jan 23, 2024

Hi @subercui , thank you for developing DeepVelo. I encountered some problems during installation. I tried to intall 'dgl>=0.4.3,<0.8.0', but it failed.

ERROR: Could not find a version that satisfies the requirement dgl<0.8.0,>=0.4.3 (from versions: 0.1.0, 0.1.2, 0.1.3, 0.8.0.post1, 0.9.0, 0.9.1, 1.0.0, 1.0.1, 1.0.4, 1.1.0, 1.1.1, 1.1.2, 1.1.3)
ERROR: No matching distribution found for dgl<0.8.0,>=0.4.3

image

@hsmaan
Copy link
Member

hsmaan commented Jan 31, 2024

Hi @WeipengMO, which version of python are you using? Could you please retry with python 3.7, 3.8, or 3.9?

@WeipengMO
Copy link

WeipengMO commented Feb 2, 2024

Hi @WeipengMO, which version of python are you using? Could you please retry with python 3.7, 3.8, or 3.9?

Hi @hsmaan , I have tried to re-install deepvelo in python3.9 env, it worked. However, It does not support calling the GPU.

# initial velocity
velocity(adata, mask_zero=False)
trainer = train(adata, configs)

computing velocities
/home/mowp/mambaforge/envs/scrna/lib/python3.9/site-packages/deepvelo/utils/optimization.py:167: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
  gamma[i] = np.linalg.pinv(A.T.dot(A)).dot(A.T.dot(y[:, i]))
    finished (0:00:00) --> added 
    'velocity', velocity vectors for each individual cell (adata.layers)
Config Warning: Set to use GPU, but GPU version of DGL is not installed. Reset to use CPU instead.
Warning: logging configuration file is not found in logger/logger_config.json.
building graph
INFO:train:Beginning training of DeepVelo ...
WARNING:trainer:Warning: visualization (Tensorboard) is configured to use, but currently not installed on this machine. Please install TensorboardX with 'pip install tensorboardx', upgrade PyTorch to version >= 1.1 to use 'torch.utils.tensorboard' or turn off the option in the 'config.json' file.
velo data shape: torch.Size([2930, 2000])
confidence mse shape: (2930, 2000)
confidence mse stats: max 2751.32080078125, min 0.0, mean 0.1709362268447876, std 5.503781795501709
confidence corr shape: (2000,)
confidence corr stats: max 0.9785177111625671, min -0.4764111340045929, mean 0.5344014763832092, std 0.16993308067321777
velo_mat shape: (2930, 2000)
--> added 'velocity' (adata.layers)
--> added 'velocity_unspliced' (adata.layers)
--> added 'cell_specific_beta' (adata.layers)
--> added 'cell_specific_gamma' (adata.layers)

Then, I re-tried to intall 'dgl>=0.4.3,<0.8.0', but it got the same error:

OSError                                   Traceback (most recent call last)
Cell In[1], line 1
----> 1 import deepvelo as dv
      2 import scvelo as scv
      3 import scanpy as sc

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/deepvelo/__init__.py:1
----> 1 from .train import *
      3 from . import tool as tl
      4 from . import plot as pl

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/deepvelo/train.py:9
      6 from anndata import AnnData
      7 from scvelo import logging as logg
----> 9 from deepvelo.trainer import Trainer
     10 import deepvelo.data_loader.data_loaders as module_data
     11 import deepvelo.model.loss as module_loss

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/deepvelo/trainer/__init__.py:1
----> 1 from .trainer import *

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/deepvelo/trainer/trainer.py:5
      3 from numpy import inf
      4 import torch
----> 5 import dgl
      7 # from torchvision.utils import make_grid
      8 from deepvelo.base import BaseTrainer

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/dgl/__init__.py:13
     10 import socket
     12 # Should import backend before importing anything else
---> 13 from .backend import load_backend, backend_name
     15 from . import function
     16 from . import contrib

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/dgl/backend/__init__.py:95
     91         set_default_backend('pytorch')
     92         return 'pytorch'
---> 95 load_backend(get_preferred_backend())
     98 def is_enabled(api):
     99     """Return true if the api is enabled by the current backend.
    100 
    101     Parameters
   (...)
    109         True if the API is enabled by the current backend.
    110     """

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/dgl/backend/__init__.py:41, in load_backend(mod_name)
     38 else:
     39     raise NotImplementedError('Unsupported backend: %s' % mod_name)
---> 41 from .._ffi.base import load_tensor_adapter # imports DGL C library
     42 version = mod.__version__
     43 load_tensor_adapter(mod_name, version)

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/dgl/_ffi/base.py:44
     42 __version__ = libinfo.__version__
     43 # library instance of nnvm
---> 44 _LIB, _LIB_NAME, _DIR_NAME = _load_lib()
     46 # The FFI mode of DGL
     47 _FFI_MODE = os.environ.get("DGL_FFI", "auto")

File ~/mambaforge/envs/scrna/lib/python3.9/site-packages/dgl/_ffi/base.py:34, in _load_lib()
     32 """Load libary by searching possible path."""
     33 lib_path = libinfo.find_lib_path()
---> 34 lib = ctypes.CDLL(lib_path[0])
     35 dirname = os.path.dirname(lib_path[0])
     36 basename = os.path.basename(lib_path[0])

File ~/mambaforge/envs/scrna/lib/python3.9/ctypes/__init__.py:382, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    379 self._FuncPtr = _FuncPtr
    381 if handle is None:
--> 382     self._handle = _dlopen(self._name, mode)
    383 else:
    384     self._handle = handle

OSError: libcudart.so.10.1: cannot open shared object file: No such file or directory

@WeipengMO
Copy link

Here is my session info:

Package            Version
------------------ ------------
adjustText         0.7.3
anndata            0.10.5.post1
array_api_compat   1.4.1
asttokens          2.0.5
backcall           0.2.0
certifi            2023.11.17
cffi               1.16.0
charset-normalizer 3.3.2
click              8.1.7
comm               0.1.2
cycler             0.12.1
debugpy            1.6.7
decorator          5.1.1
deepvelo           0.2.8
dgl-cu101          0.6.1
exceptiongroup     1.2.0
executing          0.8.3
fonttools          4.47.2
get-annotations    0.1.2
h5py               3.10.0
hnswlib            0.6.2
idna               3.6
igraph             0.9.11
importlib-metadata 7.0.1
ipykernel          6.28.0
ipython            8.15.0
jedi               0.18.1
Jinja2             3.1.3
joblib             1.3.2
jupyter_client     8.6.0
jupyter_core       5.5.0
kiwisolver         1.4.5
llvmlite           0.42.0
loompy             3.0.7
MarkupSafe         2.1.3
matplotlib         3.5.3
matplotlib-inline  0.1.6
natsort            8.4.0
nest-asyncio       1.5.6
networkx           3.2.1
numba              0.59.0
numpy              1.26.3
numpy-groupies     0.10.2
packaging          23.1
pandas             2.2.0
parso              0.8.3
patsy              0.5.6
pexpect            4.8.0
pickleshare        0.7.5
pillow             10.2.0
pip                23.3.1
platformdirs       3.10.0
prompt-toolkit     3.0.43
psutil             5.9.0
ptyprocess         0.7.0
pure-eval          0.2.2
pycparser          2.21
Pygments           2.15.1
pynndescent        0.5.11
pyparsing          3.1.1
python-dateutil    2.8.2
pytz               2023.3.post1
pyzmq              25.1.2
requests           2.31.0
rpy2               3.5.11
scanpy             1.9.6
scikit-learn       1.4.0
scipy              1.12.0
scvelo             0.2.5
seaborn            0.11.2
session-info       1.0.0
setuptools         68.2.2
simplegeneric      0.8.1
six                1.16.0
stack-data         0.2.0
statsmodels        0.14.1
stdlib-list        0.10.0
tbb                2021.11.0
texttable          1.7.0
threadpoolctl      3.2.0
torch              1.12.1
tornado            6.3.3
tqdm               4.66.1
traitlets          5.7.1
typing_extensions  4.9.0
tzdata             2023.4
tzlocal            2.1
umap-learn         0.5.4
urllib3            2.2.0
wcwidth            0.2.5
wheel              0.41.2
zipp               3.17.0

@hsmaan
Copy link
Member

hsmaan commented Apr 30, 2024

Hi @WeipengMO, apologies for the late response. This looks like a cuda toolkit mismatch to me, but could you please provide the following further info:

  • Which cuda version of dgl did you install?
  • Which cuda version is supported on your system?

@WeipengMO
Copy link

Hi @WeipengMO, apologies for the late response. This looks like a cuda toolkit mismatch to me, but could you please provide the following further info:

  • Which cuda version of dgl did you install?
  • Which cuda version is supported on your system?

Thanks for you reply. The cuda version of dgl I installed is dgl-cu101 (0.6.1), and the cuda version of my system is 12.0.

@hsmaan
Copy link
Member

hsmaan commented Apr 30, 2024

I see, can you try installing cudatoolkit 10.1 and trying again?

The easiest way would be to create a conda environment, install cudatoolkit 10.1 (https://anaconda.org/conda-forge/cudatoolkit/files - you can find the 10.1 file here), and then reinstalling DeepVelo after activating the conda env (ensuring that the python versioning is still restricted to that mentioned above in the conda env).

Could you please try this and let me know if it works? Thanks.

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

4 participants