jorgensd / dolfinx-tutorial

A reimplementation of the Springer book: https://github.com/hplgit/fenics-tutorial/, covering new topics as well as transitioning from dolfin to dolfinx
https://jorgensd.github.io/dolfinx-tutorial/
114 stars 64 forks source link

pyvista freeze #130

Closed fghoussen closed 1 year ago

fghoussen commented 1 year ago

Using docker image as explained here https://github.com/FEniCS/dolfinx/blob/main/README.md#installation.

Following https://jsdokken.com/dolfinx-tutorial/chapter2/linearelasticity_code.html, I end up with pyvista freezing (no GUI + stall => compelled to ctrl-C):

>>> p.show()
^C
Loguru caught a signal: SIGINT
Stack trace:
24      0x556937da7245 _start + 37
23      0x7f8c16e53e40 __libc_start_main + 128
22      0x7f8c16e53d90 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7f8c16e53d90]
21      0x556937da734d Py_BytesMain + 45
20      0x556937dd130c Py_RunMain + 1308
19      0x556937c1c520 PyRun_AnyFileExFlags + 79
18      0x556937ddfe58 _PyRun_AnyFileObject + 104
17      0x556937c30653 _PyRun_InteractiveLoopObject + 195
16      0x556937c309c6 python3(+0xb59c6) [0x556937c309c6]
15      0x556937dd9d5b python3(+0x25ed5b) [0x556937dd9d5b]
14      0x556937de0f08 python3(+0x265f08) [0x556937de0f08]
13      0x556937db4456 PyEval_EvalCode + 134
12      0x556937cbc766 python3(+0x141766) [0x556937cbc766]
11      0x556937cc014a _PyEval_EvalFrameDefault + 2058
10      0x556937cd73ac _PyFunction_Vectorcall + 124
9       0x556937cc014a _PyEval_EvalFrameDefault + 2058
8       0x556937cd73ac _PyFunction_Vectorcall + 124
7       0x556937cc648e _PyEval_EvalFrameDefault + 27470
6       0x556937ccd7db _PyObject_MakeTpCall + 603
5       0x556937cd6b88 python3(+0x15bb88) [0x556937cd6b88]
4       0x7f8bf4bfe8ed /usr/local/lib/python3.10/dist-packages/vtkmodules/vtkRenderingCore.cpython-310-x86_64-linux-gnu.so(+0x15c8ed) [0x7f8bf4bfe8ed]
3       0x7f8bf19bc8a4 vtkXRenderWindowInteractor::StartEventLoop() + 68
2       0x7f8bf19c048f vtkXRenderWindowInteractor::ProcessEvents() + 1039
1       0x7f8c16f457ed __select + 349
0       0x7f8c16e6c520 /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f8c16e6c520]
2023-05-27 11:55:11.822 ( 209.993s) [main            ]                       :0     FATL| Signal: SIGINT

root@2a7031a303bf:~/dolfinx-tutorial/chapter2# pip list | grep pyvista    
pyvista                       0.39.1
root@2a7031a303bf:~/dolfinx-tutorial/chapter2# pip list | grep vtk     
vtk                           9.2.6

Any clue?

jorgensd commented 1 year ago

How are you starting the docker container? Are you forwarding the necessary ports for a graphical user interface? Are you using a Python script or a notebook?

fghoussen commented 1 year ago

This does work: I have a GUI that pops up and I can navigate the into the colored mesh

>> cd /tmp
>> wget https://docs.fenicsproject.org/dolfinx/main/python/_downloads/b94ac7be61dc3726ca331afd20f195d2/demo_poisson.py
>> xhost +
>> sudo docker run --rm -it -e DISPLAY="$DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix -v /tmp:/root --name fenics_tuto dolfinx/dolfinx:stable
root@6ed4aea976a6:~# ls *.py                       
demo_poisson.py
root@6ed4aea976a6:~# apt update
root@6ed4aea976a6:~# apt install libgl1-mesa-glx xvfb
root@6ed4aea976a6:~# python3 -m pip install pyvista
root@6ed4aea976a6:~# python3 demo_poisson.py 

But this doesn't work: the visualization stalls

