openmmtools
openmmtools copied to clipboard
Example for running MPI for ReplicaExchangeSampler?
Is there a good example for a script that parallelizes the runs generated by ReplicaExchangeSampler over cores via MPI (or other means)? Note that are systems are small enough (<100 particles) that we don't appear to be getting that much performance benefit of GPU over CPU. We are having a hard time getting this work, and we didn't find anything in the official documentation.
Thanks!
ReplicaExchangeSampler
should have automatic detection of MPI and it should parallelize the replicas over MPI processes accordingly. So it should be possible to just run mpirun [mpirun_options] my_script_with_rex.py
.
To make it run over CPU rather than GPU, you should be able t set the platform in the ContextCache
object used to generate the OpenMM Context
s. By default, ReplicaExchange
uses a global context cache that you configure at the beginning of your script like this
from openmmtools.cache import global_context_cache
global_context_cache.platform = openmm.getPlatform('CPU')
Note however this bug: #449. This is giving us a hard time, and I am short on dev time right now, unfortunately.
Thanks so much for the info! I suspect we will either be running on 1 GPU at a time, or parallelized on CPU's, so we hopefully will be OK.
Parallelizing over CPU might indeed work since I don't think we have tested the bug on CPUs. So far, however, the problem seems to be with MPI rather than the GPU platform in particular.
BTW, it's working, but we are still sorting out how to optimize what it does.