Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running metadynamics with PLUMED and metatensor-defined collective variables #88

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Luthaf
Copy link
Contributor

@Luthaf Luthaf commented Oct 11, 2024

Very work in progress, this will not even run on CI!

To build the example locally:

git clone https://github.com/lab-cosmo/plumed2 --branch conda-metatensor plumed-conda-metatensor
cd plumed-conda-metatensor

# install the dependencies provided by pip
pip install cython "metatensor-torch>=0.5.5"

# SETUP FLAGS following https://www.plumed.org/doc-master/user-doc/html/_m_e_t_a_t_e_n_s_o_r_m_o_d.html, 
# the code below should work on linux, when using pre-built from pip wheels

# export the location to all the libraries:
TORCH_CMAKE_PREFIX=$(python -c "import torch; print(torch.utils.cmake_prefix_path)")
TORCH_PREFIX=$(cd "$TORCH_CMAKE_PREFIX/../.." && pwd)
 
METATENSOR_CMAKE_PREFIX=$(python -c "import metatensor; print(metatensor.utils.cmake_prefix_path)")
METATENSOR_PREFIX=$(cd "$METATENSOR_CMAKE_PREFIX/../.." && pwd)
 
METATENSOR_TORCH_CMAKE_PREFIX=$(python -c "import metatensor.torch; print(metatensor.torch.utils.cmake_prefix_path)")
METATENSOR_TORCH_PREFIX=$(cd "$METATENSOR_TORCH_CMAKE_PREFIX/../.." && pwd)
TORCH_CPPFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"

TORCH_INCLUDES="-I$TORCH_PREFIX/include -I$TORCH_PREFIX/include/torch/csrc/api/include"
CPPFLAGS="$TORCH_INCLUDES $TORCH_CPPFLAGS -I$METATENSOR_PREFIX/include -I$METATENSOR_TORCH_PREFIX/include $CPPFLAGS"
 
LDFLAGS="-L$TORCH_PREFIX/lib -L$METATENSOR_PREFIX/lib -L$METATENSOR_TORCH_PREFIX/lib $LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,-rpath,$TORCH_PREFIX/lib"
LDFLAGS="$LDFLAGS -Wl,-rpath,$METATENSOR_PREFIX/lib -Wl,-rpath,$METATENSOR_TORCH_PREFIX/lib"
LDFLAGS="$LDFLAGS -Wl,--disable-new-dtags"

./configure --enable-python --enable-libtorch --enable-metatensor --enable-modules=all LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS"

make -j

Then, set PLUMED_KERNEL in lj-crystal.py to [.....]/plumed-conda-metatensor/src/lib/libplumedKernel.so.

If you get an error about the GIL being held, copy [.....]/plumed-conda-metatensor/src/python/plumed.cpython-* to .nox/metatensor-plumed/lib/python3.*/site-packages/plumed.cpython-*.

This is blocked on the following PR to different tools used here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants