Skip to content

Commit

Permalink
Fix build instructions on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Mar 28, 2024
1 parent 56716fa commit 622e424
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/metatensor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ TORCH_PREFIX=../../..
TORCH_CMAKE_PREFIX=$(python -c "import torch; print(torch.utils.cmake_prefix_path)")
TORCH_PREFIX=$(cd "$TORCH_CMAKE_PREFIX/../.." && pwd)

TORCH_INCLUDES="-I$TORCH_PREFIX/include -I$TORCH_PREFIX/include/torch/csrc/api/include"

# patch a bug from torch's MKL detection
cd <PLUMED/DIR>
./src/metatensor/patch-torch.sh "$TORCH_PREFIX"
Expand All @@ -30,7 +32,7 @@ METATENSOR_PREFIX=<...>

METATENSOR_TORCH_PREFIX="$METATENSOR_PREFIX"

git clone https://github.com/lab-cosmo/metatensor --tag metatensor-torch-v0.3.0
git clone https://github.com/lab-cosmo/metatensor --branch=metatensor-torch-v0.3.0
cd metatensor

mkdir build && cd build
Expand Down Expand Up @@ -59,10 +61,18 @@ METATENSOR_TORCH_PREFIX=$(cd "$METATENSOR_TORCH_CMAKE_PREFIX/../.." && pwd)
```bash
cd <PLUMED/DIR>

# configure with metatensor
# configure PLUMED with metatensor
./configure --enable-libtorch --enable-metatensor --enable-modules=+metatensor \
LDFLAGS="-L$TORCH_PREFIX/lib -L$METATENSOR_PREFIX/lib -L$METATENSOR_TORCH_PREFIX/lib" \
CPPFLAGS="$TORCH_INCLUDES -I$METATENSOR_PREFIX/include -I$METATENSOR_TORCH_PREFIX/include"

# If you are on Linux and use a pip-installed version of libtorch, or the
# pre-cxx11-ABI build of libtorch, you'll need to add "-D_GLIBCXX_USE_CXX11_ABI=0"
# to the compilation flags:
./configure --enable-libtorch --enable-metatensor --enable-modules=+metatensor \
LDFLAGS="-L$TORCH_PREFIX/lib -L$METATENSOR_PREFIX/lib -L$METATENSOR_TORCH_PREFIX/lib" \
CPPFLAGS="-I$TORCH_PREFIX/include -I$TORCH_PREFIX/include/torch/csrc/api/include -I$METATENSOR_PREFIX/include -I$METATENSOR_TORCH_PREFIX/include"
CPPFLAGS="$TORCH_INCLUDES -I$METATENSOR_PREFIX/include -I$METATENSOR_TORCH_PREFIX/include" \
CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0"

make -j && make install
```

0 comments on commit 622e424

Please sign in to comment.