plumed / plumed2

Development version of plumed 2
https://www.plumed.org
GNU Lesser General Public License v3.0
356 stars 283 forks source link

Plumed can't find libtorch #983

Closed zimb3l-priv closed 10 months ago

zimb3l-priv commented 11 months ago

Hello!

I am trying to compile Plumed 2.9.0 with Libtorch CPU, but I am getting errors. No matter what I try, I get this message in the logs:

checking libtorch without extra libs... no checking libtorch with -ltorch_cpu -lc10... no configure: WARNING: cannot enable __PLUMED_HAS_LIBTORCH

With the config.log showing the following

User conftest.cpp:37:10: fatal error: torch/torch.h: No such file or directory 37 | #include <torch/torch.h>

The full configure command I used was this: ./configure --prefix=/software/PLUMED-2.9.0-libtorch/plumed-install/ --enable-libtorch LDFLAGS="-L/software/LibTorch/libtorch" But I also tried various different combinations from emitting the LDFLAGS to specifying the folder of the torch.h and I also tried it with the CUDA version of libtorch - nothing worked

What else can I try to get it to recognize the library?

Iximiel commented 10 months ago

Have you tried with ./configure --prefix=/software/PLUMED-2.9.0-libtorch/plumed-install/ --enable-libtorch LDFLAGS="-L/path/to/libtorch/lib" CPPFLAGS='-I/path/to/libtorch/include -I/path/to/libtorch/include/torch/csrc/api/include/'?

change /path/to/libtorch with your libtorch directory, the one that contains the lib and the include directories.

LDFLAGS are part of the options you pass to the linker CPPFLAGS are the options you pass to to cpp compiler (in this case you have to pass the include paths for libtorch) Libtorch is thought to be included in projects that use CMake, so it is not easy to set up everything with autotools

Ciao Daniele

luigibonati commented 10 months ago

As an alternative to what Daniele suggested, you can also follow the documentation and export the relevant variables:

https://www.plumed.org/doc-master/user-doc/html/_installation.html#installation-libtorch

in this case, you can invoke the configure without passing LDFLAGS/CPPFLAGS

Best,

Luigi


Luigi Bonati Postdoctoral Researcher Atomistic Simulations Italian Institute of Technology, Genova, Italy

Il giorno lun 13 nov 2023 alle ore 13:56 Daniele @.***> ha scritto:

Have you tried with ./configure --prefix=/software/PLUMED-2.9.0-libtorch/plumed-install/ --enable-libtorch LDFLAGS="-L/path/to/libtorch/lib" CPPFLAGS='-I/path/to/libtorch/include -I/path/to/libtorch/include/torch/csrc/api/include/'?

change /path/to/libtorch with your libtorch directory, the one that contains the lib and the include directories.

LDFLAGS are part of the options you pass to the linker CPPFLAGS are the options you pass to to cpp compiler (in this case you have to pass the include paths for libtorch) Libtorch is thought to be included in projects that use CMake, so it is not easy to set up everything with autotools

Ciao Daniele

— Reply to this email directly, view it on GitHub https://github.com/plumed/plumed2/issues/983#issuecomment-1808114751, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRCUSYM7ZHKVJ5VUTDP4QTYEIKHHAVCNFSM6AAAAAA6MJJ7NWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBYGEYTINZVGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

andleb commented 2 months ago

@luigibonati : Apologies for re-opening this, but I feel like this is the most suitable place to ask. I am actually playing around with your mlcolvar paper examples on an M1 Mac, trying to run the enhanced sampling iterations locally.

Running ./configure using the old 1.13.1 C++-abi library fails (I know for sure that the test code in configure.ac does not compile). However, using the correct libtorch-macos-arm64-2.*.zip, for which the test example compiles, also fails to configure; my guess would be since versions above 2.0 are not supported (and older ones are not available here ).

I have installed libtorch as instructed (and can compile & link the test examples), as well as tried all the permutations of the ./configure options above. Is my reading correct and are those with ARM Macs stuck for now?