Parallelise MACE calculator

I’m slightly confused as to how to run the MACE calculator on multiple threads, I can’t seem to find anything in any of the documentation.

from mace.calculators import mace_mp
from ase import build

atoms = build.molecule('H2O')
calc = mace_mp(model="medium", dispersion=False, default_dtype="float32", device='cpu')
atoms.calc = calc
print(atoms.get_potential_energy())

That’s about as simple as the code can get. Thanks for any help!

This version of MACE is based on PyTorch, so I think you should get some parallelism controlled by OMP_NUM_THREADS.

You may be better off directing this question to the MACE developers here: ACEsuit/mace · Discussions · GitHub

1 Like

Thank you! It worked when using MKL_NUM_THREADS

Hello, may i ask how to use MKL_NUM_THREADS, can you show the code plz…
Did you set MKL_NUM_THREADS in python?

Hi hi, you should set it in your terminal, run export MKL_NUM_THREADS=36 in your shell, you could do this in python too if you do

from os import system as sys
sys('export MKL_NUM_THREADS=36')

probably also worth trying OMP_NUM_THREADS too

Hi, my current approach is to assign optimization tasks for different structures to different CPUs to improve efficiency, as my previous attempt with os.environ["MKL_NUM_THREADS"] = 32 didn’t seem to work well…

But still thank you for your response!!!