Skip to content

Install dolfinx and petsc from wheels instead of building them - #19

Open
shimwell wants to merge 1 commit into
mainfrom
install-from-wheels
Open

Install dolfinx and petsc from wheels instead of building them#19
shimwell wants to merge 1 commit into
mainfrom
install-from-wheels

Conversation

@shimwell

Copy link
Copy Markdown
Member

The pip install built petsc, basix and dolfinx from source, which took the best part of an hour and needed fifteen apt packages to do it. All of them are wheels now.

pip install mpich
pip install --pre --extra-index-url https://shimwell.github.io/wheels \
  "fenics-dolfinx[petsc4py]" petsc

installation-with-pip.sh goes from 80 lines to 36. Gone are the petsc source build, the PETSC_DIR export, the symlink working around petsc shipping libpetsc.so as a linker script, both git clones, six cmake invocations, and thirteen of the fifteen apt packages. What is left of apt is what cadquery and pyvista need to render.

Checked, not assumed

Installed from the index into a clean python:3.12 container and ran 2-solve-heat-equation.py. Identical output both ways.

petsc 3.26.0.dev0 | petsc4py 3.26.0.dev0 | fenics-dolfinx 0.12.0.dev0
OK serial,   temperature.vtkhdf 12141375 bytes
OK parallel, temperature.vtkhdf 12141375 bytes

Nothing compiled during the install.

Worth knowing in review

dolfinx moves from 0.11.0 to 0.12.0.dev0. The scripts use LinearProblem, fem, mesh and io.vtkhdf, and those take the same arguments in 0.12. The run above is the evidence. It is a development version though, so it will move.

--pre is required. Without it pip ignores these versions and falls back to building petsc from the PyPI source distribution, which is the slow path this replaces. That failure is quiet, it looks like a normal slow install.

The basix wheel works now. The old script built basix from source with a comment explaining that the fenics-basix wheel could not be used, because it is a Py_LIMITED_API build and nanobind puts that in its ABI tag, so its types were invisible to locally built dolfinx bindings. That is no longer a problem here since basix and dolfinx come from the same build and share a tag.

No MPI clash. The petsc wheels are built against the PyPI mpich. The openmc wheel links no MPI at all, so the openmpi flavour matching the old script needed no longer applies.

CI drops to ubuntu-latest. The 26.04 pin was for a scotch new enough to ship SCOTCHConfig.cmake, which only the source build wanted. The wheels are manylinux_2_34, so glibc 2.34 is the floor, meaning Ubuntu 22.04 onwards. The job timeout goes from 180 minutes to 30.

About the petsc wheels

They are custom builds from https://github.com/shimwell/wheels, not PyPI.

  • Fortran free, using SuperLU_DIST rather than MUMPS as the parallel direct solver, because the MPI wheels on PyPI ship no Fortran bindings.
  • Built from petsc main rather than a release, to pick up petsc!9573. Without it a prebuilt petsc4py records the PETSC_DIR of the machine that built it and dolfinx cannot find libpetsc. That fix is in the 3.26 milestone, expected around the end of September, so these get rebuilt against the release when it lands.
  • Intel MPI will not work with them. petsc built against MPICH references MPIX_Irecv_enqueue, which Intel MPI does not implement despite being MPICH ABI compatible.

The pip install built petsc, basix and dolfinx from source, which took
the best part of an hour and needed fifteen apt packages to do it. All
of them are wheels now, so the script installs them.

    pip install mpich
    pip install --pre --extra-index-url https://shimwell.github.io/wheels \
      "fenics-dolfinx[petsc4py]" petsc

That removes the petsc source build, the PETSC_DIR export, the symlink
that worked around petsc shipping libpetsc.so as a linker script, both
git clones, six cmake invocations, and thirteen of the fifteen apt
packages. What is left of apt is what cadquery and pyvista need to
render. The script goes from 80 lines to 36.

--pre is needed. These are development versions, and without it pip
ignores them and falls back to building petsc from the source
distribution, which is the slow path this replaces.

The wheels move dolfinx from 0.11.0 to 0.12.0.dev0. The scripts use
LinearProblem, fem, mesh and io.vtkhdf, and those all take the same
arguments in 0.12. Checked by installing from the index into a clean
python:3.12 container and running 2-solve-heat-equation.py, which
produced an identical 12141375 byte temperature.vtkhdf both serially
and under mpiexec -n 2.

CI no longer needs ubuntu-26.04. That pin was for a scotch new enough to
ship SCOTCHConfig.cmake, which only the source build wanted. The wheels
are manylinux_2_34, so glibc 2.34 is the floor and ubuntu-latest is
fine. The job timeout drops from 180 minutes to 30.

The petsc wheels are built Fortran free with SuperLU_DIST rather than
MUMPS, because the MPI wheels on PyPI ship no Fortran bindings, and they
are built from petsc main to pick up the fix that lets a prebuilt
petsc4py find libpetsc. That fix is in the 3.26 milestone, so they will
be rebuilt against the release when it lands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant