openmmtools
openmmtools copied to clipboard
platform_supports_precision(platform, precision) always fails for CUDA and OpenCL on AWS EC2
In openmmtools.utils
, the function platform_supports_precision(platform, precision)
always fails since the context cannot be generated. Instead, the call in line 551 returns a NotImplementedError:
The specific call in platform_supports_precision that leads to the error is:
if platform.getName() in ['CUDA', 'OpenCL']:
from simtk import openmm
properties = { 'Precision' : precision }
system = openmm.System()
integrator = openmm.VerletIntegrator(0.001)
try:
context = openmm.Context(system, integrator, properties)
del context, integrator
return True
except Exception as e:
return False
leading to the error:
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Context'.
Possible C/C++ prototypes are:
OpenMM::Context::Context(OpenMM::System const &,OpenMM::Integrator &)
OpenMM::Context::Context(OpenMM::System const &,OpenMM::Integrator &,OpenMM::Platform &)
OpenMM::Context::Context(OpenMM::System const &,OpenMM::Integrator &,OpenMM::Platform &,std::map< std::string,std::string,std::less< std::string >,std::allocator< std::pair< std::string const,std::string > > > const &)
OpenMM::Context::Context(OpenMM::Context const &)
The error occurs because the Context initializer is missing an argument for platform given that the properties are set as a positional argument, e.g. see documentation for openmm.Context:
| __init__(self, *args)
| __init__(self, system, integrator) -> Context
| __init__(self, system, integrator, platform) -> Context
| __init__(self, system, integrator, platform, properties) -> Context
| __init__(self, other) -> Context
Additionally, when adding the platform (I tried this for CUDA on an AWS EC2 g4dn.xlarge instance) you get the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ec2-user/miniconda3/lib/python3.7/site-packages/simtk/openmm/openmm.py", line 18608, in __init__
this = _openmm.new_Context(*args)
Exception: Cannot create a Context for a System with no particles
I tried replacing the the blank openmm.System() with a system I generated from random PDB file which generated a context without difficulty, i.e.:
forcefield = ForceField('amber/ff14SB.xml',
'amber/tip3p_standard.xml',
'amber/tip3p_HFE_multivalent.xml',
'amber/phosaa10.xml')
system = forcefield.createSystem(pdb.topology)
On my specific system I could not check if the context generation actually works to identify if the precision is in fact supported by the platform, but as the function is right now it throws an error even for support precision for CUDA (and presumably OpenCL).