CMake error while building and installing dolfinx c++ core

It does not seem like you have an appropriate version of PETSc installed

It seems like you are on the DOLFINx main branch, and not on the 0.5.X branch that is compatible with your ffcx installation

Well this is strange because this is the version I have installed:

Name: petsc
Version: 3.18.2

So I don’t know how I can fix that.
Now I’m in the c++ build and this is what it outputs:

CMake Error at /home/krizerator/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find UFCx: Found unsuitable version "0.5.0.post0", but required
  is at least "0.6" (found
  /usr/lib/python3/dist-packages/ffcx/codegeneration)

      Reason given by package: UFCx could not be found.

Call Stack (most recent call first):
  /home/krizerator/.local/lib/python3.8/site-packages/cmake/data/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:598 (_FPHSA_FAILURE_MESSAGE)
  cmake/modules/FindUFCx.cmake:63 (find_package_handle_standard_args)
  CMakeLists.txt:199 (find_package)

Looks like the exact same thing as before, I’m not sure if I’m doing it right :sweat_smile:

Did you set PETSC_DIR and PETSC_ARCH so that it points to the installation of PETSc?

Make sure that the branches of DOLFINx, FFCx and Basix are consistent, and that python3 -m pip list lists these versions of fenics-basix and fenics-ffcx

Yes I set them to the installation directory and the versions of basix and ffcx are 0.5.0 and 0.5.0.post0 respectively. Still the same error.

What is the output of git branch when you call it from within the dolfinx folder?

The output is this:
* main

You should not use the main branch of DOLFINx if you use the 0.5.X version of the other libraries. You should use the v0.5.2 branch Release v0.5.2 · FEniCS/dolfinx · GitHub

Excuse me the question if it’s too basic, but how can I use this version? I’ve only used GitHub a few times and I’m not sure how this works. I just want to make fenics work in my pc but neither legacy fenics or fenicsx work and I need to make sure I can simulate stuff. I’m really worried because it’s taken a long time for me to achieve this trying to fix packages and so on. Isn’t there an “easy way” to install fenics? I mean I know how to program but I’m not an expert in a lot of things like docker (I don’t even know what a container is in programming) or Git. Some time ago fenics worked fine but now it doesn’t. I could even generate simulations like this but not anymore:
induction
p3
If there is an easy way out of all of this and you know it, like uninstalling and reinstalling properly or something I’d appreciate it.

Use git checkout v0.5.2 inside the dolfinx repo

I have already referred you to

  1. Docker
  2. conda

You will have an issue with trying to install both dolfin and dolfinx globally on your system, as they depend on different versions of ufl.

Long story short: to make life simple, use conda to install dolfin/dolfinx

I followed the steps for conda and into the fenicsx-env I ran the program and still there are some errors:

INFO:root:running build_ext
INFO:root:building 'libffcx_forms_3ab349c4998802b05e03df1716e1be81cd712806' extension
INFO:root:/home/krizerator/anaconda3/envs/fenicsx-env/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/krizerator/anaconda3/envs/fenicsx-env/include -fPIC -O2 -isystem /home/krizerator/anaconda3/envs/fenicsx-env/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/krizerator/anaconda3/envs/fenicsx-env/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/krizerator/anaconda3/envs/fenicsx-env/include -fPIC -I/home/krizerator/anaconda3/envs/fenicsx-env/lib/python3.10/site-packages/ffcx/codegeneration -I/home/krizerator/anaconda3/envs/fenicsx-env/include/python3.10 -c libffcx_forms_3ab349c4998802b05e03df1716e1be81cd712806.c -o ./libffcx_forms_3ab349c4998802b05e03df1716e1be81cd712806.o -O2 -g0
INFO:root:/home/krizerator/anaconda3/envs/fenicsx-env/bin/x86_64-conda-linux-gnu-cc -shared -Wl,--allow-shlib-undefined -Wl,-rpath,/home/krizerator/anaconda3/envs/fenicsx-env/lib -Wl,-rpath-link,/home/krizerator/anaconda3/envs/fenicsx-env/lib -L/home/krizerator/anaconda3/envs/fenicsx-env/lib -Wl,--allow-shlib-undefined -Wl,-rpath,/home/krizerator/anaconda3/envs/fenicsx-env/lib -Wl,-rpath-link,/home/krizerator/anaconda3/envs/fenicsx-env/lib -L/home/krizerator/anaconda3/envs/fenicsx-env/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/krizerator/anaconda3/envs/fenicsx-env/lib -Wl,-rpath-link,/home/krizerator/anaconda3/envs/fenicsx-env/lib -L/home/krizerator/anaconda3/envs/fenicsx-env/lib -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/krizerator/anaconda3/envs/fenicsx-env/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/krizerator/anaconda3/envs/fenicsx-env/include ./libffcx_forms_3ab349c4998802b05e03df1716e1be81cd712806.o -o ./libffcx_forms_3ab349c4998802b05e03df1716e1be81cd712806.cpython-310-x86_64-linux-gnu.so
WARNING:py.warnings:/home/krizerator/anaconda3/envs/fenicsx-env/lib/python3.10/site-packages/pyvista/plotting/plotting.py:131: UserWarning:
This system does not appear to be running an xserver.
PyVista will likely segfault when rendering.

