Installation in Docker dev-env failing due to missing SCOTCH/ParMETIS dependencies

Hallo,

I am trying to install dolfinx from source inside the latest Docker dev-env image (fetched using docker pull dolfinx/dev-env:nightly).
Cloning and installing ufl, basix and ffcx works fine, but after subsequent cloning and trying to install dolfinx:

git clone https://github.com/FEniCS/dolfinx.git
cd dolfinx/cpp && mkdir build && cd build
cmake ..

I get

– SCOTCH could not be found. Be sure to set SCOTCH_ROOT. (missing: SCOTCH_LIBRARIES SCOTCH_INCLUDE_DIRS SCOTCH_TEST_RUNS) **
– ParMETIS could not be found/configured. (missing: PARMETIS_LIBRARIES PARMETIS_TEST_RUNS PARMETIS_INCLUDE_DIRS PARMETIS_VERSION PARMETIS_VERSION_OK) (Required is at least version β€œ4.0.2”)
CMake Error at CMakeLists.txt:359 (message):
** No graph partitioner found. SCOTCH, ParMETIS or KaHIP is required.

So, I understood that the dev-env Docker container already contains all PETSc and other related dependencies to install dolfinx. Do I see this wrong and would I need to install some of the other dependencies, too?

Thanks for advice.

Best,
Marc

You need to set the PETSC_DIR and PETSC_ARCH as the dev-env does not set these (as it contains multiple installations of PETSc, real32, complex32 etc).

Thanks. This worked (setting PETSC_DIR=/usr/local/petsc and PETSC_ARCH=linux-gnu-real-64) and I could build according to the instructions.

