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

ImportError, libtorch_cuda.so: undefined symbol #5

Closed
kolmorgan opened this issue Mar 28, 2024 · 17 comments
Closed

ImportError, libtorch_cuda.so: undefined symbol #5

kolmorgan opened this issue Mar 28, 2024 · 17 comments

Comments

@kolmorgan
Copy link

kolmorgan commented Mar 28, 2024

Hi,

After reading your article published in NC, I have created and downloaded relative files to generate molecules for my protein. However, when I used python -u sample_for_pdb.py --ckpt 500.pt --pdb_path protein/mypro_nolig.pdb --num_atoms 70 --num_samples 100 --sampling_type generalized, an error message showed in the screen
Traceback (most recent call last): File "/media/data/software/conda/PMDM-main/sample_for_pdb.py", line 10, in <module> from evaluation import * File "/media/data/software/conda/PMDM-main/evaluation/__init__.py", line 1, in <module> from .evaluation_metrics import * File "/media/data/software/conda/PMDM-main/evaluation/evaluation_metrics.py", line 7, in <module> import torch File "/home/anaconda3/envs/mol/lib/python3.9/site-packages/torch/__init__.py", line 235, in <module> from torch._C import * # noqa: F403 ImportError: /home/anaconda3/envs/mol/lib/python3.9/site-packages/torch/lib/libtorch_cuda.so: undefined symbol: cudaLaunchKernelExC, version libcudart.so.11.0
Can you please help me to solve this problem? Thanks!

@kskim-phd
Copy link

I have the same problem in mol env as shown in figure below. Could you help to address? Thank you!
Error

@Layne-Huang
Copy link
Owner

Hi,

There are some issues for the installation of pytorch.
There are two solutions:

  1. Reinstall pytorch according to your cuda version
  2. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/usr/anaconda3/envs/mol/lib/

@kolmorgan
Copy link
Author

kolmorgan commented Apr 2, 2024

