Installing dolfinx with spack on Ubuntu 22.04

I ran spack install and had a successful build finish at terminal. So upon done I ran a find -name “dolfinx.h” and found that there was nothing yet installed on the system. Upon finding that out I attempted to apt install cmake and build from source from the cpp/build directory of dolfinx by running “cmake …”

The first thing that happens is I get some red text out of terminal that says:
/usr/lib/x86_64-linux-gnu/openmpi/include

So I attempted to resolve this by copying ~/dolfinx/cpp/dolfinx the whole contents into /usr/include and then compiling the poisson example from the demo folder of dolfinx. Upon compiling I am finding that I still have a missing “poisson.h”. I did a search so far for a posson.h but did not yet find anything on the system.

Is there some additional step that should be necessary after running “spack install” at terminal to install onto the system a set of working source files for the dolfinx project into the source tree?

How might the missing poisson.h be resolved on Ubuntu 22.04?

Poisson.h should be generated by ffcx when you call cmake on a demo, Ref

OK. That was very helpful so far. Currently the difficulty with just using the cmake command on the …/cpp/demo folder of dolfinx is that cmake is asking for some missing configuration files in the form of:

DOLFINXConfig.cmake
dolfinx-config.cmake

after running cmake just for the demo folder.

What commands did you run to install dolfinx with spack, and what was the output?

I had run this set of commands:

git clone https://github.com/spack/spack.git
. ./spack/share/spack/setup-env.sh
spack env create fenicsx-env
spack env activate fenicsx-env
spack add py-fenics-dolfinx cflags="-O3" fflags="-O3"
spack install

the output was quite long, mostly it had indicated that all required packages were pulled and processed in some way successfully. “Spack” takes a little over one hour to complete the process.

Incidentally I ran on my system:

    sudo apt install libopenmpi-dev
    pip install mpi4py

which does seem to fix the missing OpenMPI includes however when attempting again to cmake the cpp folder of dolfinx I get a missing basix package just to start out with among some others which I am trying to install onto the system with sudo apt install’s.

