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

Error inference with single files and torch_geometric #1

Closed
duerrsimon opened this issue Oct 5, 2022 · 7 comments
Closed

Error inference with single files and torch_geometric #1

duerrsimon opened this issue Oct 5, 2022 · 7 comments

Comments

@duerrsimon
Copy link
Contributor

I installed this in a fresh environment using the provided environment.yml. but it fails on inference. I attached the two files (renamed to txt for upload)

The esm embedding step works:

(diffdock) $ HOME=esm/model_weights python esm/scripts/extract.py esm2_t33_650M_UR50D data/prepared_for_esm.fasta data/esm2_output --repr_layers 33 --include per_tok
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/models/esm2_t33_650M_UR50D.pt" to esm/model_weights/.cache/torch/hub/checkpoints/esm2_t33_650M_UR50D.pt
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/regression/esm2_t33_650M_UR50D-contact-regression.pt" to esm/model_weights/.cache/torch/hub/checkpoints/esm2_t33_650M_UR50D-contact-regression.pt
Transferred model to GPU
Read data/prepared_for_esm.fasta with 2 sequences
Processing 1 of 1 batches (2 sequences)

I get the following error when executing this command in the root dir of the project. I did not download the data and used single sdf and pdb files but according to the README that should work. data/esm2_output contains two .pt files: 1cbr_protein.pdb_chain_0.pt 1cbr_protein.pdb_chain_1.pt

(diffdock) $ python -m inference --ligand_path examples/1cbr_ligand.sdf --protein_path examples/1cbr_protein.pdb --out_dir results/user_predictions_small --inference_steps 20 --samples_per_complex 40 --batch_size 10
Traceback (most recent call last):
  File "/home/duerr/miniconda3/envs/diffdock/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/duerr/miniconda3/envs/diffdock/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/share/lcbcsrv5/lcbcdata/duerr/PhD/08_Code/DiffDock/inference.py", line 16, in <module>
    from datasets.pdbbind import PDBBind
  File "/share/lcbcsrv5/lcbcdata/duerr/PhD/08_Code/DiffDock/datasets/pdbbind.py", line 22, in <module>
    from utils.utils import read_strings_from_txt
  File "/share/lcbcsrv5/lcbcdata/duerr/PhD/08_Code/DiffDock/utils/utils.py", line 12, in <module>
    from torch_geometric.nn.data_parallel import DataParallel
  File "/home/duerr/miniconda3/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/__init__.py", line 3, in <module>
    from .sequential import Sequential
  File "/home/duerr/miniconda3/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/sequential.py", line 8, in <module>
    from torch_geometric.nn.conv.utils.jit import class_from_module_repr
  File "/home/duerr/miniconda3/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/conv/__init__.py", line 25, in <module>
    from .spline_conv import SplineConv
  File "/home/duerr/miniconda3/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/conv/spline_conv.py", line 16, in <module>
    from torch_spline_conv import spline_basis, spline_weighting
  File "/home/duerr/miniconda3/envs/diffdock/lib/python3.9/site-packages/torch_spline_conv/__init__.py", line 11, in <module>
    torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
AttributeError: 'NoneType' object has no attribute 'origin'

1cbr_ligand.txt
1cbr_protein.txt

@duerrsimon
Copy link
Contributor Author

seems related to this pyg-team/pytorch_geometric#2304

@gcorso
Copy link
Owner

gcorso commented Oct 5, 2022

Hi, the issue seems to arise when importing torch geometric at this line from torch_geometric.nn.data_parallel import DataParallel. Could you try running it directly in a python shell?

Unfortunately installation issues with torch geometric are very frequent, I suggest looking at issues in their repo and trying to uninstall and reinstall being careful of getting the version compatible with the pytorch version and CUDA installation.

@duerrsimon
Copy link
Contributor Author

duerrsimon commented Oct 5, 2022

