MolecularAI / aizynthfinder

A tool for retrosynthetic planning
https://molecularai.github.io/aizynthfinder/
MIT License
562 stars 128 forks source link

Memory use accumulates when analysing numerous SMILES #117

Closed chubbant closed 1 year ago

chubbant commented 1 year ago

AiZynthFinder works fantastically well when analysing a single SMILES. However, when repeatedly using the AiZynthFinder Python interface, I noticed that memory use spikes during the initial stocks upload process then falls back a bit and stabilises. Memory use then steadily creeps up (adding between 70 MB and 1,100 MB) with each SMILES searched, until the RAM is exhausted.
Thus far I think I've tracked it down to the finder.tree_search() while loop that contains a call to self.tree.one_iteration(). Is there a way to 'reuse' the AiZynthFinder module without the time-consuming stocks upload step for each SMILES?

SGenheden commented 1 year ago

Thank you for your feedback. This is an issue with discovered with some of the latest versions of Tensorflow.

You have two options:

  1. Try to downgrade Tensorflow to about 2.8.0
  2. Clone the repository and use the release-3.7.0 branch. For the latest release we have gotten rid of the Tensorflow dependency and have converted the models to ONNX format that is more performant (and does not leak).
chubbant commented 1 year ago

Thanks Samuel! I downgraded to Tensorflow 2.8.0, and memory use was more stable. Not completely stable (there is still a slow increase in memory use with repeated searches), but it is stable enough to get loads done.