Try starting a virtual frame buffer with xvfb, or using
  ``pyvista.start_xvfb()``

  warnings.warn(

[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple MacOS to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59
:
system msg for write_line failure : Bad file descriptor

I also did this

See Problem about pyvista - #2 by dokken

Thank you so much! Looks like things are starting to work out now but somehow strange… When I start running the code, looks like there’s only one import error towards ufl:

(base) krizerator@Clarke:/mnt/d/A--X/Programming/Python$ python3 demo_poisson.py
Traceback (most recent call last):
  File "demo_poisson.py", line 72, in <module>
    import ufl
ModuleNotFoundError: No module named 'ufl'

Notice that this happens when I run it on the base. But when I run it in the venv mentioned in Problem about pyvista - #2 by dokken, then I get this:

(fenicsx-env) krizerator@Clarke:/mnt/d/A--X/Programming/Python$ python3 demo_poisson.py
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple MacOS to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0
[unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59
:
system msg for write_line failure : Bad file descriptor

Why would it be? And what could I do to fix the import problem? I already checked the ufl but it’s installed:

(base) krizerator@Clarke:/mnt/d/A--X/Programming/Python$ pip3 show ufl
Name: UFL
Version: 2017.1.0
Summary: Unified Form Language
Home-page: https://bitbucket.org/fenics-project/ufl/
Author: Martin Sandve Alnæs, Anders Logg
Author-email: fenics-dev@googlegroups.com
License: UNKNOWN
Location: /home/krizerator/.local/lib/python3.8/site-packages
Requires: numpy, six
Required-by:

Mixing conda and pip is not adviced, as your pip3 installation is probably not linked to the conda python env. Try calling python3 -m pip show ufl and see what you get.

Try to remove the last few lines of the demo poisson (that uses pyvista) and I guess the code will be running fine.
It is unclear to me what you have added from

as you do not show the code.

1 Like

Hello and happy new year, best wishes!

I figured out that effectively when I’m using conda, ufl and other packages are not found. As soon as I quit conda, there’s not that problem anymore.

I just followed the instructions as mentioned there. It looks like it worked.
Now, I removed the last lines as you mentioned for demo_poisson.py but now I get this error:

[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
malloc_consolidate(): invalid chunk size
[Clarke:00459] *** Process received signal ***
[Clarke:00459] Signal: Aborted (6)
[Clarke:00459] Signal code:  (-6)
[Clarke:00459] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x43090)[0x7f5f805bd090]
[Clarke:00459] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f5f805bd00b]
[Clarke:00459] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f5f8059c859]
[Clarke:00459] [ 3] /lib/x86_64-linux-gnu/libc.so.6(+0x8d26e)[0x7f5f8060726e]
[Clarke:00459] [ 4] /lib/x86_64-linux-gnu/libc.so.6(+0x952fc)[0x7f5f8060f2fc]
[Clarke:00459] [ 5] /lib/x86_64-linux-gnu/libc.so.6(+0x95ad8)[0x7f5f8060fad8]
[Clarke:00459] [ 6] /lib/x86_64-linux-gnu/libc.so.6(+0x97c83)[0x7f5f80611c83]
[Clarke:00459] [ 7] /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x1b9)[0x7f5f80614299]
[Clarke:00459] [ 8] /lib/x86_64-linux-gnu/libopen-pal.so.40(opal_show_help_yy_create_buffer+0x39)[0x7f5f774e0219]
[Clarke:00459] [ 9] /lib/x86_64-linux-gnu/libopen-pal.so.40(opal_show_help_init_buffer+0x12)[0x7f5f774e1a32]
[Clarke:00459] [10] /lib/x86_64-linux-gnu/libopen-pal.so.40(opal_show_help_vstring+0x1a3)[0x7f5f774dfa73]
[Clarke:00459] [11] /lib/x86_64-linux-gnu/libopen-rte.so.40(orte_show_help+0xe3)[0x7f5f77554413]
[Clarke:00459] [12] /lib/x86_64-linux-gnu/libmpi.so.40(MPI_Abort+0x70)[0x7f5f79c2add0]
[Clarke:00459] [13] /lib/x86_64-linux-gnu/libpetsc_real.so.3.12(PetscSignalHandlerDefault+0x1e2)[0x7f5f606d34f2]
[Clarke:00459] [14] /lib/x86_64-linux-gnu/libpetsc_real.so.3.12(+0x12c577)[0x7f5f606d3577]
[Clarke:00459] [15] /lib/x86_64-linux-gnu/libc.so.6(+0x43090)[0x7f5f805bd090]
[Clarke:00459] [16] /home/krizerator/.local/lib/python3.8/site-packages/basix/_basixcpp.cpython-38-x86_64-linux-gnu.so(+0x2eb1b)[0x7f5f5f552b1b]
[Clarke:00459] [17] /home/krizerator/.local/lib/python3.8/site-packages/basix/_basixcpp.cpython-38-x86_64-linux-gnu.so(+0x3f63d)[0x7f5f5f56363d]
[Clarke:00459] [18] /home/krizerator/.local/lib/python3.8/site-packages/basix/_basixcpp.cpython-38-x86_64-linux-gnu.so(+0x43eb8)[0x7f5f5f567eb8]
[Clarke:00459] *** End of error message ***
Aborted

Again it seems like you are linking against an outdated version of PETSc

I just tried installing with Ubuntu instructions from a VM and it works. I couldn’t solve the problem with petsc but at least now I can see the results.