ubuntu package

Issue #27 resolved
Francis Poulin created an issue

Recently I have installed slepc4py on my ubuntu system wtih the following,

https://pypi.python.org/pypi/slepc4py

I am pretty sure that the PETSc it uses assumes Real (not Complex) numbers. Is there an easy way to check this?

Below are the results from a code that I wrote and it seems that the error is decreasing until it gets within the tolerance. But then at the end we find the error is very large. Might this be due to using Reals instead of Complex?

If this is the case, do you happen to know of any ubuntu packages for petsc4py and slepc4py that use complex numbers? Otherwise I will have to build my own.

Cheers, Francis

1 EPS nconv=0 first unconverged value (error) 5.25338 (1.83397701e-02) 2 EPS nconv=0 first unconverged value (error) 5.57551 (7.44931555e-03) 3 EPS nconv=0 first unconverged value (error) 5.57608 (3.73926259e-04) 4 EPS nconv=0 first unconverged value (error) 5.57609 (2.75887028e-05) 5 EPS nconv=0 first unconverged value (error) 5.57609 (1.07419373e-06) 6 EPS nconv=0 first unconverged value (error) 5.57609 (9.89446499e-08) 7 EPS nconv=0 first unconverged value (error) 5.57609 (4.25182018e-09) 8 EPS nconv=0 first unconverged value (error) 5.57609 (9.07059577e-11) 9 EPS nconv=0 first unconverged value (error) 5.57609 (3.81972447e-12) 10 EPS nconv=0 first unconverged value (error) 5.57609 (7.21808689e-14) 11 EPS nconv=1 first unconverged value (error) 5.30614 (9.35418198e-09)

Number of iterations of the method: 11 Solution method: krylovschur Number of requested eigenvalues: 1 Stopping condition: tol=1e-14, maxit=512 Number of converged eigenpairs: 1

    k          ||Ax-kx||/||kx||

 5.576088            1.07609

