How to install Scotch and ParaMETIS inside a docker container?

I pulled from docker with:

docker run -ti dolfinx/dev-env:stable

I was able to access the container through Visual Studio Code to attach the application to the container and also to start shells with. So I got a clone from git of Basix, ffcx and dolfinx all of --branch v0.6.0.

I installed Basix following the instructions first for the cpp folder with cmake and then with pip. I installed ffcx per the instuctions only with pip. Upon attempting to compile with cmake dolfinx/cpp/build/cmake … I have found that:

CMake Error at CMakeLists.txt:356 (message):
  No graph partitioner found.  SCOTCH, ParMETIS or KaHIP is required.

So far I looked to:
Installation in Docker dev-env failing due to missing SCOTCH/ParMETIS dependencies.

which wasn’t really very understandable to me yet. I see talk of setting PETSc environment variables but not sure how that would relate to SCOTCH and ParMETIS. So far no issues are being reported to me about a missing PETSc dependency yet.

So I was curious is there some instructions so far on how to install SCOTCH and ParMETIS dependancies and/or find those dependancies on the system if they are installed someplace, for a docker container configuration?

So far when trying to run demo_elasticity.py from the git clone of dolfinx I have from the container’s terminal:

root@8631439e9191:~/dolfinx#  /usr/bin/env /bin/python3 /root/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 60189 -- /root/dolfinx/python/demo/demo_elasticity.py 
Traceback (most recent call last):
  File "/root/dolfinx/python/demo/demo_elasticity.py", line 25, in <module>
    from dolfinx import la
ModuleNotFoundError: No module named 'dolfinx'
root@8631439e9191:~/dolfinx# 

So that is why I was compiling from source dolfinx and ran into the missing SCOTCH, ParMETIS missing dependencies situation…

PETSc installs scotch.

The images

Installs petsc, But you have Yo set the correct petsc-dir and petsc arch to specify what version of petsc to use.

In your case, I would assume export PETSC_ARCH="linux-gnu-real64-32" would do.
See for instance dolfinx/docker/Dockerfile.end-user at main · FEniCS/dolfinx · GitHub
and the rest of instructions in the docker file that explain how to build on top of dev-env.

Is there a reason not to use
dolfinx/dolfinx:stable?

For further reference: SCOTCH and KaHIP are definitely in the dev-env image. See ParMETIS not found when building `dolfinx` with `docker/Dockerfile.end-user` · Issue #2845 · FEniCS/dolfinx · GitHub for the reason why you will not find ParMETIS.

Seems ParMETIS depends on GKlib. Also so far I didn’t finish building ParMETIS and installing because mpi.h is missing I would guess from the OpenMOU dependency…

a find -name “mpi.h” doesn’t seem to find anything for me yet… Is it possible I would have to install OpenMPI or am I maybe not knowing where to find it so I can add mpi.h to $PATH…

Its not clear to me why you have chosen to go down the tangential, and quite more challenging route of installing parmetis from source, when Ive explained to you how to Get the Pre-built image with scotch.
You also didn’t answer the question

So far it has been explained that there is a `dolfinx/dolfinx:stable to use with docker as far as I know. So upon pulling one with docker I had found that dolfinx scripts do not yet run out of the box so to speak (no module error). So that is reason for pulling a branch from git of dolfinx and seeing if it will compile and install inside the container as a way of getting the no module found to go away and scripts to run…

So far I found as far as installing the dependencies for a git pull of dolfinx that ParMETIS depends on GTKLib and OpenMPI. So far first two are fine to install OpenMPI 3.1 ending in not being found by a ~/dolfinx/cpp/build/cmake … but it did install. Along with OpenMPI 5 that turned out to be the wrong version for dolfinxv0.6.0.

As far as pulling a prebuilt from scratch I know how to pull a docker container from said stable branch but really don’t yet understand what is meant other than that…

dolfinx/dolfinx:stable should run out of the box. What error are you getting and what script are you running?

In terms of what errors I am getting:

import pyvista
from dolfinx import mesh, fem, plot, io, default_scalar_type
from dolfinx.fem.petsc import LinearProblem
from mpi4py import MPI
import ufl
import numpy as np

dolfinx, dolfinx-fem.petsc is not resolved it.

I thought to ask is it accepted to use spack inside a docker container or is that for desktop use only?

Could you please add your full error message (stack trace), as I dont understand what you mean by this.

Please also add all commands that you are running, both to start the container and run code in it.

Also note that pyvista is only present in the dolfinx/lab:stable images, which you can run with
docker run -ti --rm -v $(pwd):/root/shared --entrypoint="/bin/bash" dolfinx/lab:stable as shown in

1 Like

So in terms of running this command:
docker run -ti dolfinx/dev-env:stable

and running in the terminal that appears for the root user I can call the command python3 and from the >> import dolfinx
which at first is a “No Module Found”.

After realizing this I tried to use spack as the gitub instructions say to. The resulting output appears from the terminal:

root@c413eada309c:~#  cd /root ; /usr/bin/env /bin/python3 /root/.vscode-server/extensions/ms-python.python-2023.22.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 40709 -- /root/Untitled-2.py 
Traceback (most recent call last):
  File "/root/Untitled-2.py", line 3, in <module>
    from dolfinx import mesh, fem, plot, io, default_scalar_type
ImportError: cannot import name 'mesh' from 'dolfinx' (unknown location)
root@c413eada309c:~# 

docker run -ti dolfinx/dolfinx:nightly does seem to come up OK. I maybe had a misunderstanding about usage of docker.

Again, Im not asking you to run dolfinx/dev-env:stable but dolfinx/dolfinx:stable. Please carefully read my replies before jumping to conclusions.

dolfinx/dolfinx:stable does work in terms of container out of the box.