<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Sep 10, 2018 at 9:56 AM Jan Grießer <<a href="mailto:griesser.jan@googlemail.com">griesser.jan@googlemail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hey,<br>i started again trying to solve an eigenvalue problem with petsc4py and slepc4py. I followed the instruction on the website and installed petsc and petsc4py via pip3. MPI4PY and the corresponding MPI version is already compiled on our cluster. <br>Unfortunately when i start the following script by using: <br>mpirun -n 2 python3 test3.py<br></div></div></div></div></div></div></blockquote><div><br></div><div>Its likely that the 'mpirun' in your path does not match the MPI that MPI4PY was installed with.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">import time</div><div dir="ltr">import numpy as np</div><div dir="ltr">import sys, petsc4py</div><div dir="ltr">petsc4py.init(sys.argv)</div><div dir="ltr">from petsc4py import PETSc</div><div dir="ltr"><br></div><div dir="ltr">from mpi4py import MPI</div><div dir="ltr">print(MPI.COMM_WORLD.Get_size())</div><div dir="ltr"><br></div><div dir="ltr"><br></div><div dir="ltr"># For print </div><div dir="ltr">Print = PETSc.Sys.Print</div><div dir="ltr"><br></div><div dir="ltr">def construct_operator(m, n):</div><div dir="ltr"> """</div><div dir="ltr"> Standard symmetric eigenproblem corresponding to the</div><div dir="ltr"> Laplacian operator in 2 dimensions.</div><div dir="ltr"> """</div><div dir="ltr"> # Create matrix for 2D Laplacian operator</div><div dir="ltr"> A = PETSc.Mat().create()</div><div dir="ltr"> A.setSizes([m*n, m*n])</div><div dir="ltr"> A.setFromOptions( )</div><div dir="ltr"> A.setUp()</div><div dir="ltr"> # Fill matrix</div><div dir="ltr"> hx = 1.0/(m-1) # x grid spacing</div><div dir="ltr"> hy = 1.0/(n-1) # y grid spacing</div><div dir="ltr"> diagv = 2.0*hy/hx + 2.0*hx/hy</div><div dir="ltr"> offdx = -1.0*hy/hx</div><div dir="ltr"> offdy = -1.0*hx/hy</div><div dir="ltr"> Istart, Iend = A.getOwnershipRange()</div><div dir="ltr"> print("Istart: ", Istart)</div><div dir="ltr"> print("Iend: ", Iend)</div><div dir="ltr"> for I in range(Istart, Iend) :</div><div dir="ltr"> A[I,I] = diagv</div><div dir="ltr"> i = I//n # map row number to</div><div dir="ltr"> j = I - i*n # grid coordinates</div><div dir="ltr"> if i> 0 : J = I-n; A[I,J] = offdx</div><div dir="ltr"> if i< m-1: J = I+n; A[I,J] = offdx</div><div dir="ltr"> if j> 0 : J = I-1; A[I,J] = offdy</div><div dir="ltr"> if j< n-1: J = I+1; A[I,J] = offdy</div><div dir="ltr"> A.assemble()</div><div dir="ltr"> return A</div><div dir="ltr"><br></div><div dir="ltr">def main():</div><div dir="ltr"> opts = PETSc.Options()</div><div dir="ltr"> N = opts.getInt('N', 96)</div><div dir="ltr"> m = opts.getInt('m', N)</div><div dir="ltr"> n = opts.getInt('n', m)</div><div dir="ltr"> Print("Symmetric Eigenproblem (sparse matrix), "</div><div dir="ltr"> "N=%d (%dx%d grid)" % (m*n, m, n))</div><div dir="ltr"> A = construct_operator(m,n)</div><div dir="ltr"><div dir="ltr">Symmetric Eigenproblem (sparse matrix), N=9216 (96x96 grid)</div><div dir="ltr">Symmetric Eigenproblem (sparse matrix), N=9216 (96x96 grid)</div><div dir="ltr">2</div><div dir="ltr">Istart: 0</div><div dir="ltr">Iend: 9216</div><div dir="ltr">2</div><div dir="ltr">Istart: 0</div><div dir="ltr">Iend: 9216</div><div><br></div></div><div dir="ltr">if __name__ == '__main__':</div><div dir="ltr"> main()<br><br>it returns me the following output:<br><br>instead of the one i assumed to get from a local execution of my file:<br><div dir="ltr">2</div><div dir="ltr">2</div><div dir="ltr">Symmetric Eigenproblem (sparse matrix), N=9216 (96x96 grid)</div><div dir="ltr">Istart: 4608</div><div dir="ltr">Iend: 9216</div><div dir="ltr">Istart: 0</div><div dir="ltr">Iend: 4608</div><div><br>Therefore i assume somehow my MPI version is not linked correctly to my file and i checked with "ldd" my petsc file: <br><div><span style="white-space:pre-wrap"> </span>linux-vdso.so.1 => (0x00007ffd8db6a000)</div><div><span style="white-space:pre-wrap"> </span>liblapack.so.3 => /lib64/liblapack.so.3 (0x00007f1bd95e8000)</div><div><span style="white-space:pre-wrap"> </span>libblas.so.3 => /lib64/libblas.so.3 (0x00007f1bd938e000)</div><div><span style="white-space:pre-wrap"> </span>libm.so.6 => /lib64/libm.so.6 (0x00007f1bd908c000)</div><div><span style="white-space:pre-wrap"> </span>libX11.so.6 => /lib64/libX11.so.6 (0x00007f1bd8d4e000)</div><div><span style="white-space:pre-wrap"> </span>libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1bd8b31000)</div><div><span style="white-space:pre-wrap"> </span>libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f1bd8829000)</div><div><span style="white-space:pre-wrap"> </span>libdl.so.2 => /lib64/libdl.so.2 (0x00007f1bd8625000)</div><div><span style="white-space:pre-wrap"> </span>libgfortran.so.3 => /lib64/libgfortran.so.3 (0x00007f1bd8302000)</div><div><span style="white-space:pre-wrap"> </span>libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f1bd80ec000)</div><div><span style="white-space:pre-wrap"> </span>libquadmath.so.0 => /lib64/libquadmath.so.0 (0x00007f1bd7eb0000)</div><div><span style="white-space:pre-wrap"> </span>libc.so.6 => /lib64/libc.so.6 (0x00007f1bd7aec000)</div><div><span style="white-space:pre-wrap"> </span>/lib64/ld-linux-x86-64.so.2 (0x0000557325576000)</div><div><span style="white-space:pre-wrap"> </span>libxcb.so.1 => /lib64/libxcb.so.1 (0x00007f1bd78c4000)</div><div><span style="white-space:pre-wrap"> </span>libXau.so.6 => /lib64/libXau.so.6 (0x00007f1bd76bf000)</div></div><div>I assume that pip3 was for some reasons not able to link my mpi version to it. Can i force pip to link mpi or is there another mistake somewhere? </div><br></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>