Pyvista not available with docker due to lack of vtk

Hi,

I’m using dolfinx with docker on M1 Mac book pro and have a problem using pyvista.
When I type pip list, pyvista is not listed and so I tried to install pyvista, but got following error message.

ERROR: Cannot install pyvista==0.20.0, pyvista==[long list of versions] 
because these package versions have conflicting dependencies.

The conflict is caused by:
    pyvista 0.35.2 depends on vtk
    pyvista [other versions] depends on vtk

Therefore, I tried to install vtk but that also did not work with the following error message.

root@c19dbdc6113d:/# pip install vtk
ERROR: Could not find a version that satisfies the requirement vtk (from versions: none)
ERROR: No matching distribution found for vtk

and it seems like this problem comes from python3.10 as discussed here: can't install with Python 3.10 (#18335) · Issues · VTK / VTK · GitLab

I tried the solution suggested in the link, but that also did not work.
As I am not familiar with docker, I might have done something wrong when setting up docker container.

Could anyone help me solve this issue?

Best,

Could you first of all clarify what docker image you are using? If you are using the dolfinx/dolfinx image, could you print dolfinx.common.git_commit_hash, and check if you can find vtk in dolfinx/lab?

As far as I can tell, this could be related to: VTK is not packaged for Mac M1 (#18158) · Issues · VTK / VTK · GitLab

The issue you are refering to has been resolved (VtK is now available for python3.10).

1 Like

Hi @dokken,

I’m, using dolfinx/dolfinx and the output of dolfinx.common.git_commit_hash is 1b27281ac329f1cd1fd7cb3e2d66096e53ad47c3. I do not use dolfinx/lab but I can try and see if vtk is available with it. Thanks for your help.

[EDIT] I tried to use dolfinx/lab with docker run -ti dolfinx/lab:latest but the link shown after

To access the server, open this file in a browser:

Or copy and paste one of these URLs:

did not work for me. My browser (safari and chrome) could not open the link somehow.

Best,

Hi Kei,

This could be Mac specific, as I am using an image built off of dolfinx/dolfinx here for some testing (the commit hash is the same as yours). I believe pyvista comes with dolfinx/dolfinx

Have you tried copy-pasting the links in chrome as-is instead of clicking them? The latter usually works for me consistently across all machines (linux/windows though), of course with the corresponding token (which is in the link).

Hi @bhaveshshrimali

Thank you for your answer! Yes, I checked docker file and believe dolfinx/dolfinx should come with pyvista

I copy-pasted the link in chrome but it did not work. Also I’m building some python package with dolfinx, so working on jupyter notebook is not really optimal for me :frowning:

dolfinx/dolfinx does not come with pyvista. It is only added in the dolfinx/lab environment.
You can run the dolfinx/lab image as a normal image by overriding the entrypoint:

ocker run -ti --rm -v $(pwd):/root/shared --entrypoint="/bin/bash" dolfinx/lab 

Hi @dokken,

Thank you for the help, but still I can not use pyvista with dolfinx/lab.

$ docker run -ti --rm -v $(pwd):/root/shared --entrypoint="/bin/bash" dolfinx/lab 
root@39b2c4003edd:~# python3 -c "import dolfinx"
root@39b2c4003edd:~# python3 -c "import pyvista"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pyvista'

Did you make sure to pull the latest image (docker pull dolfinx/lab)?
Calling the command:

and then

 python3 -c "import dolfinx; print(dolfinx.common.git_commit_hash); import pyvista; print(pyvista.__version__)"

returns

1b27281ac329f1cd1fd7cb3e2d66096e53ad47c3
0.34.2

for me.

Hi @dokken

Yes, it should be the latest image.
My output looks like

$ docker pull dolfinx/lab
Using default tag: latest
latest: Pulling from dolfinx/lab
Digest: sha256:1bba92776bbb301bf47868c8bffecc87b967bad3b9d982096a081cfcce612728
Status: Image is up to date for dolfinx/lab:latest
docker.io/dolfinx/lab:latest
$ docker run -ti --rm -v $(pwd):/root/shared --entrypoint="/bin/bash" dolfinx/lab
root@fe0106d317fa:~# 
root@fe0106d317fa:~# python3 -c "import dolfinx; print(dolfinx.common.git_commit_hash); import pyvista; print(pyvista.__version__)"
1b27281ac329f1cd1fd7cb3e2d66096e53ad47c3
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pyvista'

So the git_commit.hash is the same as yours but pyvista is still not available to me.

Unfortunately there are no binary wheels of VTK for Linux arm64 so we cannot straightforwardly include pyvista, which depends on VTK, in our arm64 docker image.

It seems like it is technically possible to build VTK arm64 wheels so we can hope that these become available in the future and then we can enable pyvista in our arm64 images.

https://docs.pyvista.org/extras/building_vtk.html

1 Like

I guess this is the relevant issues to track: aarch64 support · Issue #42 · KitwareMedical/VTKPythonPackage · GitHub
VTK is not packaged for Mac M1 (#18158) · Issues · VTK / VTK · GitLab

1 Like

I managed to solve this problem by compiling vtk from source on my MacBook Pro (M1 Pro) and directly referring to the wheel with pip after launching the container.

VTK is available as a binary wheel on Mac OS aarch64 (M*), but not Linux aarch64.

1 Like

Hi there,

I am quite new to FEniCS, and after finally managing to get my docker install working I have just his this same problem. Has there been any development on a solution/work around?

You can install VTK from source.

I have added a wheel for vtk-9.2.6.dev0-cp310 here: Release vtk-9.2.6.dev0-cp310-cp310-linux_aarch64 · finsberg/vtk-aarch64 · GitHub

So a possible workaround is as follows (assuming you are using python3.10)

RUN dpkgArch="$(dpkg --print-architecture)"; \
    case "$dpkgArch" in arm64) \
    python3 -m pip install "https://github.com/finsberg/vtk-aarch64/releases/download/vtk-9.2.6-cp310/vtk-9.2.6.dev0-cp310-cp310-linux_aarch64.whl" ;; \
    esac;
RUN python3 -m pip install pyvista
3 Likes