Build DOLFINx v0.9.0 from source on docker with demo run-time error

I try to compile DOLFINx v0.9.0 from source on docker of Ubuntu-20.04. The reason for this is because I made some modification on the source code and the public machines (server and HPC) use relatively old kernel. So I need to mimic a similar environment do installation, e.g. glibc with 2.31.

I followed the instruction dolfinx/docker/Dockerfile.test-env at main · FEniCS/dolfinx · GitHub to build up a test environment and made some adaption on Ubuntu-20.04. Then I try it with the official demo Poisson equation — DOLFINx 0.9.0 documentation with

python demo_poisson.py

yielding

Traceback (most recent call last):
  File "demo_poisson.py", line 107, in <module>
    V = fem.functionspace(msh, ("Lagrange", 1))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/dolfinx/fem/function.py", line 628, in functionspace
    cpp_element = _create_dolfinx_element(mesh.comm, mesh.topology.cell_type, ufl_e, dtype)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/dolfinx-env/lib/python3.12/site-packages/dolfinx/fem/function.py", line 586, in _create_dolfinx_element
    return CppElement(basix_e, ufl_e.block_size, ufl_e.is_symmetric)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: __init__(): incompatible function arguments. The following argument types are supported:
    1. __init__(self, element: basix::FiniteElement<float>, block_size: int, symmetric: bool) -> None
    2. __init__(self, elements: collections.abc.Sequence[dolfinx.cpp.fem.FiniteElement_float32]) -> None
    3. __init__(self, cell_type: dolfinx.cpp.mesh.CellType, points: numpy.ndarray[dtype=float32, shape=(*, *)], block_size: int, symmetry: bool) -> None

Invoked with types: dolfinx.cpp.fem.FiniteElement_float32, basix._basixcpp.FiniteElement_float32, int, bool

I sense that the problem is due to the mismatching of data type version of dependencies, but no idea how to correct it.

Other helpful-maybe info:

python3 -c "import dolfinx; import petsc4py; petsc4py.init(); print(petsc4py.PETSc)"

yielding

<module 'petsc4py.PETSc' from '/dolfinx-env/lib/python3.12/site-packages/petsc4py/lib/linux-gnu-real32-32/PETSc.cpython-312-x86_64-linux-gnu.so'>

For ffcx, basix and ufl, I installed via pip:

pip install fenics-basix==0.9.0
pip install fenics-ffcx==0.9.0

That typically means that you have changed nanobind version between the time you’ve installed basix and the time you installed dolfinx.

pip install fenics-basix==0.9.0 will download its own nanobind, while pip install --no-build-isolation will use the nanobind version currently installed in the docker image. Simplest attempt could be to pass --no-build-isolation to basix as well.

The problem persists.
I first uninstall basix, ffcx and ufl and reinstall again by

pip uninstall fenics-basix 
pip uninstall fenics-ffcx

pip install -v --no-build-isolation fenics-basix==0.9.0
pip install -v --no-build-isolation fenics-ffcx==0.9.0

then I reinstall DOLFINx v0.9.0.

Any other measures can be taken to diagnose the problem?

Try to clone the basix repository, checkout that 0.9.0 tag and build it from there (pip install --no-build-isolation .) rather than from pypi.

My suspicion is that right now you are downloading the wheels from Client Challenge rather than building on your own system.