FEniCS / dolfinx

Next generation FEniCS problem solving environment
https://fenicsproject.org
GNU Lesser General Public License v3.0
731 stars 177 forks source link

Core dump upon 'import dolfinx' when using Spack #2251

Closed frysally closed 2 years ago

frysally commented 2 years ago

Dear all, I tried to install DOLFINx on Anvil with Spack exactly following the link. It shows that the installation was successful intallation_log.txt, but when I input "python -c 'import dolfinx'", it outputs "Segmentation fault (core dumped)". Meanwhile, things like "import ufl" seem to work.

The python version I'm using is built within Spack (Python 3.9.13). I contacted Anvil team and they can reproduce the error. Instead, a containerized version with Singularity seems to work. However, Spack is still a preferred way to avoid MPI issues. Could you figure out what's happening?

cmaurini commented 2 years ago

I had a similar issue. Which OS do you have? Can you import basix?

Corrado

Le 23 juin 2022 à 21:05, frysally @.***> a écrit :

 Dear all, I tried to install DOLFINx on Anvil with Spack exactly following the link. It shows that the installation was successful intallation_log.txt, but when I input "python -c 'import dolfinx'", it outputs "Segmentation fault (core dumped)". Meanwhile, things like "import ufl" seem to work.

The python version I'm using is built within Spack (Python 3.9.13). I contacted Anvil team and they can reproduce the error. Instead, a containerized version with Singularity seems to work. However, Spack is still a preferred way to avoid MPI issues. Could you figure out what's happening?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

cmaurini commented 2 years ago

This was the solution for me

https://fenicsproject.slack.com/archives/C26N589GV/p1648056744986039

Le 23 juin 2022 à 21:33, Corrado Maurini @.***> a écrit :

I had a similar issue. Which OS do you have? Can you import basix?

Corrado

Le 23 juin 2022 à 21:05, frysally @.***> a écrit :

 Dear all, I tried to install DOLFINx on Anvil with Spack exactly following the link. It shows that the installation was successful intallation_log.txt, but when I input "python -c 'import dolfinx'", it outputs "Segmentation fault (core dumped)". Meanwhile, things like "import ufl" seem to work.

The python version I'm using is built within Spack (Python 3.9.13). I contacted Anvil team and they can reproduce the error. Instead, a containerized version with Singularity seems to work. However, Spack is still a preferred way to avoid MPI issues. Could you figure out what's happening?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

frysally commented 2 years ago

Thanks @cmaurini. The OS I'm using is CentOS 8 Linux. I cannot import basix--it also produces segfault.

cmaurini commented 2 years ago

So this is probably the same issue I had. After a long fight, I solved with this patch, adding NO EXTRAS option to pybind11 in CMakeListq.txt. It is probably a bug in RHEL8/CENTOS8, see https://github.com/pybind/pybind11/issues/3386. For me it appeared after a system update on the cluster.

diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index dea67a22d9..36d40ce837 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -43,7 +43,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)

 # Create the binding library
 # pybind11 handles its own calls to target_link_libraries
-pybind11_add_module(cpp MODULE
+pybind11_add_module(cpp MODULE NO_EXTRAS
   dolfinx/wrappers/dolfinx.cpp
   dolfinx/wrappers/common.cpp
   dolfinx/wrappers/fem.cpp
lgorenstein commented 2 years ago

Hello Corrado, thank you for the pointers! I am Anvil staff member who works with @frysally on this problem. The solutions that you pointed to (Pybind11 issue and adding NO_EXTRAS to pybind11_add_module() calls in basix and dolfinx's python/CMakeLists.txt) were very helpful!

Of course the crux is to wrap them up into Spack... and that was a little challenging. I brute-forced my way and added two patches to Spack's fenics-dolfinx/package.py (tarball with a crude hack attached, place its content into spack/var/spack/repos/builtin/packages/fenics-dolfinx, overwriting that package.py).

It worked, patched, and built dolfinx... yet still no luck:

$ which python
/home/lev/software/fenicsx/spack/spack/var/spack/environments/fenicsx-env/.spack-env/view/bin/python

$ python -c 'import dolfinx'
Segmentation fault (core dumped)

Lev

fenics-dolfinx.changes.tar.gz

cmaurini commented 2 years ago

Yes, I personally uses spack to build basic dependencies when needed, or the modules generated via spack by the sys-admin, but then I build petsc/basix/ffcx/ufl/dolfinx by myself. I am a little bit overwhelmed by the spack technology.

I suggest to try to build by hands just basix without dolfinx. It has a minimal set of dependencies. This is the way I found to get out of it.

lgorenstein commented 2 years ago

Update: Being in a bit of time crunch, we ~cheated~ have taken a shortcut and used the Conda method to install. Everything worked quite nicely, both simple import dopfinx and actual examples.

garth-wells commented 2 years ago

Closing, as most likely a bug in version of gcc shipped with Redhat/Centos 8.