running .so file wrapped by cython parallellized by mpi in yade

Asked by Ataollah Nateghi on 2018-10-16

Hello
I am trying to couple my 3-D LBM(Lattice Boltzmann Method) code, parallelized with MPI and written in C++, with yade. I used Cython for wrapping the C++ code. At the moment I can import my parallel and serial (without MPI header) code to python and run it. Also, I can import my serial code to Yade but when it reaches to parallel code I am not able to run it in Yade.
The error I am getting is:
/////////////////////////////////////////////////////////////////////////////////////////////
Welcome to Yade 2018.02b
TCP python prompt on localhost:9000, auth cookie `dakyus'
XMLRPC info provider on http://localhost:21000
Running script ex1.py
--------------------------------------------------------------------------
It looks like opal_init failed for some reason; your parallel process is
likely to abort. There are many reasons that a parallel process can
fail during opal_init; some of which are due to configuration or
environment problems. This failure appears to be an internal failure;
here's some additional information (which may only be relevant to an
Open MPI developer):

  opal_error_register failed
  --> Returned value -2 instead of OPAL_SUCCESS
--------------------------------------------------------------------------
--------------------------------------------------------------------------
It looks like MPI_INIT failed for some reason; your parallel process is
likely to abort. There are many reasons that a parallel process can
fail during MPI_INIT; some of which are due to configuration or environment
problems. This failure appears to be an internal failure; here's some
additional information (which may only be relevant to an Open MPI
developer):

  ompi_mpi_init: opal_init_util failed
  --> Returned "(null)" (-2) instead of "Success" (0)
--------------------------------------------------------------------------
*** An error occurred in MPI_Init_thread
*** on a NULL communicator
*** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
*** and potentially your MPI job)
[ata-B:6940] Local abort before MPI_INIT completed completed successfully, but am not able to aggregate error messages, and not able to guarantee that all other processes were killed!
/////////////////////////////////////////////////////////////////////////////////////////////
Do you have any recommendations and suggestions?
Thanks in advance for your help.

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Chareyre
Solved:
2018-11-05
Last query:
2018-11-05
Last reply:
2018-11-02

This question was reopened

>"I am not able to run it in Yade."

Hi, "in Yade" is nothing else than "in python", and your problem seems to be related to python and/or mpi.
Since it is not a "Yade" problem it is not the best place to ask.
Besides, the description of your code is much too superficial to get intelligent answers.
Bruno

Ataollah Nateghi (anateghi) said : #2

Thank you for your response. I can understand you when you say "in Yade is nothing else than in python"
but My code is working when I say:
mpirun -n .. python ...py
when it reaches Yade
mpirun -n .. yade ...py
I get the error mentioned above. Anyway thanks for the help I will try to see what is happening for mpi or pyhton.

Chareyre (bruno-chareyre-9) said : #3

Ah... it was not clear in your question.
The best is to read yade executable (a python script) to try and find
something which could hurt MPI. An alternative is to import yade instead of
running it, it is compatible with mpi (at least with mpi4py).
Bruno

Le mar. 16 oct. 2018 20:16, Ataollah Nateghi <
<email address hidden>> a écrit :

> Question #675256 on Yade changed:
> https://answers.launchpad.net/yade/+question/675256
>
> Ataollah Nateghi posted a new comment:
> Thank you for your response. I can understand you when you say "in Yade
> is nothing else than in python"
> but My code is working when I say:
> mpirun -n .. python ...py
> when it reaches Yade
> mpirun -n .. yade ...py
> I get the error mentioned above. Anyway thanks for the help I will try to
> see what is happening for mpi or pyhton.
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>

Ataollah Nateghi (anateghi) said : #4

Thank you so much for your help.

Ataollah Nateghi (anateghi) said : #5

Dear Bruno
Can you please show me some example for the second case( importing yade instead of running it)? I am trying to import yade modules and run my code with python but I have some difficulties. What I am doing is (using a simple example from tutorial)

from yade import pack,geom#,plot # or any module that I need

O.bodies.append(geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))

sp=pack.SpherePack()
sp.makeCloud((0,0,0),(1,1,1),rMean=.05,rRelFuzz=.5)
#sp.toSimulation()

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
   NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
   PyRunner(command='checkUnbalanced()',realPeriod=2),
   PyRunner(command='addPlotData()',iterPeriod=100)
]
O.dt=.5*PWaveTimeStep()

O.trackEnergy=True

def checkUnbalanced():
   if unbalancedForce()<.05:
      O.pause()
# plot.saveDataTxt('bbb.txt.bz2')

#def addPlotData():
 # plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)

#plot.plots={'i':('unbalanced',None,O.energy.keys)}

#plot.plot()

O.saveTmp()

##################

but I get errors like

NameError: name 'ForceRessetter' is not defined
or
NameError: name 'sphere' is not defined

or in plot case
from yade import plot
ImportError: No module named mtTkinter

I am wondering, what is a good source that I can read for solving these problems.
Thank you so much in advance.
Ataollah

To somehow reproduce the same namespace you need "from yadeimport import *", where "yadeimport" is a symlink to yade executable.

For instance:

$ cd ~/yade/bin
$ ln -s yade-version yadeimport.py
$ ipython
In [1]: from yadeimport import *
In [2]: s=sphere((0,0,0),1)
In [3]: print s
<Body instance at 0x20fd400>
In [4]: O.engines
Out[4]:
[<ForceResetter instance at 0x137b790>,
 <InsertionSortCollider instance at 0x177f710>,
 <InteractionLoop instance at 0x18a3970>,
 <GlobalStiffnessTimeStepper instance at 0x1908fd0>,
 <NewtonIntegrator instance at 0x1658e30>]

You can of course import more selectively, e.g. "from yadeimport import sphere".

HTH

Bruno

Ataollah Nateghi (anateghi) said : #7

Thank you so much for the response.
in "$ ln -s yade-version yadeimport.py" version means the version of yade?
what I used is:
$ ln -s yade-2018.02b yadeimport.py but I am getting an error which says :
ImportError: No module named yadeimport .
and when I try to open yadeimport.py it says:
This link cannot be used because its target "yade-2018.02b: doesn't exist.

Best Chareyre (bruno-chareyre-9) said : #8

I can't tell. I suggest to try basic things to learn how python modules can
be imported and how to handle path. It will be difficult to couple codes
otherwise.
Bruno

Le ven. 2 nov. 2018 20:52, Ataollah Nateghi <
<email address hidden>> a écrit :

> Question #675256 on Yade changed:
> https://answers.launchpad.net/yade/+question/675256
>
> Status: Answered => Open
>
> Ataollah Nateghi is still having a problem:
> Thank you so much for the response.
> in "$ ln -s yade-version yadeimport.py" version means the version of
> yade?
> what I used is:
> $ ln -s yade-2018.02b yadeimport.py but I am getting an error which says :
> ImportError: No module named yadeimport .
> and when I try to open yadeimport.py it says:
> This link cannot be used because its target "yade-2018.02b: doesn't exist.
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
>

Ataollah Nateghi (anateghi) said : #9

Thanks Chareyre, that solved my question.