- changed title to Error installing in Anaconda environment using pip (update:) AND with default python3 using pip3
- edited description
Error installing in Anaconda environment using pip (update:) AND with default python3 using pip3
##Software versions##
I use Anaconda 2020.02 with Python 3.7. My OS is Ubuntu 18.04 (which has a default python3 version 3.6 ).
##Reproducing my error##
I installed OpenMPI 4.0.3 in a local folder (/home/$USER/.openmpi) and set the bin and lib files to PATH and LD_LIBRARY_PATH environment variables respectively.
I installed PETSc 3.13 using mpicc and mpifort from OpenMpi (I set mpicpp to 0). I configured using -O2 optimizations and downloading MUMPS, metis, parmetis and ptscotch. MKL Blas/Lapack and Scalapack were set correctly (check was successful and alltests failed only 1 out of 8289 tests). I set the PETSC_DIR and PETSC_ARCH variables.
Next I installed mpi4py 3.0.3 using pip indicating MPICC from my local OpenMPI. I tested this in a simple Hello World python file and it ran with mpirun. A conda installation wouldn’t work, because it couldn’t install mpi4py with my local mpicc compiler.
Finally, I tried installing petsc4py 3.12.0 with “pip install petsc4py“, but it failed with the error shown in the attached text file. numpy and cython (although I did not download the in-development version) are installed. I even tried “env MPICC=/home/$USER/.openmpi/bin/mpicc pip install --no-cache-dir petsc4py“ but it output the same error.
Comments (7)
-
reporter -
You CANNOT install petsc4py 3.12 with PETSc 3.13. You have to wait until I manage to release petsc4py 3.13, which should happen soon. Or you can install petsc4py directly from the master branch
pip install https://bitbucket.org/petsc/petsc4py/get/master.tar.gz
-
petsc4py 3.13.0 was just released. Can you please try again?
-
reporter Thank you very much Lisandro Dalcin! I installed directly from the master branch and it worked!
Now that you write this, it seems pretty obvious that the versions weren’t matching. Could this be added to the documentation? Or make
setup.py
from petsc4py check if the PETSc version in PETSC_ARCH is appropriate (e.g. checking for the version in/$PETSC_ARCH/lib/PETSc.pc
)? Or is this too obvious to worry about?I would like to take this opportunity to show my appreciation for your and your team’s work! Thank you very much again!
I’ll set the issue as resolved.
But could you please further elucidate a few questions I have regarding multithreading in petsc and pets4py? Or should I ask in another forum?
- If I install PETSc --with-openmp, does it find the .so file of OpenMP in my LD_LIBRARY_PATH?
- Can multithreading actually be accomplished by petsc4py, e.g. by avoiding the Global Interpreter Lock (GIL) from Python?
- Is multithreading even efficient in the context of parallel linear solvers (e.g. MUMPS)? Or should I just worry about multiprocessing?
Again, thank you very much!
-
reporter I’ve tried again with
pip3 install --force-reinstall --no-cache-dir petsc4py
It also worked perfectly. Thanks again!
-
reporter - changed status to resolved
Non-matching versions of PETSc (3.13) for the then released build of petsc4py (3.12). Installing from bitbucket or waiting for the release of petsc4py 3.13 solved the issue.
-
About version checks, I don’t do them to avoid annoyances during development. I’m not going to add code to annoy myself. We have required for a long time that the petsc and petsc4py versions match, but of course no one RTFM, the README file says petsc4py requires A matching version of PETSc.
PETSc does not uses multithreading on its own codebase. petsc4py is not thread-safe, it does not release the GIL on calls to PETSc routines. External packages like BLAS/LAPACK and MUMPS may support multithreading and they should work as expected.
- Log in to comment
Update:
Instead of installing petsc4py in the Anaconda environment, I commented all mentions of anaconda in my .bashrc file and reverted to Ubuntu’s default Python 3.6.9.
which pip3
andwhich python3
were outputing the correct paths.I installed mpi4py using pip3 and indicating my local MPICC path. I tested this with both mpirun and mpiexec for a simple multi-cpu Hello World rank/size print and it worked.
The PETSC_ARCH (MUMPS-mkl-real-opt) and PETSC_DIR (/home/$USER/Documents/petsc) environment variables were already set using export in .bashrc.
Then I tried
pip3 install --no-cache-dir petsc4py
. This resulted in exactly the same error as before, an error when building wheel.Next I tried
pip3 install petsc4py
. The package apparently successfully installed.But when I ran
python3 -c 'import petsc4py; print(petsc4py.get_config())'
this shows a dictionary with incorrect PETSC_ARCH (arch-linux2-c-opt) and PETSC_DIR (/home/$USER/petsc) values.And, for the sake of completeness, i ran
python3 -c 'import petsc4py; from petsc4py import PETSc; PETSc.init()'
which returned the error:/home/breno/.local/lib/python3.6/site-packages/petsc4py/lib/init.py:130: UserWarning: ignored arch: 'MUMPS-mkl-real-opt', using: 'arch-linux2-c-opt'
(os.path.pathsep.join(arch_env), arch))
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/breno/.local/lib/python3.6/site-packages/petsc4py/PETSc.py", line 3, in <module>
PETSc = ImportPETSc(ARCH)
File "/home/breno/.local/lib/python3.6/site-packages/petsc4py/lib/init.py", line 29, in ImportPETSc
return Import('petsc4py', 'PETSc', path, arch)
File "/home/breno/.local/lib/python3.6/site-packages/petsc4py/lib/init.py", line 73, in Import
module = import_module(pkg, name, path, arch)
File "/home/breno/.local/lib/python3.6/site-packages/petsc4py/lib/init.py", line 58, in import_module
with f: return imp.load_module(fullname, f, fn, info)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libpetsc.so.3.12: cannot open shared object file: No such file or directory