>> cd /tmp
>> git clone https://github.com/jorgensd/dolfinx-tutorial
>> xhost +
>> sudo docker run --rm -it -e DISPLAY="$DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix -v /tmp:/root --name fenics_tuto dolfinx/dolfinx:stable
root@3f7f2f14821f:~# ls dolfinx-tutorial/
Changelog.md  README.md    _toc.yml    chapter1  chapter3  docker  fenics_logo.png  index.ipynb          references.bib  tox.ini
Dockerfile    _config.yml  binder.png  chapter2  chapter4  fem.md  git.png      jupyter_book.code-workspace  save.png
root@3f7f2f14821f:~# apt-get update
root@3f7f2f14821f:~# apt install libgl1-mesa-glx xvfb
root@3f7f2f14821f:~# python3 -m pip install pyvista
root@3f7f2f14821f:~# cd dolfinx-tutorial/chapter2/
root@3f7f2f14821f:~/dolfinx-tutorial/chapter2# python3 linearelasticity_code.py
^C
Loguru caught a signal: SIGINT
Stack trace:
23      0x55592eb8c245 _start + 37
22      0x7fce699bbe40 __libc_start_main + 128
21      0x7fce699bbd90 /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fce699bbd90]
20      0x55592eb8c34d Py_BytesMain + 45
19      0x55592ebb60ae Py_RunMain + 702
18      0x55592ebc4e33 _PyRun_AnyFileObject + 67
17      0x55592ebc5138 _PyRun_SimpleFileObject + 424
16      0x55592ebc5c55 python3(+0x265c55) [0x55592ebc5c55]
15      0x55592ebbed5b python3(+0x25ed5b) [0x55592ebbed5b]
14      0x55592ebc5f08 python3(+0x265f08) [0x55592ebc5f08]
13      0x55592eb99456 PyEval_EvalCode + 134
12      0x55592eaa1766 python3(+0x141766) [0x55592eaa1766]
11      0x55592eaa514a _PyEval_EvalFrameDefault + 2058
10      0x55592eabc3ac _PyFunction_Vectorcall + 124
9       0x55592eaa514a _PyEval_EvalFrameDefault + 2058
8       0x55592eabc3ac _PyFunction_Vectorcall + 124
7       0x55592eaab48e _PyEval_EvalFrameDefault + 27470
6       0x55592eab27db _PyObject_MakeTpCall + 603
5       0x55592eabbb88 python3(+0x15bb88) [0x55592eabbb88]
4       0x7fce470e68ed /usr/local/lib/python3.10/dist-packages/vtkmodules/vtkRenderingCore.cpython-310-x86_64-linux-gnu.so(+0x15c8ed) [0x7fce470e68ed]
3       0x7fce43ebc8a4 vtkXRenderWindowInteractor::StartEventLoop() + 68
2       0x7fce43ec048f vtkXRenderWindowInteractor::ProcessEvents() + 1039
1       0x7fce69aad7ed __select + 349
0       0x7fce699d4520 /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fce699d4520]
2023-05-27 14:44:07.110 (  37.145s) [main            ]                       :0     FATL| Signal: SIGINT

Did I miss something?

How are you starting the docker container?

Yes

Are you forwarding the necessary ports for a graphical user interface?

Yes

Are you using a Python script or a notebook?

python script

fghoussen commented 1 year ago

Any clue so far?

jorgensd commented 1 year ago

Any clue so far?

Please note that is the weekend, and it doesn't help adding extra posts here. Try removing pyvista.start_xvfb().

fghoussen commented 1 year ago

Sorry didn't meant to disturb. As I work, I can only deal with that topic by the week-end.

Try removing pyvista.start_xvfb().

Worked, thanks! Do you want me to PR this change?

jorgensd commented 1 year ago

Sorry didn't meant to disturb. As I work, I can only deal with that topic by the week-end.

Try removing pyvista.start_xvfb().

Worked, thanks! Do you want me to PR this change?

No, as it stands, most pyvista visualization needs xvfb (for instance in jupyter notebook or for screenshots). As the tutorial is based on the ipynb scripts (to render the webpage) I need start_xvfb() to run and render plots there.

What you could do is to add a comment or separate section about plotting in chapter1, where one goes through what is needed for various plotting methods.