Not using checkpoint files correctly(?)

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
User avatar
George Pantelopulos
Posts: 64
Joined: Mon Jun 01, 2015 2:15 pm

Not using checkpoint files correctly(?)

Post by George Pantelopulos » Sun Sep 20, 2015 6:44 pm

Hi all,

I'm attempting to use checkpoint files generated on the same machine using the same platform. For whatever reason this has been unsuccessful, and by all accounts I've read online I don't have any idea why this is happening.

From within my script:

Code: Select all

with open('production%i.chk'%rep, 'rb') as f:
    simulation.context.loadCheckpoint(f.read())
I receive the output:

Code: Select all

Traceback (most recent call last):
  File "produce.py", line 57, in <module>
    simulation.context.loadCheckpoint(f.read())
  File "C:\Miniconda3\lib\site-packages\simtk\openmm\openmm.py", line 5056, in l
oadCheckpoint
    return _openmm.Context_loadCheckpoint(self, *args)
TypeError: in method 'Context_loadCheckpoint', argument 2 of type 'std::string'
What might be going wrong? Any thoughts would be helpful.

Thanks!

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: Not using checkpoint files correctly(?)

Post by Peter Eastman » Tue Sep 22, 2015 10:56 am

Looks like some sort of a string/bytes inconsistency. What Python version are you using? This gets handled very differently in Python 2 and 3, so I suspect the origin of the problem is related to that.

What if you change the file mode to 'r' instead of 'rb'?

Peter

User avatar
George Pantelopulos
Posts: 64
Joined: Mon Jun 01, 2015 2:15 pm

Re: Not using checkpoint files correctly(?)

Post by George Pantelopulos » Tue Sep 22, 2015 6:49 pm

Hi Peter,

Trying the 'r' reading mode throws this error:

Code: Select all

Traceback (most recent call last):
  File "resume.py", line 39, in <module>
    simulation.context.loadCheckpoint(f.read())
  File "C:\Miniconda3\lib\site-packages\simtk\openmm\openmm.
oadCheckpoint
    return _openmm.Context_loadCheckpoint(self, *args)
Exception: loadCheckpoint: Checkpoint header was not correct
I'm using python 3.4 on a windows machine for this simulation.

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: Not using checkpoint files correctly(?)

Post by Peter Eastman » Thu Sep 24, 2015 10:23 am

Perhaps the problem is in how you're writing the checkpoint file? Could you show the code you use for that?

Peter

User avatar
George Pantelopulos
Posts: 64
Joined: Mon Jun 01, 2015 2:15 pm

Re: Not using checkpoint files correctly(?)

Post by George Pantelopulos » Thu Sep 24, 2015 11:03 am

Ah, I'm using the CheckpointReporter. I can't access that machine at the moment but I'm quite sure I was using it like so:

Code: Select all

simulation.reporters.append(app.CheckpointReporter('checkpoint.chk', 1000))

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: Not using checkpoint files correctly(?)

Post by Peter Eastman » Thu Sep 24, 2015 11:14 am

Alright, that should be fine. But your code for loading the checkpoint is nearly identical to what's in the test case for CheckpointReporter:

https://github.com/pandegroup/openmm/bl ... py#L33-L34

And I know that test runs successfully on Windows with Python 3.4, because that's one of the combinations we have continuous integration for. So I'm kind of confused.

Peter

User avatar
George Pantelopulos
Posts: 64
Joined: Mon Jun 01, 2015 2:15 pm

Re: Not using checkpoint files correctly(?)

Post by George Pantelopulos » Thu Sep 24, 2015 2:53 pm

I'll try running TestCheckpointReporter.py on that machine when I get the chance (tonight)!

User avatar
George Pantelopulos
Posts: 64
Joined: Mon Jun 01, 2015 2:15 pm

Re: Not using checkpoint files correctly(?)

Post by George Pantelopulos » Thu Sep 24, 2015 6:13 pm

OK. TestCheckpointReporter.py also fails.

Code: Select all

======================================================================
ERROR: test_1 (__main__.TestCheckpointReporter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "TestCheckpoint.py", line 34, in test_1
    self.simulation.context.loadCheckpoint(f.read())
  File "C:\Miniconda3\lib\site-packages\simtk\openmm\openmm.py", line 5056, in l
oadCheckpoint
    return _openmm.Context_loadCheckpoint(self, *args)
TypeError: in method 'Context_loadCheckpoint', argument 2 of type 'std::string'

----------------------------------------------------------------------
Ran 1 test in 3.360s

FAILED (errors=1)

User avatar
Peter Eastman
Posts: 2593
Joined: Thu Aug 09, 2007 1:25 pm

Re: Not using checkpoint files correctly(?)

Post by Peter Eastman » Thu Oct 01, 2015 2:01 pm

Hi George,

I'm still trying to reproduce this, but without success. What version of OpenMM are you using? Is this 6.3? Or the latest code from the repository? Or something else?

Peter

User avatar
George Pantelopulos
Posts: 64
Joined: Mon Jun 01, 2015 2:15 pm

Re: Not using checkpoint files correctly(?)

Post by George Pantelopulos » Thu Oct 01, 2015 2:29 pm

Hi Peter,

This is 6.3. If it matters at all, I'm using python3.4 via an installation of a very recent build of miniconda3.

I'm starting to think it might be something to do with the environment on my that particular machine since I'm getting python errors on it that don't crop up on others. I was trying to run a simulation using the gromacs-equilibrated structure from: https://simtk.org/forums/viewtopic.php?f=161&t=6005 which worked fine on the machine I'd been testing that stuff on, but the error:

Code: Select all

Traceback (most recent call last):
  File "test.py", line 37, in <module>
    simulation.step(totalsteps)
  File "C:\Miniconda3\lib\site-packages\simtk\openmm\app\simulation.py", line 95
, in step
    self._simulate(endStep=self.currentStep+steps)
  File "C:\Miniconda3\lib\site-packages\simtk\openmm\app\simulation.py", line 15
2, in _simulate
    self.integrator.step(stepsToGo)
  File "C:\Miniconda3\lib\site-packages\simtk\openmm\openmm.py", line 11905, in
step
    return _openmm.LangevinIntegrator_step(self, *args)
TypeError: in method 'LangevinIntegrator_step', argument 2 of type 'int'
Popped up while using CUDA (that particular simulation does work on CPU.

Because it seemed that some platform work while other don't, I checked all of the platform that are available on that machine with TestCheckpoint.py... but I received the same error regardless of platform:

Code: Select all

======================================================================
ERROR: test_1 (__main__.TestCheckpointReporter)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "TestCheckpoint.py", line 35, in test_1
    self.simulation.context.loadCheckpoint(f.read())
  File "C:\Miniconda3\lib\site-packages\simtk\openmm\openmm.py", line 5056, in l
oadCheckpoint
    return _openmm.Context_loadCheckpoint(self, *args)
TypeError: in method 'Context_loadCheckpoint', argument 2 of type 'std::string'

----------------------------------------------------------------------
Ran 1 test in 0.108s

FAILED (errors=1)

POST REPLY