Just a little bit more information after that (currently I have a versioning requirement issue installing ffcx manually):

    prusso@lenovo:~/ffcx$ sudo cmake --install build-dir
    -- Install configuration: ""
    -- Installing: /usr/local/share/ufcx/cmake/ufcxTargets.cmake
    -- Installing: /usr/local/share/ufcx/cmake/ufcxConfig.cmake
    -- Installing: /usr/local/share/ufcx/cmake/ufcxConfigVersion.cmake
    -- Installing: /usr/local/include/ufcx.h
    -- Installing: /usr/local/share/pkgconfig/ufcx.pc
    prusso@lenovo:~/ffcx$ pip install .
    Defaulting to user installation because normal site-packages is not writeable
    Processing /home/prusso/ffcx
    Installing build dependencies ... done
    Getting requirements to build wheel ... done
    Preparing metadata (pyproject.toml) ... done
    Collecting cffi
    Downloading cffi-1.15.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (441 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 441.8/441.8 KB 7.4 MB/s eta 0:00:00
   Collecting numpy
    Downloading numpy-1.25.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.6     MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17.6/17.6 MB 33.4 MB/s eta 0:00:00
ERROR: Could not find a version that satisfies the requirement fenics-ufl<2023.3.0,>=2023.2.0.dev0 (from fenics-ffcx) (from versions: 2017.1.0.post1, 2017.2.0, 2018.1.0, 2019.1.0, 2022.1.0.post0, 2022.2.0, 2023.1.0, 2023.1.1.post0)
ERROR: No matching distribution found for fenics-ufl<2023.3.0,>=2023.2.0.dev0

I would guess at this point that the UFL release requested just isn’t out yet. It seems that OpenMPI was put in by spack so far it was only the C++ header files that were missing that were installed with apt.

As you are trying to run the C++ installation of DOLFINx, I would install fenics-dolfinx and not py-fenics-dolfinx, as the latter are the Python bindings of dolfinx, Ref: Package List — Spack 0.21.0.dev0 documentation

1 Like

So I have upon running apt search fenics:

 fenics
 fenicsx
 (also a smattering of packages for dolfin and python-dolfin*)

So after apt install fenicsx which is the closest I have to fenics-dolfinx and also trying to build the cpp again what I have showing up is that I have an unsuitable version of UFCx (0.5.0 vs 0.7 that cmake is asking for).

I would imagine that at this time I may or may not be able to get a version 0.7, I guess that I will maybe just wait for it to come down the pipeline. Any opines about the availability currently of 0.7 it is asking are welcome. Thanks… looks really like what I was searching for in the way of PDE solving capabilities.

You are now mixing apt installation and spack installations, which is not what you want. You started using spack, but you installed the python interface (which doesn’t have the c++ code as a runtime dependency). this is why you should call your spack installation with

spack env create fenicsx-env
spack env activate fenicsx-env
spack add fenics-dolfinx cflags="-O3" fflags="-O3"
spack install

If you want to work with the C++ version of dolfinx (v0.6.0 or main branch), you need to use spack (and not apt).

OK, that being made known it. Then from a clean slate following ‘spack’ terminal input as described previous:

prusso@lenovo:~$ spack install
==> Concretized fenics-dolfinx cflags="-O3" fflags="-O3"
    ~~~~
==> fenics-dolfinx: Successfully installed fenics-dolfinx-0.6.0-fwye67m2fhxepyr73fimkfgmm7pramhr
  Stage: 1.66s.  Cmake: 1.45s.  Build: 39.38s.  Install: 0.17s.  Post-install: 0.08s.  Total: 42.96s
[+] /home/prusso/spack/opt/spack/linux-ubuntu22.04-skylake/gcc-11.3.0/fenics-dolfinx-0.6.0-fwye67m2fhxepyr73fimkfgmm7pramhr
==> Updating view at /home/prusso/spack/var/spack/environments/fenicsx-env/.spack-env/view
prusso@lenovo:~$ git clone https://github.com/FEniCS/dolfinx

Then followed by:

prusso@lenovo:~/dolfinx/cpp/build$ cmake ..
-- Found Boost 1.82.0 at /home/prusso/spack/var/spack/environments/fenicsx-env/.spack-env/view/lib/cmake/Boost-1.82.0
--   Requested configuration: QUIET REQUIRED COMPONENTS timer
-- Found boost_headers 1.82.0 at /home/prusso/spack/var/spack/environments/fenicsx-env/.spack-env/view/lib/cmake/boost_headers-1.82.0

    ~~~~

-- Checking for basix hints with /usr/bin/python3.10
CMake Error at CMakeLists.txt:195 (find_package):
  Could not find a configuration file for package "Basix" that is compatible
  with requested version "0.7".

  The following configuration files were considered but not accepted:

    /home/prusso/spack/var/spack/environments/fenicsx-env/.spack-env/view/lib/cmake/basix/BasixConfig.cmake, version: 0.6.0



-- Configuring incomplete, errors occurred!
See also "/home/prusso/dolfinx/cpp/build/CMakeFiles/CMakeOutput.log".

So there is still currently in that configuration of a ‘spack’ installation a version mismatch that occurs when building for c++ with ‘cmake’…

What version of dolfinx have you checked out (v0.6.0?) in your local git clone?

You can specify what version of dolfinx you want to work against by specifying the version:

spack add fenics-dolfinx@main

See Basic Usage — Spack 0.21.0.dev0 documentation
and
Package List — Spack 0.21.0.dev0 documentation
for available versions
or spack info fenics-dolfinx for preferred version

So currently at this time there are (preferred and safe):

Preferred version:  
    0.6.0          https://github.com/FEniCS/ffcx/archive/v0.6.0.tar.gz

Safe versions:  
    main           [git] https://github.com/FEniCS/ffcx.git on branch main
    0.6.0          https://github.com/FEniCS/ffcx/archive/v0.6.0.tar.gz
    0.5.0.post0    https://github.com/FEniCS/ffcx/archive/v0.5.0.post0.tar.gz
    0.5.0          https://github.com/FEniCS/ffcx/archive/v0.5.0.tar.gz
    0.4.2          https://github.com/FEniCS/ffcx/archive/v0.4.2.tar.gz

I did give a go to put in 0.70. This was result:

prusso@lenovo:~/dolfinx/cpp/build$ spack install --add fenics-dolfinx@0.70
==> Error: concretization failed for the following reasons:

   1. Cannot satisfy 'fenics-dolfinx@0.70'. Couldn't concretize without changing the existing environment. If you are ok with changing it, try `spack concretize --force`. You could consider setting `concretizer:unify` to `when_possible` or `false` to allow multiple versions of some packages.

Not really sure what it means all the way. I did try to re-concretize some way to see if that would remedy anything. Couldn’t get a 0.7 to go in yet…

As I said. 0.7.0 is main branch, so try

That part does make sense. So I tried to to so from an untouched installation of Ubuntu 22.04.

spack env create fenicsx-env
spack env activate fenicsx-env
spack add fenics-dolfinx@main cflags="-O3" fflags="-O3"
spack install

main branch is showing safe by spack, 0.6.0 is showing preferred when completed. For discussion purposes I wget https://github.com/FEniCS/dolfinx/archive/v0.6.0.tar.gz and unpack it. spack is showing fenics-ufcx as installed 0.6.0 being preferred.

dolfinx-0.6.0/cpp/build$ cmake …

ModuleNotFoundError: No module named 'ffcx'
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find UFCx (missing: UFCX_INCLUDE_DIRS UFCX_VERSION) (Required is
  at least version "0.6")

      Reason given by package: UFCx could not be found.

Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindUFCx.cmake:72 (find_package_handle_standard_args)
  CMakeLists.txt:260 (find_package)

  • So it seems in this particular case 0.6.0 is installed but not found of UFCx.

  • So when compiling main branch the problem is that 0.7.0 is not found and maybe not installed of UFCx

What do you see when you do spack find in your enviroment?
Can you confirm that it’s using spack’s installation? eg: which python3

Sometimes it’s just a matter of loading the packages manually:

spack env activate fenicsx-env
spack load fenics-dolfinx
1 Like

Thank you for asking so…

prusso@lenovo:~$ spack find
==> In environment fenicsx-env
==> Root specs
fenics-dolfinx@main  cflags="-O3" fflags="-O3"   fenics-ufcx@0.7.0 

==> Installed packages
-- linux-ubuntu22.04-skylake / gcc@11.3.0 -----------------------
autoconf@2.69                       expat@2.5.0          hwloc@2.9.1           libpciaccess@0.17  openblas@0.3.23  pmix@4.2.3              xz@5.4.1
automake@1.16.5                     fenics-basix@main    hypre@2.28.0          libsigsegv@2.14    openmpi@4.1.5    pugixml@1.13            zlib@1.2.13
berkeley-db@18.1.40                 fenics-dolfinx@main  krb5@1.20.1           libtool@2.4.7      openssh@9.3p1    python@3.10.10          zstd@1.5.5
bison@3.8.2                         fenics-ufcx@main     libbsd@0.11.7         libxcrypt@4.4.33   openssl@1.1.1u   readline@8.2
boost@1.82.0                        findutils@4.9.0      libedit@3.1-20210216  libxml2@2.10.3     parmetis@4.0.3   sqlite@3.42.0
bzip2@1.0.8                         gdbm@1.23            libevent@2.1.12       m4@1.4.19          perl@5.36.0      superlu-dist@8.1.2
ca-certificates-mozilla@2023-01-10  gettext@0.21.1       libffi@3.4.4          metis@5.1.0        petsc@3.19.1     tar@1.34
cmake@3.26.3                        gmake@4.4.1          libiconv@1.17         ncurses@6.4        pigz@2.7         util-linux-uuid@2.38.1
diffutils@3.9                       hdf5@1.14.1-2        libmd@1.0.4           numactl@2.0.14     pkgconf@1.9.5    util-macros@1.19.3
==> 57 installed packages
prusso@lenovo:~$ python
Python 3.10.10 (main, Jun 27 2023, 12:49:40) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>