Comments (9)

  1. Jose E. Roman

    You can check whether PETSc is built with real or complex scalars for example with a vector x and doing x.set(1+1j). If you get an error then PETSc is built with real scalars.

    Yes, the problem could be due to using reals instead of complex, but I am not sure.

    Ubuntu has a package for SLEPc 3.7 with complex scalars, but you will have to check for your particular distribution.

  2. Francis Poulin reporter

    Thank you for the reply. I did test it and it does not have complex numbers, as I suspected.

    I checked the ubuntu libraries and agree that there are some that are complex. Below is a list of them and I have one of them installed, but it's only a libslepc not a slepc without lib.

    First question, do you think this should be enough?

    Second, when I try installing slepc4py using apt it fails. I imagine this is a problem with ubuntu. Do you have any ideas how I might get them to fix this?

    Cheers, Francis

    $ apt search slepc                
    Sorting... Done
    Full Text Search... Done
    libslepc-complex-3.6/xenial 3.6.1.dfsg1-2build2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc-complex-3.6.1-dbg/xenial 3.6.1.dfsg1-2build2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc-complex-3.6.1-dev/xenial 3.6.1.dfsg1-2build2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc-complex-3.7-dev/yakkety 3.7.2+dfsg1-2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc-complex-3.7.2/yakkety,now 3.7.2+dfsg1-2 amd64 [installed]
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc-complex-3.7.2-dev/yakkety 3.7.2+dfsg1-2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc3.6/xenial 3.6.1.dfsg1-2build2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc3.6.1-dbg/xenial 3.6.1.dfsg1-2build2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc3.6.1-dev/xenial 3.6.1.dfsg1-2build2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc3.7-dev/yakkety 3.7.2+dfsg1-2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc3.7.2/yakkety,now 3.7.2+dfsg1-2 amd64 [installed]
      Scalable Library for Eigenvalue Problem Computations
    
    libslepc3.7.2-dev/yakkety 3.7.2+dfsg1-2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    python-slepc4py/yakkety 3.7.0-2 amd64
      Python bindings for SLEPc libraries
    
    slepc-dev/yakkety 3.7.2+dfsg1-2 amd64
      Scalable Library for Eigenvalue Problem Computations
    
    slepc3.6.1-doc/xenial,xenial 3.6.1.dfsg1-2build2 all
      Scalable Library for Eigenvalue Problem Computations
    
    slepc3.7.2-doc/yakkety,yakkety,now 3.7.2+dfsg1-2 all [installed]
      Scalable Library for Eigenvalue Problem Computations
    
    $ sudo pip install slepc4py
    The directory '/home/fpoulin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    The directory '/home/fpoulin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    Collecting slepc4py
      Downloading slepc4py-3.7.0.tar.gz (813kB)
        100% |████████████████████████████████| 819kB 843kB/s 
    Requirement already satisfied: petsc4py<3.8,>=3.7 in /usr/lib/python2.7/dist-packages (from slepc4py)
    Collecting slepc<3.8,>=3.7 (from slepc4py)
      Could not find a version that satisfies the requirement slepc<3.8,>=3.7 (from slepc4py) (from versions: )
    No matching distribution found for slepc<3.8,>=3.7 (from slepc4py)
    
  3. Francis Poulin reporter

    I decided to stop on the ubuntu packages and build my own.

    I believe I have succeeded in building petsc, slepc, petsc4py and slepc4py.

    The issue above is probably still outstanding for people who want to use the pre-build slepc4py but I have managed to avoid it.

    Thanks again.

  4. Lisandro Dalcin

    @francis_poulin The problem here is that pip install slepc4py has to know the location of slepc. The usual and easiest way is through the SLEPC_DIRenvironment variable.

    Yoi should try installing this way:

    export SLEPC_DIR=/usr/lib/slepcdir/3.7.2/x86_64-linux-gnu-complex
    pip install --user slepc4py # installs underneath ~/.local, no need of root, works out of the box
    
  5. Francis Poulin reporter

    Thank you for clarifying that. That helps a lot.

    On a related note, if I wanted to remove the petsc4py and slepc4py that I build myself, in hopes of going with pip, is there an easy way of doing that?

  6. Francis Poulin reporter

    I figured out where petsc4py and slepc4py where located and I deleted those manually.

    I decided to then install things using pip. I do things with sudo which may not be ideal but it does seem to work.

    Regardless of whether I use pip or build it I seem to get the following error when doing "python runtests.py" in the tests folder.

    What is strange is that when I build petsc4py it seems to pass the tests.

    Also, my petsc seems to pass the tests so I'm not sure what I'm missing.

    ======================================================================
    ERROR: testGetVec (test_dmda.TestDA_1D)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_dmda.py", line 127, in testGetVec
        vg = self.da.getGlobalVec()
    AttributeError: 'petsc4py.PETSc.DMDA' object has no attribute 'getGlobalVec'
    
    ======================================================================
    ERROR: testGetVec (test_dmda.TestDA_1D_W0)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_dmda.py", line 127, in testGetVec
        vg = self.da.getGlobalVec()
    AttributeError: 'petsc4py.PETSc.DMDA' object has no attribute 'getGlobalVec'
    
    ======================================================================
    ERROR: testGetVec (test_dmda.TestDA_1D_W2)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_dmda.py", line 127, in testGetVec
        vg = self.da.getGlobalVec()
    AttributeError: 'petsc4py.PETSc.DMDA' object has no attribute 'getGlobalVec'
    
    ...
    
    ======================================================================
    ERROR: testAdjacency (test_dmplex.TestPlex_3D_P4)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "test_dmplex.py", line 60, in testAdjacency
        PETSc.DMPlex.setAdjacencyUseAnchors]
    AttributeError: type object 'petsc4py.PETSc.DMPlex' has no attribute 'setAdjacencyUseAnchors'
    
    ----------------------------------------------------------------------
    Ran 3658 tests in 8.456s
    
    FAILED (errors=25)
    

    Maybe not too surprisingly, when I try installing slepc4py it doesn't work. So I hope if I fix the former then the latter will work.

    Any advice would be greatly appreciated.

        error: command '/home/fpoulin/software/petsc/arch-linux2-cxx-debug/bin/mpicxx' failed with exit status 1
    
        ----------------------------------------
    Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3BuB8r/slepc4py/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-O5b_Yw-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-3BuB8r/slepc4py/               
    
  7. Lisandro Dalcin

    If you installed with pip install petsc4py, then you should checkout the maint branch if the petsc4py repo, then run the tests.

    I'm not really sure what kind of mess you made on your system, my recommendation would be to start fresh:

    • Remove petsc and slepc from ~/software .
    • Remove any petsc4py/slepc4py in Python's dist/site-packages and ~/.local.
    • Make sure you removed the *py packages (i.e. "import slepc4py|petsc4py" should error).
    • Remove any {PETSC|SLEPC}_{DIR|ARCH} environment variables (and remove them from ~/.bashrc).
    • Make sure you apt-get install the right petsc/slepc packages from Ubuntu (just in case, also numpy).
    • Export/setenv {PETSC|SLEPC}_DIR environ vars to the Ubuntu prefix installs of petsc and slepc.
    • Finally, do pip install petsc4py slepc4py --user. Things should install out of the box. To test, clone and checkout the maint branch of petsc4py/slepc4py repos.
  8. Francis Poulin reporter

    Thank you.

    I am not sure what I did wrong before but I redid my installations and it now seems to work. I will be very careful before doing any updates.

  9. Log in to comment