Fatal Error: PSIOManager cannot get a mirror file handle

Hello, I’ve been encountering a persistent RuntimeError that always stops my script from running to completion. The code I have designed calculates the energy and dipole moment of a diatomic molecule, MgF, at various bond lengths using various methods (SCF and CCSD(T) within double- and triple-zeta bases) by iterating through a for-loop. It’s a long process, but I wouldn’t expect it to be so computationally inefficient that I’d run out of memory (I have over 7 GB free on my computer). The error I receive says Fatal Error: PSIOManager cannot get a mirror file handle.

I spoke about this error in a previous thread: Deleting scratch files before a computation finishes - Psi4 – Open-Source Quantum Chemistry (psicode.org) but it would seem that I had the wrong idea about what might be causing the issue. Originally I had suspected that the problem was caused by the process creating too many scratch files, but since my code uses psi4.core.clean() after each calculation these should be getting deleted once they’re no longer needed. Indeed, checking the directory indicated that all the CLEAN files left in memory were all left over when the script failed to finish running properly. In other words, these files only fail to get deleted when the script is terminated prematurely.

Does anyone know what might be causing this issue instead? It’s quite frustrating. I’ve been able to work around it by periodically saving the results of any successful calculations to an Excel spreadsheet in order to prevent all progress being lost, but the script’s inability to run to completion still results in absurd amounts of wasted time. I’d appreciate any information you might have. I am using Psi4 1.4rc2.dev1. Thank you.

I have no suggestions on this one, but I’ve made an issue. There should never be an error message that not even the developers can interpret.

1 Like

A long shot, but what limit has your shell for open files?

ulimit -n

If it’s small, could you try to increase it?
Maybe psi4 does not close every file it opens.

That command only seems to be valid on Linux, I am using a Windows device. I did a bit of research to see what an equivalent process could be and was told to use

import win32file
print(win32file._getmaxstdio())

I got a result of 512. I was able to increase it to 1024 and then to 2048 (which I understand is the limit) but the problem persisted.

unfortunately none of our devs are experienced with Windows.

Could you tell us more about your Window setup?
Native or WSL? Some special shell emulator?

The error comes from C++ fopen not being able to open the .clean file for writing, a basic
operator that should be robust. Hence the guess that there are file system permission issues.

I’m using VSCode to run a Python script that treats Psi4 as an imported module (PsiAPI style), so I’m not directly accessing the shell at all. Visual Studio has a built-in terminal that it uses to execute the process of running the code, which seems to be a Windows PowerShell terminal (the following message appears when I make a new terminal):

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

My operating system is Windows 10, so I believe that would qualify as running the code natively. I have less experience working with the shell directly, but I can try to run the script from there instead to see if I still get this mirror file handle issue.

I hope that answered your question, I apologize but I’m not sure if I understood it very well.

Thanks. Yes that kind of information is what I was looking for.

Bit late to the party on this one, but came across this issue while searching for the same:

Fatal Error: PSIOManager cannot get a mirror file handle

Using Psi4 in Anaconda prompt on Windows 10. Eventually realised I was trying to run in a directory (C:) I did not have write access to, assume Psi4 was trying and failing to write scratch files.