<div dir="ltr"><div>@Lawrence, thanks for the details, but point 7 fails with : <br>
</div><div><br></div><div>ERROR: Invalid requirement: '/usr/local/petsc/src/binding/petsc4py'<br>
Hint: It looks like a path. File
'/usr/local/petsc/src/binding/petsc4py' does not exist.</div><div><br></div><div>Just like @wence's tentative command. I've changed the dockerfile of dolfinx to add the --with-hdf5 flag and I'm trying to build a new optimised docker image with :</div><br>echo '{ "cffi_extra_compile_args" : ["-O2", "-march=native" ] }' > dolfinx_jit_parameters.json<br><div>docker build --target dolfinx --file Dockerfile --build-arg PETSC_SLEPC_OPTFLAGS="-O2 -march=native" --build-arg DOLFINX_CMAKE_CXX_FLAGS="-march=native" .</div><div><br></div><div>It's slowgoing, but it might eventually do the trick I guess.<br></div><div><br></div><div>@bsmith, the --with-petsc4py flag changes nothing.</div> <br><div>MWE is unchanged :<br></div><span class="gmail-im"><div>* Run<a href="https://hub.docker.com/r/dolfinx/dolfinx" target="_blank"> this docker container</a><br>* Do : python3 -c "from petsc4py import PETSc; PETSc.Viewer().createHDF5('dummy.h5')"<br><br></div></span><div>Updated attempt at a fix :<br></div><div>* cd /usr/local/petsc/<br>* ./configure --with-hdf5 --with-petsc4py --force (turns out the container sets PETSC_ARCH and PETSC_DIR as environment variables by default)<br>* make all</div><div><br></div><div>This still produces the same error :<br></div><div><br></div><div>Traceback (most recent call last):<br>  File "<string>", line 1, in <module><br>  File "PETSc/Viewer.pyx", line 182, in petsc4py.PETSc.Viewer.createHDF5<br>petsc4py.PETSc.Error: error code 86<br>[0] PetscViewerSetType() at /usr/local/petsc/src/sys/classes/viewer/interface/viewreg.c:442<br>[0] Unknown type. Check for miss-spelling or missing package: <a href="https://petsc.org/release/install/install/#external-packages">https://petsc.org/release/install/install/#external-packages</a><br>[0] Unknown PetscViewer type given: hdf5<br></div><div><br></div>Quentin<br><br></div><br clear="all"><div><div dir="ltr" class="gmail_signature"><div dir="ltr"><span style="font-family:"Arial",sans-serif;color:black"> </span>
<div>
<table style="width:369pt;margin-left:5.4pt;border-collapse:collapse" width="0" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr style="height:63pt">
<td style="width:57.75pt;border-color:windowtext currentcolor currentcolor;border-style:solid none none;border-width:1.5pt medium medium;padding:0cm 5.4pt;height:63pt" width="77" valign="top">
<p class="MsoNormal" style="margin-top:6pt;text-align:center" align="center"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)"><img style="width: 0.427in; height: 1in;" src="cid:image003.jpg@01D690CB.3B3FDC10" alt="cid:image003.jpg@01D690CB.3B3FDC10" width="41" height="96"></span></p>
</td>
<td style="width:311.25pt;border-style:solid none none;border-width:1.5pt medium medium;padding:0cm 5.4pt;height:63pt;border-color:currentcolor" width="415" valign="top">
<p class="MsoNormal" style="margin-right:0cm;margin-left:0.85pt;margin-bottom:0.0001pt;line-height:12pt;break-after:avoid">
<span style="font-size:11pt;font-family:"Berlin Sans FB",sans-serif;color:rgb(127,127,127)">Quentin CHEVALIER – IA parcours recherche</span></p>
<p class="MsoNormal" style="margin-left:0.9pt;line-height:12pt;break-after:avoid">
<span style="font-size:11pt;font-family:"Berlin Sans FB",sans-serif;color:rgb(127,127,127)">LadHyX - Ecole polytechnique</span></p>
<p class="MsoNormal" style="margin-left:0.9pt;line-height:12pt;break-after:avoid">
<span style="font-size:11pt;font-family:"Berlin Sans FB",sans-serif;color:rgb(127,127,127)">__________</span></p></td></tr></tbody></table></div></div></div></div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 7 Dec 2021 at 16:52, Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><br></div>  You can also just add --with-petsc4py to your PETSc configure command and it will manage automatically the petsc4py install. So<div><br></div><div><span style="font-size:13px">./configure --with-hdf5 --any-other --configure-flags --you-want --with-petsc4py</span></div><div><font size="2"><br></font></div><div><font size="2"><br></font><div> Some people don't like this approach, I don't understand exactly why not; it should be equivalent (if it is not equivalent then perhaps it could be fixed?).</div><div><br><blockquote type="cite"><div>On Dec 7, 2021, at 10:18 AM, Lawrence Mitchell <<a href="mailto:wence@gmx.li" target="_blank">wence@gmx.li</a>> wrote:</div><br><div><div>Comments inline below:<br><br><blockquote type="cite">On 7 Dec 2021, at 14:43, Quentin Chevalier <<a href="mailto:quentin.chevalier@polytechnique.edu" target="_blank">quentin.chevalier@polytechnique.edu</a>> wrote:<br><br>@Matthew, as stated before, error output is unchanged, i.e.the python<br>command below produces the same traceback :<br><br># python3 -c "from petsc4py import PETSc; PETSc.Viewer().createHDF5('d.h5')"<br>Traceback (most recent call last):<br> File "<string>", line 1, in <module><br> File "PETSc/Viewer.pyx", line 182, in petsc4py.PETSc.Viewer.createHDF5<br>petsc4py.PETSc.Error: error code 86<br>[0] PetscViewerSetType() at<br>/usr/local/petsc/src/sys/classes/viewer/interface/viewreg.c:442<br>[0] Unknown type. Check for miss-spelling or missing package:<br><a href="https://petsc.org/release/install/install/#external-packages" target="_blank">https://petsc.org/release/install/install/#external-packages</a><br>[0] Unknown PetscViewer type given: hdf5<br><br>@Wence that makes sense. I'd assumed that the original PETSc had been<br>overwritten, and if the linking has gone wrong I'm surprised anything<br>happens with petsc4py at all.<br><br>Your tentative command gave :<br><br>ERROR: Invalid requirement: '/usr/local/petsc/src/binding/petsc4py'<br>Hint: It looks like a path. File<br>'/usr/local/petsc/src/binding/petsc4py' does not exist.<br><br>So I tested that global variables PETSC_ARCH & PETSC_DIR were correct<br>then ran "pip install petsc4py" to restart petsc4py from scratch.<br></blockquote><br>This downloads petsc4py from pypi. It is not guaranteed to give you a version that matches the PETSc version you have installed (which is the source of your error below)<br><br><br><blockquote type="cite">This<br>gives rise to a different error :<br><br></blockquote>[...]<br><blockquote type="cite">ImportError: /usr/local/lib/python3.9/dist-packages/petsc4py/lib/linux-gnu-real-32/<a href="http://PETSc.cpython-39-x86_64-linux-gnu.so" target="_blank">PETSc.cpython-39-x86_64-linux-gnu.so</a>:<br>undefined symbol: petscstack<br><br>Not sure that it a step forward ; looks like petsc4py is broken now.<br></blockquote><br>The steps to build PETSc with HDF5 support and then get a compatible petsc4py are:<br><br>1. Download the PETSc source somehow (<a href="https://petsc.org/release/download/" target="_blank">https://petsc.org/release/download/</a>)<br><br>I now assume that this source tree lives in .../petsc<br><br>2. cd .../petsc<br><br>3. ./configure --with-hdf5 --any-other --configure-flags --you-want<br><br>4. Run the appropriate "make" command as suggested by configure<br><br>5. Run the appropriate "make check" command as suggested by configure<br><br>6. Set PETSC_DIR and PETSC_ARCH appropriately<br><br>7. pip install src/binding/petsc4py<br><br>If you are working the docker container from dolfinx/dolfinx, you can see the commands that are run to install PETSc, and then petsc4py, here <a href="https://github.com/FEniCS/dolfinx/blob/main/docker/Dockerfile#L243" target="_blank">https://github.com/FEniCS/dolfinx/blob/main/docker/Dockerfile#L243</a><br><br>If you want to reproduce these versions of PETSc but with the addition of HDF5 support, just add --with-hdf5 to all of the relevant configure lines.<br><br>Lawrence<br><br><br></div></div></blockquote></div><br></div></div></blockquote></div>