Page 1 of 2

Not using checkpoint files correctly(?)

Posted: Sun Sep 20, 2015 6:44 pm
by gpantel
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!

Re: Not using checkpoint files correctly(?)

Posted: Tue Sep 22, 2015 10:56 am
by peastman
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

Re: Not using checkpoint files correctly(?)

Posted: Tue Sep 22, 2015 6:49 pm
by gpantel
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.

Re: Not using checkpoint files correctly(?)

Posted: Thu Sep 24, 2015 10:23 am
by peastman
Perhaps the problem is in how you're writing the checkpoint file? Could you show the code you use for that?

Peter

Re: Not using checkpoint files correctly(?)

Posted: Thu Sep 24, 2015 11:03 am
by gpantel
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))

Re: Not using checkpoint files correctly(?)

Posted: Thu Sep 24, 2015 11:14 am
by peastman
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

Re: Not using checkpoint files correctly(?)

Posted: Thu Sep 24, 2015 2:53 pm
by gpantel
I'll try running TestCheckpointReporter.py on that machine when I get the chance (tonight)!

Re: Not using checkpoint files correctly(?)

Posted: Thu Sep 24, 2015 6:13 pm
by gpantel
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)

Re: Not using checkpoint files correctly(?)

Posted: Thu Oct 01, 2015 2:01 pm
by peastman
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

Re: Not using checkpoint files correctly(?)

Posted: Thu Oct 01, 2015 2:29 pm
by gpantel
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)