@Layne-Huang Thank you for your help! The error disappeared after reinstalling pytorch. However, another error message appeared. When I used python -u sample_for_pdb.py --ckpt 500.pt --pdb_path protein/mypro_nolig.pdb --num_atoms 70 --num_samples 100 --sampling_type generalized
The error messages are shown as below:
`Entropy of n_nodes: H[N] -1.3862943649291992

[2024-04-02 13:28:17,151::test::INFO] Namespace(pdb_path='protein/mypro_nolig.pdb', num_atom=29, build_method='reconstruct', config=None, cuda=True, ckpt='500.pt', save_traj=False, num_samples=100, batch_size=100, resume=None, tag='', clip=1000.0, n_steps=1000, global_start_sigma=inf, w_global_pos=1.0, w_local_pos=1.0, w_global_node=1.0, w_local_node=1.0, sampling_type='generalized', eta=1.0)

[2024-04-02 13:28:17,151::test::INFO] {'model': {'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31}, 'train': {'seed': 2021, 'batch_size': 16, 'val_freq': 250, 'max_iters': 500, 'max_grad_norm': 10.0, 'num_workers': 4, 'anneal_power': 2.0, 'optimizer': {'type': 'adam', 'lr': 0.001, 'weight_decay': 0.0, 'beta1': 0.95, 'beta2': 0.999}, 'scheduler': {'type': 'plateau', 'factor': 0.6, 'patience': 10, 'min_lr': 1e-06}, 'transform': {'mask': {'type': 'mixed', 'min_ratio': 0.0, 'max_ratio': 1.2, 'min_num_masked': 1, 'min_num_unmasked': 0, 'p_random': 0.5, 'p_bfs': 0.25, 'p_invbfs': 0.25}, 'contrastive': {'num_real': 50, 'num_fake': 50, 'pos_real_std': 0.05, 'pos_fake_std': 2.0}}}, 'dataset': {'name': 'crossdock', 'type': 'pl', 'path': './data/crossdocked_pocket10', 'split': './data/split_by_name.pt'}}

[2024-04-02 13:28:17,151::test::INFO] Loading crossdock data...
Entropy of n_nodes: H[N] -3.543935775756836
[2024-04-02 13:28:17,151::test::INFO] Loading data...

/media/user/data/software/conda/PMDM-main_new/sample_for_pdb.py:59: DeprecationWarning: np.long is a deprecated alias for np.compat.long. To silence this warning, use np.compat.long by itself. In the likely event your code does not need to work on Python 2 you can use the builtin int for which np.compat.long is itself an alias. Doing this will not modify any behaviour and is safe. When replacing np.long, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
feat_mat = np.zeros([rd_num_atoms, len(ATOM_FAMILIES)], dtype=np.long)
/media/user/data/software/conda/PMDM-main_new/sample_for_pdb.py:101: DeprecationWarning: np.int is a deprecated alias for the builtin int. To silence this warning, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
element = np.array(element, dtype=np.int)
/media/user/data/software/conda/PMDM-main_new/sample_for_pdb.py:118: DeprecationWarning: np.long is a deprecated alias for np.compat.long. To silence this warning, use np.compat.long by itself. In the likely event your code does not need to work on Python 2 you can use the builtin int for which np.compat.long is itself an alias. Doing this will not modify any behaviour and is safe. When replacing np.long, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
edge_index = np.array([row, col], dtype=np.long)
/media/user/data/software/conda/PMDM-main_new/sample_for_pdb.py:119: DeprecationWarning: np.long is a deprecated alias for np.compat.long. To silence this warning, use np.compat.long by itself. In the likely event your code does not need to work on Python 2 you can use the builtin int for which np.compat.long is itself an alias. Doing this will not modify any behaviour and is safe. When replacing np.long, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
edge_type = np.array(edge_type, dtype=np.long)
[2024-04-02 13:28:17,222::test::INFO] Building model...
[2024-04-02 13:28:17,222::test::INFO] MDM_full_pocket_coor_shared

{'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31}
Traceback (most recent call last):
File "/media/user/data/software/conda/PMDM-main_new/sample_for_pdb.py", line 299, in
model = get_model(config.model).to(device)
File "/media/user/data/software/conda/PMDM-main_new/models/epsnet/init.py", line 9, in get_model
raise NotImplementedError('Unknown network: %s' % config.network)
NotImplementedError: Unknown network: MDM_full_pocket_coor_conformation
`
Can you please help me with it? I have downloaded the pre-trained model and extracted files into the folder instead of training the model again.

@wenchangzhou-qtx
Copy link

yep, I got the same error as I just tried this procedure.

@Layne-Huang
Copy link
Owner

I have revised this file. It could work now.

@wenchangzhou-qtx
Copy link

Thanks1 @Layne-Huang

I did a quick test and got this error below:

