jorgensd / dolfinx_mpc

Extension for dolfinx to handle multi-point constraints.
https://jorgensd.github.io/dolfinx_mpc/
MIT License
30 stars 12 forks source link

dolfinx_mpc on colab #106

Closed oszachter closed 6 months ago

oszachter commented 6 months ago

Hello, How do I install dolfinx_mpc on Google Colab? All the other packages I install using the fallowing:

!wget "https://fem-on-colab.github.io/releases/fenicsx-install-real.sh" -O "/tmp/fenicsx-install.sh" && bash "/tmp/fenicsx-install.sh"

!wget "https://fem-on-colab.github.io/releases/gmsh-install.sh" -O "/tmp/gmsh-install.sh" && bash "/tmp/gmsh-install.sh"

!apt-get install -qq xvfb

!pip install pyvista panel -q

Thank you!

jorgensd commented 6 months ago

This is a question for @francesco-ballarin as he makes fem-on-colab. I don't know if one can simply do !git clone --branch v0.7.2 --single-branch https://github.com/jorgensd/dolfinx_mpc/ ! cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build-dir ./dolfinx_mpc/cpp/

! ninja -j3 install -C build-dir ! python3 -m pip -v install --config-settings=cmake.build-type="Release" --no-build-isolation ./dolfinx_mpc/python -U

francesco-ballarin commented 6 months ago

What @jorgensd wrote looks correct, with the exception that @oszachter you most probably want to use the main branch of dolfinx_mpc. The reason is that FEM on Colab gets updated every week (on the night between Friday and Saturday) with dolfinx main.

Keep in mind that you will have to recompile dolfinx_mpc every time you restart your Colab environment. How much does it take to compile it?

jorgensd commented 6 months ago

What @jorgensd wrote looks correct, with the exception that @oszachter you most probably want to use the main branch of dolfinx_mpc. The reason is that FEM on Colab gets updated every week (on the night between Friday and Saturday) with dolfinx main.

Keep in mind that you will have to recompile dolfinx_mpc every time you restart your Colab environment. How much does it take to compile it?

DOLFINx_MPC is fairly lightweight.

oszachter commented 6 months ago

First of all, thank you for the quick reply. I'm not used to installing packages from git, so I'm unsure how to use the main branch of dolfinx_mpc. I used this: !git clone --branch v0.7.2 --single-branch https://github.com/jorgensd/dolfinx_mpc/ ! cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build-dir ./dolfinx_mpc/cpp/ ! ninja -j3 install -C build-dir ! python3 -m pip -v install --config-settings=cmake.build-type="Release" --no-build-isolation ./dolfinx_mpc/python -U

and I got the following message:

Cloning into 'dolfinx_mpc'... remote: Enumerating objects: 6953, done. remote: Counting objects: 100% (2372/2372), done. remote: Compressing objects: 100% (853/853), done. remote: Total 6953 (delta 1965), reused 1694 (delta 1486), pack-reused 4581 Receiving objects: 100% (6953/6953), 2.28 MiB | 9.09 MiB/s, done. Resolving deltas: 100% (5203/5203), done. Note: switching to '06f4c5bf55528336ff7f97367cf4396dc263814a'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example:

git switch -c

Or undo this operation with:

git switch -

Turn off this advice by setting config variable advice.detachedHead to false

CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! /bin/bash: line 1: ninja: command not found Using pip 23.1.2 from /usr/local/lib/python3.10/dist-packages/pip (python 3.10) Processing ./dolfinx_mpc/python DEPRECATION: Config settings are ignored for project file:///content/dolfinx_mpc/python. pip 23.3 will enforce this behaviour change. A possible replacement is to use --use-pep517 or add a pyproject.toml file to the project. Running command python setup.py egg_info running egg_info creating /tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info writing /tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info/PKG-INFO writing dependency_links to /tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info/dependency_links.txt writing requirements to /tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info/requires.txt writing top-level names to /tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info/top_level.txt writing manifest file '/tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info/SOURCES.txt' reading manifest file '/tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info/SOURCES.txt' writing manifest file '/tmp/pip-pip-egg-info-cbfplfn7/dolfinx_mpc.egg-info/SOURCES.txt' Preparing metadata (setup.py) ... done Requirement already satisfied: numpy>=1.21 in /usr/local/lib/python3.10/dist-packages (from dolfinx-mpc==0.7.2) (1.25.2) INFO: pip is looking at multiple versions of dolfinx-mpc to determine which version is compatible with other requirements. This could take a while. ERROR: Could not find a version that satisfies the requirement fenics-dolfinx>=0.7.0 (from dolfinx-mpc) (from versions: none) ERROR: No matching distribution found for fenics-dolfinx>=0.7.0

francesco-ballarin commented 6 months ago

Please use this notebook as template https://colab.research.google.com/drive/1NRduhoQoiyBdAutXzQqsvMM9CxD5YoAS

I could add dolfinx_mpc to the fenicsx package, but every package I add is maintenance effort from me. Considering that I have given you a workaround, I am not planning to add it right now. I could revisit this decision in future if there are further similar requests from several other users.

oszachter commented 6 months ago

Thank you so much! It works