-
Notifications
You must be signed in to change notification settings - Fork 31
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
Memory Overflow of the ASE calculator #98
Comments
you keep initializing new calc instances each time. |
Note that you modify each structure in place creating a new calculator object and associate it with the structure. The API objects cannot be cleaned up by the GC because references to the respective objects still exist. |
I can confirm reuse the calc object can avoid memory problems. The below code has no issue. from ase.atoms import Atoms
from xtb.ase.calculator import XTB
atoms = Atoms('H2',positions=[[0,0,0],[0,0,1]])
atoms.calc = XTB(method="GFN2-xTB")
for _ in range(100000):
atoms.rattle()
atoms.get_forces() However, this code demonstrate there is indeed gc issue: from ase.atoms import Atoms
from xtb.ase.calculator import XTB
atoms = Atoms('H2',positions=[[0,0,0],[0,0,1]])
for _ in range(100000):
atoms.rattle()
atoms.calc = XTB(method="GFN2-xTB")
atoms.get_forces() Note that it is a slightly different approach compared to the op. the same atoms was used each time. The old instance of XTB calculator should be GCed.
an additional test to verify that is not ase's issue. The below code does not consume more and more memory. from ase.atoms import Atoms
from ase.calculators.lj import LennardJones
atoms = Atoms('H2',positions=[[0,0,0],[0,0,1]])
for _ in range(10000):
atoms.rattle()
atoms.calc = LennardJones()
atoms.get_forces() Correct me if I did something wrong. |
Describe the bug
I try to calculate the xtb energies of the QM9 database - 133885 structures. But at 6000 structures the memory usage exceeds 32GB, resulting in my calculation to crash. This can be solved by copying the ASE atoms object before every evaluation.
To Reproduce
Example workflow, which fails:
Expected behaviour
This is the working example:
In particular I changed the line:
Additional context
I tried both
cache_api=True
andcache_api=False
still this does not fix the issue. A similar option would be great to achieve the same reset I get from copying the atoms object.The text was updated successfully, but these errors were encountered: