jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
488 stars 108 forks source link

slepc error: "The MPI_Comm_rank() function was called before MPI_INIT was invoked" #35

Closed paulsbrookes closed 4 years ago

paulsbrookes commented 4 years ago

Hi. I have been trying to build petsc and slepc to use the slepc and slepc-nompi backends for eigh. Both petsc and slepc pass their tests but when I try to use slepc-nompi I receive an error message which I don't understand. Here is the code:

import quimb as qu
n = qu.num(10)     
e, v = qu.eigh(n, k=2, backend='slepc-nompi')

The error message is:

*** The MPI_Comm_rank() function was called before MPI_INIT was invoked.
*** This is disallowed by the MPI standard.
*** Your MPI job will now abort.

Do you know what might be causing this error?

jcmgray commented 4 years ago

Hey Paul, mmm not sure! These things are quite hard for me to debug. But just to check, what version of these are you using:

On Ubuntu, with gcc, openmpi 4.0.0 or 1.10.7, and the latest versions of slepc and petsc (and mpi4py, slepc4py and petsc4py) your snippet works fine for me.

paulsbrookes commented 4 years ago

Hey Johnie. Here's the info:

I found a couple of other questions (linked below) which mention this kind of error. One possibility is related to having multiple versions of MPI. petsc is presumably using the version of OpenMPI it downloaded, but I do have other versions of MPI on my computer, which may be interfering later on. But I don't really understand it.

https://github.com/Argonne-National-Laboratory/DSP/issues/8

https://stackoverflow.com/questions/31687583/mumps-the-mpi-comm-f2c-function-was-called-before-mpi-init-was-invoked

jcmgray commented 4 years ago

Ah yes, I suspect multiple MPIs + which mpi4py is pointing at vs which slepc4py is pointing at is the issue. MPI is the one bit of slepc that's probably best installed separately. Some stuff to try:

If you are using a cluster, use their MPI for sure. Else I generally compile a local version of openmpi v1.10.7 and use that.

paulsbrookes commented 4 years ago

Thanks Johnnie! I installed mpi4py using env MPICC=/path/to/mpicc pip install mpi4py as detailed in https://mpi4py.readthedocs.io/en/stable/install.html and that seems to have fixed the problem.