Trying to run a demo/importing dolfinx in Python3 however yields

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/shared/work/codes/fenicsx/dolfinx/python/dolfinx/__init__.py", line 34, in <module>
    from dolfinx.common import (TimingType, git_commit_hash, has_debug, has_kahip,
  File "/home/shared/work/codes/fenicsx/dolfinx/python/dolfinx/common.py", line 11, in <module>
    from dolfinx import cpp as _cpp
ImportError: cannot import name 'cpp' from partially initialized module 'dolfinx' (most likely due to a circular import) (/home/shared/work/codes/fenicsx/dolfinx/python/dolfinx/__init__.py)

Would you have an idea on this?

Thanks!

I would need the output of the build-logs to be able to give any guidance on this, as this usually means that something failed during installation of the python bindings.

After calling cmake -DCMAKE_INSTALL_PREFIX=../build_install .. inside dolfinx/cpp/build, I get the following inside the CMakeError.log:

Determining if the PETSC_USE_COMPLEX exist failed with the following output:
Change Dir: /home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_6e70f/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_6e70f.dir/build.make CMakeFiles/cmTC_6e70f.dir/build
gmake[1]: Entering directory '/home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_6e70f.dir/CheckSymbolExists.c.o
/usr/bin/cc  -I/usr/local/petsc/linux-gnu-real-64/include -I/usr/local/petsc/include  -o CMakeFiles/cmTC_6e70f.dir/CheckSymbolExists.c.o -c /home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function 'main':
/home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: 'PETSC_USE_COMPLEX' undeclared (first use in this function); did you mean 'PETSC_HAVE_COMPLEX'?
    8 |   return ((int*)(&PETSC_USE_COMPLEX))[argc];
      |                   ^~~~~~~~~~~~~~~~~
      |                   PETSC_HAVE_COMPLEX
/home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
gmake[1]: *** [CMakeFiles/cmTC_6e70f.dir/build.make:78: CMakeFiles/cmTC_6e70f.dir/CheckSymbolExists.c.o] Error 1
gmake[1]: Leaving directory '/home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:127: cmTC_6e70f/fast] Error 2


File /home/shared/work/codes/fenicsx/dolfinx/cpp/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <petscsystypes.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef PETSC_USE_COMPLEX
  return ((int*)(&PETSC_USE_COMPLEX))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Not sure if this is related to the import issue.

Could you add the full output and call ls $PETS_DIR and ls $PETS_DIR/$PETSC_ARCH to make sure that the env variables are set correctly.

Sure. So here is what I’m doing after having pulled the container, docker pull dolfinx/dev-env:nightly.
I’m launching the container with the following .env.list file:

PYTHONPATH=/home/shared/work/codes/fenicsx/ffcx:/home/shared/work/codes/fenicsx/ufl:/home/shared/work/codes/fenicsx/basix/python:/home/shared/work/codes/fenicsx/dolfinx/python
PETSC_DIR=/usr/local/petsc
PETSC_ARCH=linux-gnu-real-64
Basix_DIR=/home/shared/work/codes/fenicsx/basix/_skbuild/linux-x86_64-3.10/cmake-install/python/basix/lib/cmake/basix
DOLFINX_DIR=/home/shared/work/codes/fenicsx/dolfinx_install/lib/cmake/dolfinx/

Then, inside the container, I navigate to /home/shared/work/codes/fenicsx and execute the following commands:

git clone https://github.com/fenics/ufl.git
git clone https://github.com/fenics/basix.git
git clone https://github.com/fenics/ffcx.git
git clone https://github.com/fenics/dolfinx.git
cd ufl   && pip3 -v install --no-deps --no-cache-dir . && cd ..
cd basix && pip3 -v install --no-deps --no-cache-dir . && cd ..
cd ffcx  && pip3 -v install --no-deps --no-cache-dir . && cd ..
mkdir -p dolfinx/cpp/build && mkdir -p dolfinx_install && cd dolfinx/cpp/build && cmake -DCMAKE_INSTALL_PREFIX=../../../dolfinx_install .. && make install && cd ../../..
source dolfinx_install/lib/dolfinx/dolfinx.conf
cd dolfinx/python && pip3 -v install --no-deps --no-cache-dir . && cd ../..

echo $PETSC_DIR gives /usr/local/petsc and echo $PETSC_ARCH outputs linux-gnu-real-64. CMake error and output files are on my web server (too large for being posted):
http://www.deepambit.com/CMakeError.log
http://www.deepambit.com/CMakeOutput.log

Now, typing python3 and then in the command prompt import dolfinx yields the error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/shared/work/codes/fenicsx/dolfinx/python/dolfinx/__init__.py", line 34, in <module>
    from dolfinx.common import (TimingType, git_commit_hash, has_debug, has_kahip,
  File "/home/shared/work/codes/fenicsx/dolfinx/python/dolfinx/common.py", line 11, in <module>
    from dolfinx import cpp as _cpp
ImportError: cannot import name 'cpp' from partially initialized module 'dolfinx' (most likely due to a circular import) (/home/shared/work/codes/fenicsx/dolfinx/python/dolfinx/__init__.py)

Hope that helps, thank you!

I cannot reproduce this with the following dockerfile:

FROM dolfinx/dev-env:nightly
WORKDIR /tmp
ENV PETSC_DIR=/usr/local/petsc
ENV PETSC_ARCH=linux-gnu-real-64

RUN git clone https://github.com/fenics/ufl.git && \
    python3 -m pip -v install --no-deps --no-cache-dir ufl/

RUN git clone https://github.com/fenics/basix.git && \
    python3 -m pip -v install --no-deps --no-cache-dir basix/

RUN git clone https://github.com/fenics/ffcx.git && \
    python3 -m pip -v install --no-deps --no-cache-dir ffcx/

RUN git clone https://github.com/fenics/dolfinx.git && \
    cmake -G Ninja -B build-dir-dolfinx -DCMAKE_BUILD_TYPE=Debug -S dolfinx/cpp &&\
    cmake --build build-dir-dolfinx && \
    cmake --install build-dir-dolfinx

RUN python3 -m pip -v install --no-deps --no-cache-dir dolfinx/python

RUN python3 -c "import dolfinx; import petsc4py; petsc4py.init(); print(petsc4py.PETSc)"

returning

#11 [8/8] RUN python3 -c "import dolfinx; import petsc4py; petsc4py.init(); print(petsc4py.PETSc)"
#11 0.706 <module 'petsc4py.PETSc' (/usr/local/lib/python3.10/dist-packages/petsc4py/lib/linux-gnu-real-64/PETSc.cpython-310-x86_64-linux-gnu.so)>

for the last step.
It also runs nicely with

ENV PETSC_ARCH=linux-gnu-complex-64

with output:


#11 [8/8] RUN python3 -c "import dolfinx; import petsc4py; petsc4py.init(); print(petsc4py.PETSc)"
#11 0.753 <module 'petsc4py.PETSc' (/usr/local/lib/python3.10/dist-packages/petsc4py/lib/linux-gnu-complex-64/PETSc.cpython-310-x86_64-linux-gnu.so)>
#11 DONE 0.8s

1 Like

Thanks, it’s working like this for me. Not sure what the cause of the problem was. Maybe that something got mixed up with install locations, as I used others than /usr/local.