Yes that is the offending line. I think you should make the environment file more bulletproof by separating the pip from the conda parts into different files and install the torch geometric version using -f https://data.pyg.org/whl/torch-1.12.0+cu113.html (or whatever cuda version is supported by the users platform) in requirements.txt. As it is now it will pull the cpu version of pytorch geometric and I think environment.yml does not support flags in the pip part so you need separate files.

If I execute pip install -U torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html in the environment it does not update anything, if I pip uninstall the packages and reinstall them using this command from torch_geometric.nn.data_parallel import DataParallel works.

@gcorso
Copy link
Owner

gcorso commented Oct 5, 2022

I'm glad it was solved! Thanks for the suggestion!

@mf-rug
Copy link

mf-rug commented Oct 6, 2022

Yes that is the offending line. I think you should make the environment file more bulletproof by separating the pip from the conda parts into different files and install the torch geometric version using -f https://data.pyg.org/whl/torch-1.12.0+cu113.html (or whatever cuda version is supported by the users platform) in requirements.txt. As it is now it will pull the cpu version of pytorch geometric and I think environment.yml does not support flags in the pip part so you need separate files.

If I execute pip install -U torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html in the environment it does not update anything, if I pip uninstall the packages and reinstall them using this command from torch_geometric.nn.data_parallel import DataParallel works.

Hi, having the same issue. Can you clarify your approach by sharing your exact commands? What exactly did you uninstall with pip, did you do it while inside the conda env, and how did you reinstall?

@duerrsimon
Copy link
Contributor Author

duerrsimon commented Oct 6, 2022

pip uninstall torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric
pip install -U torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html
Pick the cuda version that matches your pytorch cuda version that you can find out using:

import torch
torch.version.cuda

Above commands are for cuda 11.3

@mf-rug
Copy link

mf-rug commented Oct 9, 2022

pip uninstall torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric pip install -U torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html Pick the cuda version that matches your pytorch cuda version that you can find out using:

import torch
torch.version.cuda

Above commands are for cuda 11.3

Sweet thanks. If this happens to anyone else, for me the error originally only happened when running on gpu, but not on cpu. After

>>> torch.version.cuda
'11.3'

$ pip uninstall torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric
$ pip install -U torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.0+cu113.html

I got this new error on cpu:

Traceback (most recent call last):
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/data/p273962/DiffDock/inference.py", line 16, in <module>
    from datasets.pdbbind import PDBBind
  File "/data/p273962/DiffDock/datasets/pdbbind.py", line 22, in <module>
    from utils.utils import read_strings_from_txt
  File "/data/p273962/DiffDock/utils/utils.py", line 12, in <module>
    from torch_geometric.nn.data_parallel import DataParallel
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/__init__.py", line 3, in <module>
    from .sequential import Sequential
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/sequential.py", line 8, in <module>
    from torch_geometric.nn.conv.utils.jit import class_from_module_repr
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/conv/__init__.py", line 25, in <module>
    from .spline_conv import SplineConv
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/site-packages/torch_geometric/nn/conv/spline_conv.py", line 16, in <module>
    from torch_spline_conv import spline_basis, spline_weighting
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/site-packages/torch_spline_conv/__init__.py", line 15, in <module>
    torch.ops.load_library(spec.origin)
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/site-packages/torch/_ops.py", line 255, in load_library
    ctypes.CDLL(path)
  File "/data/p273962/conda/envs/diffdock/lib/python3.9/ctypes/__init__.py", line 382, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /data/p273962/conda/envs/diffdock/lib/python3.9/site-packages/torch_spline_conv/_basis_cuda.so)

but I found this, and after doing

pip uninstall torch-spline-conv

it worked on cpu again. Seems like that package is not needed?

ingcoder added a commit to ingcoder/DiffDock that referenced this issue Nov 15, 2023
…erver gcorso#1

- Enabled full post-processing for 4 SDF files generated with DiffDock.
- Refactored code to enhance readability and maintainability.
- Successfully implemented saving of CSV files with confidence scores and gnina docking affinities.
- CSV files are now stored both on the EC2 server (in DiffDock/results/predictions_small/outdir) and in an S3 Bucket.
- Gnina processing time ~10sec/file
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