igashov / DiffLinker

DiffLinker: Equivariant 3D-Conditional Diffusion Model for Molecular Linker Design
MIT License
302 stars 44 forks source link

can I run cpu mode to generate linkers? #10

Open wenchangzhou-qtx opened 6 months ago

wenchangzhou-qtx commented 6 months ago

Hey, is it possible to run cpu mode? I saw it's possible from the generate.py, but when I tried I got this error:

python -W ignore /home/softwares/DiffLinker/generate.py --fragments frag.sdf --model models/geom_difflinker.ckpt --linker_size models/geom_size_gnn.ckpt --anchors 9,19
Will generate linkers with sampled numbers of atoms
Sampling...
  0%|                                                                                                  | 0/1 [00:01<?, ?it/s]
Traceback (most recent call last):
  File "/home/softwares/DiffLinker/generate.py", line 187, in <module>
    main(
  File "/home/softwares/DiffLinker/generate.py", line 156, in main
    chain, node_mask = ddpm.sample_chain(data, sample_fn=sample_fn, keep_frames=1)
  File "/home/softwares/DiffLinker/src/lightning.py", line 449, in sample_chain
    chain = self.edm.sample_chain(
  File "/home/softwares/mambaforge3/envs/difflinker/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/softwares/DiffLinker/src/edm.py", line 152, in sample_chain
    z = self.sample_p_zs_given_zt_only_linker(
  File "/home/softwares/DiffLinker/src/edm.py", line 188, in sample_p_zs_given_zt_only_linker
    eps_hat = self.dynamics.forward(
  File "/home/softwares/DiffLinker/src/egnn.py", line 383, in forward
    edges = self.get_edges(n_nodes, bs)  # (2, B*N)
  File "/home/softwares/DiffLinker/src/egnn.py", line 464, in get_edges
    return self.get_edges(n_nodes, batch_size)
  File "/home/softwares/DiffLinker/src/egnn.py", line 459, in get_edges
    edges = [torch.LongTensor(rows).to(self.device), torch.LongTensor(cols).to(self.device)]
  File "/home/softwares/mambaforge3/envs/difflinker/lib/python3.10/site-packages/torch/cuda/__init__.py", line 216, in _lazy_init
    torch._C._cuda_init()
RuntimeError: No CUDA GPUs are available
corinwagen commented 6 months ago

Ditto here, I get some weird issues on CPU. The pre-trained models worked well for me, but I had to manually override a variety of "device" settings to force PyTorch not to try and use a non-existent CUDA device.

I'm guessing there's some settings being cached in the pre-trained models that aren't updated when they're loaded in generate.py?