[2024-04-02 17:46:54,305::test::INFO] Loading crossdock data...
Entropy of n_nodes: H[N] -3.543935775756836
[2024-04-02 17:46:54,306::test::INFO] Loading data...
[2024-04-02 17:46:54,351::test::INFO] Building model...
[2024-04-02 17:46:54,351::test::INFO] MDM_full_pocket_coor_shared
{'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31}
sdf idr: ~/generate_ref
Entropy of n_nodes: H[N] -3.543935775756836
100%|████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 10420.63it/s]
  0%|                                                                                               | 0/2 [00:00<?, ?it/s]1
  0%|                                                                                               | 0/2 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "~/softwares/PMDM/sample_for_pdb.py", line 349, in <module>
    pos_gen, pos_gen_traj, atom_type, atom_traj = model.langevin_dynamics_sample(
  File "~/softwares/PMDM/models/epsnet/MDM_pocket_coor_shared.py", line 749, in langevin_dynamics_sample
    ligand_pos, protein_pos = center_pos_pl(ligand_pos_init + protein_com[ligand_batch], protein_pos,
  File "~/softwares/PMDM/models/epsnet/MDM_pocket_coor_shared.py", line 1465, in center_pos_pl
    pocket_pos_center = pocket_pos - scatter_mean(ligand_pos, ligand_batch, dim=0)[pocket_batch]
IndexError: index is out of bounds for dimension with size 0

@kolmorgan
Copy link
Author

kolmorgan commented Apr 3, 2024

Mine showed the same error as @wenchangzhou-qtx said. The error message were shown below:

Entropy of n_nodes: H[N] -1.3862943649291992

[2024-04-03 08:44:17,696::test::INFO] Namespace(pdb_path='8etr/pocket.pdb', sdf_path=None, num_atom=29, build_method='reconstruct', config=None, cuda=True, ckpt='500.pt', save_traj=False, num_samples=100, batch_size=100, resume=None, tag='', clip=1000.0, n_steps=1000, global_start_sigma=inf, w_global_pos=1.0, w_local_pos=1.0, w_global_node=1.0, w_local_node=1.0, sampling_type='generalized', eta=1.0)

[2024-04-03 08:44:17,697::test::INFO] {'model': {'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31}, 'train': {'seed': 2021, 'batch_size': 16, 'val_freq': 250, 'max_iters': 500, 'max_grad_norm': 10.0, 'num_workers': 4, 'anneal_power': 2.0, 'optimizer': {'type': 'adam', 'lr': 0.001, 'weight_decay': 0.0, 'beta1': 0.95, 'beta2': 0.999}, 'scheduler': {'type': 'plateau', 'factor': 0.6, 'patience': 10, 'min_lr': 1e-06}, 'transform': {'mask': {'type': 'mixed', 'min_ratio': 0.0, 'max_ratio': 1.2, 'min_num_masked': 1, 'min_num_unmasked': 0, 'p_random': 0.5, 'p_bfs': 0.25, 'p_invbfs': 0.25}, 'contrastive': {'num_real': 50, 'num_fake': 50, 'pos_real_std': 0.05, 'pos_fake_std': 2.0}}}, 'dataset': {'name': 'crossdock', 'type': 'pl', 'path': './data/crossdocked_pocket10', 'split': './data/split_by_name.pt'}}

[2024-04-03 08:44:17,697::test::INFO] Loading crossdock data... Entropy of n_nodes: H[N] -3.543935775756836 [2024-04-03 08:44:17,697::test::INFO] Loading data... [2024-04-03 08:44:17,705::test::INFO] Building model... [2024-04-03 08:44:17,705::test::INFO] MDM_full_pocket_coor_shared

{'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31} sdf idr: 8etr/generate_ref Entropy of n_nodes: H[N] -3.543935775756836 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 16677.15it/s] 0%| | 0/2 [00:00<?, ?it/s]1 0%| | 0/2 [00:00<?, ?it/s]

Traceback (most recent call last): File "/media/wsr/data/software/conda/PMDM-main_new/sample_for_pdb.py", line 345, in <module> pos_gen, pos_gen_traj, atom_type, atom_traj = model.langevin_dynamics_sample( File "/media/wsr/data/software/conda/PMDM-main_new/models/epsnet/MDM_pocket_coor_shared.py", line 749, in langevin_dynamics_sample ligand_pos, protein_pos = center_pos_pl(ligand_pos_init + protein_com[ligand_batch], protein_pos, File "/media/wsr/data/software/conda/PMDM-main_new/models/epsnet/MDM_pocket_coor_shared.py", line 1465, in center_pos_pl pocket_pos_center = pocket_pos - scatter_mean(ligand_pos, ligand_batch, dim=0)[pocket_batch] IndexError: index is out of bounds for dimension with size 0

@Layne-Huang
Copy link
Owner

Layne-Huang commented Apr 3, 2024

Mine showed the same error as @wenchangzhou-qtx said. The error message were shown below:

Entropy of n_nodes: H[N] -1.3862943649291992

[2024-04-03 08:44:17,696::test::INFO] Namespace(pdb_path='8etr/pocket.pdb', sdf_path=None, num_atom=29, build_method='reconstruct', config=None, cuda=True, ckpt='500.pt', save_traj=False, num_samples=100, batch_size=100, resume=None, tag='', clip=1000.0, n_steps=1000, global_start_sigma=inf, w_global_pos=1.0, w_local_pos=1.0, w_global_node=1.0, w_local_node=1.0, sampling_type='generalized', eta=1.0)

[2024-04-03 08:44:17,697::test::INFO] {'model': {'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31}, 'train': {'seed': 2021, 'batch_size': 16, 'val_freq': 250, 'max_iters': 500, 'max_grad_norm': 10.0, 'num_workers': 4, 'anneal_power': 2.0, 'optimizer': {'type': 'adam', 'lr': 0.001, 'weight_decay': 0.0, 'beta1': 0.95, 'beta2': 0.999}, 'scheduler': {'type': 'plateau', 'factor': 0.6, 'patience': 10, 'min_lr': 1e-06}, 'transform': {'mask': {'type': 'mixed', 'min_ratio': 0.0, 'max_ratio': 1.2, 'min_num_masked': 1, 'min_num_unmasked': 0, 'p_random': 0.5, 'p_bfs': 0.25, 'p_invbfs': 0.25}, 'contrastive': {'num_real': 50, 'num_fake': 50, 'pos_real_std': 0.05, 'pos_fake_std': 2.0}}}, 'dataset': {'name': 'crossdock', 'type': 'pl', 'path': './data/crossdocked_pocket10', 'split': './data/split_by_name.pt'}}

[2024-04-03 08:44:17,697::test::INFO] Loading crossdock data... Entropy of n_nodes: H[N] -3.543935775756836 [2024-04-03 08:44:17,697::test::INFO] Loading data... [2024-04-03 08:44:17,705::test::INFO] Building model... [2024-04-03 08:44:17,705::test::INFO] MDM_full_pocket_coor_shared

{'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31} sdf idr: 8etr/generate_ref Entropy of n_nodes: H[N] -3.543935775756836 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 16677.15it/s] 0%| | 0/2 [00:00<?, ?it/s]1 0%| | 0/2 [00:00<?, ?it/s]

Traceback (most recent call last): File "/media/wsr/data/software/conda/PMDM-main_new/sample_for_pdb.py", line 345, in <module> pos_gen, pos_gen_traj, atom_type, atom_traj = model.langevin_dynamics_sample( File "/media/wsr/data/software/conda/PMDM-main_new/models/epsnet/MDM_pocket_coor_shared.py", line 749, in langevin_dynamics_sample ligand_pos, protein_pos = center_pos_pl(ligand_pos_init + protein_com[ligand_batch], protein_pos, File "/media/wsr/data/software/conda/PMDM-main_new/models/epsnet/MDM_pocket_coor_shared.py", line 1465, in center_pos_pl pocket_pos_center = pocket_pos - scatter_mean(ligand_pos, ligand_batch, dim=0)[pocket_batch] IndexError: index is out of bounds for dimension with size 0

Hi,

I have updated sample_for_pdb.py with the related files models/encoders/egnn.py and utils/sample.py to support generation without reference ligand.

If you meet this error: the "self.propagate(edge_index, x=feats, edge_attr=edge_attr_feats,)", please degrade your torch_geometry version to 2.4.0.

Please let me know if there is any other issue.

@wenchangzhou-qtx
Copy link

@Layne-Huang NICE! It's working for me now.

@kolmorgan
Copy link
Author

kolmorgan commented Apr 8, 2024

@Layne-Huang Thank you for your help. The error was solved, but another error message showed as mentioned in #9. And I followed the suggestion to choose only residues within 10 angstroms of the ligand as protein and another error message showed as you mentioned self.propagate(edge_index, x=feats, edge_attr=edge_attr_feats,), and I degraded the torch_geometry to 2.4.0. However, the error showed:

`sh: 1: module: not found
Entropy of n_nodes: H[N] -1.3862943649291992
Traceback (most recent call last):
  File "/media/user/data/software/conda/PMDM-main_new/sample_for_pdb.py", line 25, in <module>
    from utils.transforms import *
  File "/media/user/data/software/conda/PMDM-main_new/utils/transforms.py", line 15, in <module>
    from torch_geometric.utils._subgraph import subgraph
ModuleNotFoundError: No module named 'torch_geometric.utils._subgraph'`

I'm not an expert in these, and after searching for the solution, maybe it's related to the CUDA version? I'm using CUDA 12.2 now.

@Layne-Huang
Copy link
Owner

@Layne-Huang Thank you for your help. The error was solved, but another error message showed as mentioned in #9. And I followed the suggestion to choose only residues within 10 angstroms of the ligand as protein and another error message showed as you mentioned self.propagate(edge_index, x=feats, edge_attr=edge_attr_feats,), and I degraded the torch_geometry to 2.4.0. However, the error showed:

`sh: 1: module: not found
Entropy of n_nodes: H[N] -1.3862943649291992
Traceback (most recent call last):
  File "/media/user/data/software/conda/PMDM-main_new/sample_for_pdb.py", line 25, in <module>
    from utils.transforms import *
  File "/media/user/data/software/conda/PMDM-main_new/utils/transforms.py", line 15, in <module>
    from torch_geometric.utils._subgraph import subgraph
ModuleNotFoundError: No module named 'torch_geometric.utils._subgraph'`

I'm not an expert in these, and after searching for the solution, maybe it's related to the CUDA version? I'm using CUDA 12.2 now.

I think the code in our file should be from torch_geometric.utils import subgraph?

@kolmorgan
Copy link
Author

kolmorgan commented Apr 9, 2024

@Layne-Huang Thank you! I have updated the script and now it works. However, the sampled molecules didn't seem fine. The output of sampling for my pocket file is shown below:
python -u sample_for_pdb.py --ckpt 500.pt --pdb_path pro/pro_chainB_pocket.pdb --num_atom 70 --num_samples 10 --sampling_type generalized

sh: 1: module: not found
Entropy of n_nodes: H[N] -1.3862943649291992
[2024-04-09 13:51:59,066::test::INFO] Namespace(pdb_path='8etr/7PZC_chainB_hbondopt-pocket.pdb', sdf_path=None, num_atom=70, build_method='reconstruct', config=None, cuda=True, ckpt='500.pt', save_traj=False, num_samples=10, batch_size=10, resume=None, tag='', clip=1000.0, n_steps=1000, global_start_sigma=inf, w_global_pos=1.0, w_local_pos=1.0, w_global_node=1.0, w_local_node=1.0, sampling_type='generalized', eta=1.0)
[2024-04-09 13:51:59,066::test::INFO] {'model': {'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31}, 'train': {'seed': 2021, 'batch_size': 16, 'val_freq': 250, 'max_iters': 500, 'max_grad_norm': 10.0, 'num_workers': 4, 'anneal_power': 2.0, 'optimizer': {'type': 'adam', 'lr': 0.001, 'weight_decay': 0.0, 'beta1': 0.95, 'beta2': 0.999}, 'scheduler': {'type': 'plateau', 'factor': 0.6, 'patience': 10, 'min_lr': 1e-06}, 'transform': {'mask': {'type': 'mixed', 'min_ratio': 0.0, 'max_ratio': 1.2, 'min_num_masked': 1, 'min_num_unmasked': 0, 'p_random': 0.5, 'p_bfs': 0.25, 'p_invbfs': 0.25}, 'contrastive': {'num_real': 50, 'num_fake': 50, 'pos_real_std': 0.05, 'pos_fake_std': 2.0}}}, 'dataset': {'name': 'crossdock', 'type': 'pl', 'path': './data/crossdocked_pocket10', 'split': './data/split_by_name.pt'}}
[2024-04-09 13:51:59,066::test::INFO] Loading crossdock data...
Entropy of n_nodes: H[N] -3.543935775756836
[2024-04-09 13:51:59,066::test::INFO] Loading data...
[2024-04-09 13:51:59,105::test::INFO] Building model...
[2024-04-09 13:51:59,105::test::INFO] MDM_full_pocket_coor_shared
{'type': 'diffusion', 'network': 'MDM_full_pocket_coor_shared', 'hidden_dim': 128, 'protein_hidden_dim': 128, 'num_convs': 3, 'num_convs_local': 3, 'protein_num_convs': 2, 'cutoff': 3.0, 'g_cutoff': 6.0, 'encoder_cutoff': 6.0, 'time_emb': True, 'atom_num_emb': False, 'mlp_act': 'relu', 'beta_schedule': 'sigmoid', 'beta_start': 1e-07, 'beta_end': 0.002, 'num_diffusion_timesteps': 1000, 'edge_order': 3, 'edge_encoder': 'mlp', 'smooth_conv': False, 'num_layer': 9, 'feats_dim': 5, 'soft_edge': True, 'norm_coors': True, 'm_dim': 128, 'context': 'None', 'vae_context': False, 'num_atom': 10, 'protein_feature_dim': 31}
sdf idr: 8etr/generate_ref
Entropy of n_nodes: H[N] -3.543935775756836
100%|███████████████████████████████████████████████████████| 2/2 [00:00<00:00, 202.81it/s]
0%|                                                                | 0/2 [00:00<?, ?it/s]1
/media/data/software/conda/PMDM-main/models/common.py:485: UserWarning: torch.sparse.SparseTensor(indices, values, shape, *, device=) is deprecated.  Please use torch.sparse_coo_tensor(indices, values, shape, dtype=, device=). (Triggered internally at ../torch/csrc/utils/tensor_new.cpp:618.)
bgraph_adj = torch.sparse.LongTensor(
sample: 1000it [00:49, 20.28it/s]
/media/data/software/conda/PMDM-main/sample_for_pdb.py:391: DeprecationWarning: `np.long` is a deprecated alias for `np.compat.long`. To silence this warning, use `np.compat.long` by itself. In the likely event your code does not need to work on Python 2 you can use the builtin `int` for which `np.compat.long` is itself an alias. Doing this will not modify any behaviour and is safe. When replacing `np.long`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
indicators = torch.zeros([pos.size(0), len(ATOM_FAMILIES)], dtype=np.long)
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C#C.CC1CCC(O)C1.N.N.O.O.OO
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.N.O=CCO
==============================
Open Babel Warning  in PerceiveBondOrders
Failed to kekulize aromatic bonds in OBMol::PerceiveBondOrders

generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.CC1C=CC=C1.N.N.N.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C=CC.N.O
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C#C.N.N.N.N.N.N.O
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.CCC.N.N.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.N.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C#C.N.N.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C#C.CO.N.N.O
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.CC.O
50%|████████████████████████████                            | 1/2 [00:49<00:49, 49.65s/it]1
sample: 1000it [00:49, 20.30it/s]
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.CO.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.N.N.O.O.OO
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.CC#N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.N.N.N.OO
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.N.N.N.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C=O.CC.N.N.O
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.Cc1ccccc1.N.N.N.N.N.O
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.CO.N.N.N.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C1CCCC1.N.N.N
generated smile: C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.C.CO.N.N.N.N
100%|████████████████████████████████████████████████████████| 2/2 [01:38<00:00, 49.48s/it]
[2024-04-09 13:53:38,133::test::INFO] valid:20
[2024-04-09 13:53:38,133::test::INFO] stable:0

Can you please help with it? Thank you!

@Layne-Huang
Copy link
Owner

Layne-Huang commented Apr 9, 2024 via email

@Layne-Huang
Copy link
Owner

protein.zip

Sure. Here are the files. I tried the pocket file to generate molecules before and now I'm trying it with my protein file. Thank you!

Our model is pretrained on CrossDocked dataset which the average length of the molecules is 26. There are only 6 molecules whose lengths are longer than 70 in the training set. Please decrease the num_atom to less than 40. If you want to generate large molecules, the model should be finetuned on the dataset which conatins large molecules.

@wenchangzhou-qtx
Copy link

@Layne-Huang, on this topic, is there a total number of atoms or just the part I'm trying to generate (e.g. fragment) that I should pay attention to when I tried to generate molecules?

@Layne-Huang
Copy link
Owner

Layne-Huang commented Apr 9, 2024

@Layne-Huang, on this topic, is there a total number of atoms or just the part I'm trying to generate (e.g. fragment) that I should pay attention to when I tried to generate molecules?

It depends on different protein pockets. In general, it is more difficult to generate valid molecules when you increase num_atoms. In the sample_frag.py, the code will automatically discard the distant atoms which could help generating more valid molecules. You could play our model to see the validities of the generated large molecules from scratch or given seed scaffolds. I am looking forward to your feedback.

@kolmorgan
Copy link
Author

@Layne-Huang Thank you! It works now.

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