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

Error when link Lammps to python after Nequip complied #30

Open
DIooooooooooooo opened this issue Nov 11, 2022 · 1 comment
Open

Error when link Lammps to python after Nequip complied #30

DIooooooooooooo opened this issue Nov 11, 2022 · 1 comment

Comments

@DIooooooooooooo
Copy link

I have pytorch==1.11.0+cu113 and cuda 11.3 on my system.
After I complied Lammps with Nequip, I want to link Lammps to python. but when I input
make serial mode=shlib
in terminal in the path/to/src, the following error accurred:

g++ -g -O3 -std=c++11 -fPIC -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64    -I../STUBS     -c ../lammps.cpp
In file included from ../style_pair.h:16,
                 from ../lammps.cpp:29:
../pair_nequip.h:25:10: fatal error: torch/torch.h: No such file or directory
   25 | #include <torch/torch.h>;
      |          ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [Makefile:109: lammps.o] Error 1
make[2]: Leaving directory '/home/ubuntu/software/lammps/lammps/src/Obj_shared_serial'
make[1]: *** [Makefile:390: serial] Error 2
make[1]: Leaving directory '/home/ubuntu/software/lammps/lammps/src'
make: *** [Makefile:390: serial] Error 2

I can easily link a new Lammps with nothing complied to python by:

make serial mode=shlib
make install-python

but I can't make it when Nequip is complied. I wonder if it is possible to link Lammps with Nequip implied to python or does someone manage it?

@anjohan
Copy link
Collaborator

anjohan commented Nov 11, 2022

This should be possible, but you need to do everything within CMake, since we use it to find Torch.

See the documentation, but you should essentially add something like -DPKG_PYTHON=ON -DBUILD_SHARED_LIBS=ON.

You can try to set -DCMAKE_INSTALL_PREFIX=/somewhere/in/path and run make install and pray that you can then run import lammps; l = lammps.lammps(), although this is somewhat unreliable. A safer option is to set the environment variables PYTHONPATH=$PYTHONPATH:/path/to/lammps/python LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/lammps/build

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

No branches or pull requests

2 participants