Warning: No calculation saved. Psi4 segmentation fault possible.
Closed this issue · 7 comments
I am having trouble with the basic usage of openfermionpsi4. The error is
molecule = run_psi4(molecule,
run_scf=True,
run_fci=False)
returning
Users/pablo/.local/lib/python3.7/site-packages/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
Warning)
To replicate it, I have created a conda environment called openfermion, installed both psi4 and openfermion and run a small code:
conda create -n openfermion python=3.7
conda activate openfermion
conda install -c psi4 psi4
as done herepip install git+https://github.com/quantumlib/OpenFermion.git@master
as done in the tutorial in the section Basics of MolecularData class. Notice here that just pip installing openfermion will result in aModule not found
error when attemptingfrom openfermion.chem import geometry_from_pubchem, MolecularData
.pip install openfermionpsi4
although everything is already installed, so you may as well skip this.- Run the main code in a jupyter notebook (installed for instance via anaconda navigator)
from openfermion.chem import geometry_from_pubchem, MolecularData
from openfermionpsi4 import run_psi4
methane_geometry = geometry_from_pubchem('methane')
print(methane_geometry)
basis = 'sto-3g'
molecule = MolecularData(methane_geometry, basis, multiplicity = 1)
molecule = run_psi4(molecule,
run_scf=True,
run_fci=False)
As indicated previously, this last line will raise an error
Users/pablo/.local/lib/python3.7/site-packages/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
Warning)
Thanks in advance for the help
The issue is that you're using an outdated version of openfermionpsi4
. The latest pip
version was uploaded August 2018. You're using a more recent version of openfermion
, which substantially reorganized the module. openfermionpsi4
was adapted to this in PR #42, just this year. When you try to use pre-reorganized openfermionpsi4
and post-reorganized openfermion
, you get a predictable ImportError
, leading to the error message which I find when I try to reproduce this:
ImportError: cannot import name 'MolecularData' from 'openfermion.hamiltonians' (package_directory_name_here/openfermion/hamiltonians/__init__.py)
Printing out the relevant lines from the Psithon --> Python processed input file:
""","blank_molecule_psi4_yo")
"""This is a template for psi4 input format."""
import numpy
import sys
from openfermion.config import *
--> from openfermion.hamiltonians import MolecularData
from openfermion.ops import general_basis_change
from numpy import array
sys.path.append('package_directory_name_here/openfermionpsi4')
from _psi4_conversion_functions import *
core.set_memory_bytes(8000000000)
package_directory_name_here/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
Warning)
@PabloAMC, was that the full form of the error message you saw? Without the context of the rest of the message, that last line about "Psi4 segmentation fault possible" is misleading.
Hi @JonathonMisiewicz . Thanks for helping out!
In fact I do not have the error when importing
from openfermion.chem import geometry_from_pubchem, MolecularData
Rather, it is in the
molecule = run_psi4(molecule,
run_scf=True,
run_fci=False)
because if I comment it out it does not return an error. The full output unfortunately does not give any more information, and does not tell you why it fails (I'm running it on jupyter notebook, is this a problem?)
[('C', (0, 0, 0)), ('H', (0.5541, 0.7996, 0.4965)), ('H', (0.6833, -0.8134, -0.2536)), ('H', (-0.7782, -0.3735, 0.6692)), ('H', (-0.4593, 0.3874, -0.9121))]
/Users/pablo/.local/lib/python3.7/site-packages/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
Warning)
Of course, if there is a way to avoid it using some specific package versions I'd be very interested. My objective is actually to obtain the molecular integrals in an easy way.
An error with from openfermion.chem import geometry_from_pubchem, MolecularData
is not expected. Behind-the-scenes, the run_psi4
command creates other Psi4 files input files from a template. The line from openfermion.hamiltonians import MolecularData
is from a pre-#42 version of the template. When Psi4 instructs Python to execute the line, we get the ImportError.
Jupyter is probably suppressing that additional output. Try running your script as a vanilla Python script. When I do that, the run_psi4
line indeed leads to the error I posted previously.
As a side-note, you can get molecular integrals just with Psi4, no OpenFermion needed. I'm assuming that your use also has something which genuinely does require OpenFermion.
Occasionally I will get similar errors from installing a different version of numpy after the psi4 conda build though I don't immediately see why this would provide an error given the commands you described for installation. Is psi4 conda build stable at 3.7? maybe try 3.6.
Indeed, running as a python script would be helpful. You can also store the output from psi4 via run_psi4. That should provide the most information.
I have done as suggested and in a plain Python file, it runs as
(openfermion) MacBook-Pro-de-pablo-2:GitHub pablo$ python Psi4-openfermion.py
[('C', (0, 0, 0)), ('H', (0.5541, 0.7996, 0.4965)), ('H', (0.6833, -0.8134, -0.2536)), ('H', (-0.7782, -0.3735, 0.6692)), ('H', (-0.4593, 0.3874, -0.9121))]
Traceback (most recent call last):
File "/Users/pablo/opt/anaconda3/envs/openfermion/bin/psi4", line 287, in <module>
exec(content)
File "<string>", line 22, in <module>
ImportError: cannot import name 'MolecularData' from 'openfermion.hamiltonians' (/Users/pablo/opt/anaconda3/envs/openfermion/lib//python3.7/site-packages/openfermion/hamiltonians/__init__.py)
Printing out the relevant lines from the Psithon --> Python processed input file:
""","blank_molecule_psi4_yo")
"""This is a template for psi4 input format."""
import numpy
import sys
from openfermion.config import *
--> from openfermion.hamiltonians import MolecularData
from openfermion.ops import general_basis_change
from numpy import array
sys.path.append('/Users/pablo/.local/lib/python3.7/site-packages/openfermionpsi4')
from _psi4_conversion_functions import *
core.set_memory_bytes(8000000000)
/Users/pablo/.local/lib/python3.7/site-packages/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
Warning)
@ncrubin I am not sure how to save the output of run_psi4, I have tried to put the tolerate_error = True
, as well as verbose
(although the latter will only work to print out other things), but none works. When using only psi4 I can run something like
psi4 input.dat output.dat
but it does not work here.
I have also tried the suggestion of attempting to use python = 3.6, but aside from the fact that it required me to run pip install openfermionpsi4
which was not needed before, the error does not appear to have changed
(openfermion36) MacBook-Pro-de-pablo-2:GitHub pablo$ python Psi4-openfermion.py
[('C', (0, 0, 0)), ('H', (0.5541, 0.7996, 0.4965)), ('H', (0.6833, -0.8134, -0.2536)), ('H', (-0.7782, -0.3735, 0.6692)), ('H', (-0.4593, 0.3874, -0.9121))]
Traceback (most recent call last):
File "/Users/pablo/opt/anaconda3/envs/openfermion36/bin/psi4", line 287, in <module>
exec(content)
File "<string>", line 22, in <module>
ImportError: cannot import name 'MolecularData'
Printing out the relevant lines from the Psithon --> Python processed input file:
""","blank_molecule_psi4_yo")
"""This is a template for psi4 input format."""
import numpy
import sys
from openfermion.config import *
--> from openfermion.hamiltonians import MolecularData
from openfermion.ops import general_basis_change
from numpy import array
sys.path.append('/Users/pablo/opt/anaconda3/envs/openfermion36/lib/python3.6/site-packages/openfermionpsi4')
from _psi4_conversion_functions import *
core.set_memory_bytes(8000000000)
/Users/pablo/opt/anaconda3/envs/openfermion36/lib/python3.6/site-packages/openfermionpsi4/_run_psi4.py:226: Warning: No calculation saved. Psi4 segmentation fault possible.
Warning)
Finally, just clarify @JonathonMisiewicz that I wanted to get the molecular integrals (if you give me a way to do that using only psi4 that would be great), but I also wanted to work in the plane wave basis, which I believe is only supported via openfermion.
Thanks to both!
There is an import error here. It looks like you are probably using a more recent Openfermion than Openfermion-psi4 is compatible with. We moved MolecularData
into a chem
module. This move hasn't been pushed to pypi which is why I suspect you are working on a dev openfermion but a pypi OpenFermion-Psi4.
one fix would be to use the dev versions of the entire openfermion ecosystem. All this version stuff will be fixed soon. We'll be releasing OpenFermion 1.0 and all plugins will be upgraded on Pypi.
Thanks to @ncrubin and @JonathonMisiewicz. I can confirm that if one uses python = 3.6
and repeats the instructions above substituting
pip install openfermionpsi4
with
pip install git+https://github.com/quantumlib/OpenFermion-Psi4.git@master
no such problem happens.