I am trying to install LAMMPS Python module and extend Python to LAMMPS as well, by following the instructions here. The LAMMPS version is 3 Nov 2022. I would like to do a full installation with CMake, since I hope to use it in various virtual Conda environment. So I followed the instruction in Full install(CMake-only)
bulletin instead of the instruction in Virtual environment
bulletin. The commands I used are
module load gcc-toolset/12
module load openmpi/gcc/4.1.2
module load anaconda3/2021
mkdir build
cd build
cmake -C âŚ/cmake/presets/basic.cmake -DCMAKE_INSTALL_PREFIX=pwd
-DCMAKE_CXX_COMPILER=mpicxx -DPKG_REPLICA=ON -DPKG_MISC=ON -DPKG_MOLECULE=ON -DPKG_KSPACE=ON -DPKG_EXTRA-PAIR=ON -DBUILD_SHARED_LIBS=ON -DLAMMPS_EXCEPTIONS=ON -DPKG_PYTHON=ON âŚ/cmake
(Note that I set the installation prefix to be âpwdâ, so it will be installed in current âbuild/â directory)
cmake --build .
cmake --install .
Later I would like to use it in some virtual environments. I knew the LAMMPS executable, shared library and so on could not be found by default, so I added their paths to environment variables in ~/.bashrc
file:
export PATH=my-lammps-directory/build/bin:$PATH
export LD_LIBRARY_PATH=my-lammps-directory/build:$LD_LIBRARY_PATH (I am not sure if the path is correct)
export PYTHONPATH=my-lammps-directory/python:$PYTHONPATH (I am not sure if the path is correct)
So far, I think the installation should be complete. There were no error messages popping up during the installation, but I found there were something strange to me:
- First, the LAMMPS Python package is installed in
my-lammps-dir/build/lib/pythonX.Y/site-packages/lammps
as if the system is 32bit, but the shared libraryliblammps.so
appears inmy-lammps-dir/build/lib64/
as if the system is 64bit. I do not know if the conflict will cause any problem. By the way, the Linux system is 64bit. - Second, there also exists a shared library
liblammps.so
inside the foldermy-lammps-dir/build/
, which is my installation directory. And theliblammps.so
here differs from theliblammps.so
insidemy-lammps-dir/build/lib64/
I mentioned above. I do not know which one is actually linked to the executablelmp
. - Third, I am not sure if the
PYTHONPATH
is correct, since there is only one sentence in the instruction page saying âThePYTHONPATH
needs to point to the parent folder that contains thelammps
package!â, while there are many folders calledlammps
.
With these questions, I move to implement it, and some error message is popped up,
conda activate myenv (has been created before)
pythonimport lammps (works)
from lammps import lammps (works)
lmp = lammps() (fails)
I actually used Slurm to submit the Python test script, of which the error message is relatively long, and I paste the content of slurm-xxx.out
file below since I cannot upload files because I am a new user. I guess the error occurs due to some unknown issue of the installation procedure, probably including linking some libraries, adding some paths and so forth.
I will appreciate it if someone can help me solve this problem.
WARNING: There was an error initializing an OpenFabrics device.
Local host: della-r3c4n15
Local device: mlx4_0[della-r3c4n15:633844:0:633844] Caught signal 11 (Segmentation fault: address not mapped to object at address 0x440000e9)
==== backtrace (tid: 633844) ====
0 /lib64/libucs.so.0(ucs_handle_error+0x2dc) [0x15332bc6cedc]
1 /lib64/libucs.so.0(+0x2b0bc) [0x15332bc6d0bc]
2 /lib64/libucs.so.0(+0x2b28a) [0x15332bc6d28a]
3 /usr/local/openmpi/4.1.2/gcc/lib64/libmpi.so.40(PMPI_Comm_set_errhandler+0x43) [0x1533420be0c3]
4 {HOME}/.conda/envs/pimd/lib/python3.8/site-packages/mpi4py/MPI.cpython-38-x86_64-linux-gnu.so(+0x86b20) [0x153340cd4b20] 5 {HOME}/.conda/envs/pimd/lib/python3.8/site-packages/mpi4py/MPI.cpython-38-x86_64-linux-gnu.so(+0x2dee1) [0x153340c7bee1]
6 python(PyModule_ExecDef+0x48) [0x558dfc9ae118]
7 python(+0x2361b5) [0x558dfc9ae1b5]
8 python(+0x13b385) [0x558dfc8b3385]
9 python(PyVectorcall_Call+0x6f) [0x558dfc8d649f]
10 python(_PyEval_EvalFrameDefault+0x6152) [0x558dfc954af2]
11 python(_PyEval_EvalCodeWithName+0x260) [0x558dfc944600]
12 python(_PyFunction_Vectorcall+0x594) [0x558dfc945bc4]
13 python(_PyEval_EvalFrameDefault+0x4f83) [0x558dfc953923]
14 python(_PyFunction_Vectorcall+0x1b7) [0x558dfc9457e7]
15 python(_PyEval_EvalFrameDefault+0x4c0) [0x558dfc94ee60]
16 python(_PyFunction_Vectorcall+0x1b7) [0x558dfc9457e7]
17 python(_PyEval_EvalFrameDefault+0x71b) [0x558dfc94f0bb]
18 python(_PyFunction_Vectorcall+0x1b7) [0x558dfc9457e7]
19 python(_PyEval_EvalFrameDefault+0x71b) [0x558dfc94f0bb]
20 python(_PyFunction_Vectorcall+0x1b7) [0x558dfc9457e7]
21 python(+0x142714) [0x558dfc8ba714]
22 python(_PyObject_CallMethodIdObjArgs+0xf5) [0x558dfc8fe275]
23 python(PyImport_ImportModuleLevelObject+0x366) [0x558dfc89f8c6]
24 python(+0x1de0b8) [0x558dfc9560b8]
25 python(+0x13c00e) [0x558dfc8b400e]
26 python(_PyEval_EvalFrameDefault+0x5c58) [0x558dfc9545f8]
27 python(_PyEval_EvalCodeWithName+0x260) [0x558dfc944600]
28 python(_PyFunction_Vectorcall+0x594) [0x558dfc945bc4]
29 python(_PyEval_EvalFrameDefault+0x71b) [0x558dfc94f0bb]
30 python(_PyEval_EvalCodeWithName+0xd5f) [0x558dfc9450ff]
31 python(_PyFunction_Vectorcall+0x594) [0x558dfc945bc4]
32 python(+0x142714) [0x558dfc8ba714]
33 python(_PyObject_CallMethodIdObjArgs+0xf5) [0x558dfc8fe275]
34 python(PyImport_ImportModuleLevelObject+0x6cb) [0x558dfc89fc2b]
35 python(_PyEval_EvalFrameDefault+0x300d) [0x558dfc9519ad]
36 python(_PyEval_EvalCodeWithName+0x260) [0x558dfc944600]
37 python(_PyFunction_Vectorcall+0x534) [0x558dfc945b64]
38 python(+0x1b9698) [0x558dfc931698]
39 python(_PyObject_MakeTpCall+0x228) [0x558dfc8a8fa8]
40 python(_PyEval_EvalFrameDefault+0x4eff) [0x558dfc95389f]
41 python(_PyEval_EvalCodeWithName+0x260) [0x558dfc944600]
42 python(PyEval_EvalCode+0x23) [0x558dfc945eb3]
43 python(+0x242622) [0x558dfc9ba622]
44 python(+0x2531d2) [0x558dfc9cb1d2]
45 python(+0x25636b) [0x558dfc9ce36b]
46 python(PyRun_SimpleFileExFlags+0x1bf) [0x558dfc9ce54f]
47 python(Py_RunMain+0x3a9) [0x558dfc9cea29]
48 python(Py_BytesMain+0x39) [0x558dfc9cec29]
49 /lib64/libc.so.6(__libc_start_main+0xe5) [0x1533440dfd85]
50 python(+0x1f9ad7) [0x558dfc971ad7][della-r3c4n15:633844] *** Process received signal ***
[della-r3c4n15:633844] Signal: Segmentation fault (11)
[della-r3c4n15:633844] Signal code: (-6)
[della-r3c4n15:633844] Failing at address: 0x254b70009abf4
[della-r3c4n15:633844] [ 0] /lib64/libpthread.so.0(+0x12cf0)[0x15334447dcf0]
[della-r3c4n15:633844] [ 1] /usr/local/openmpi/4.1.2/gcc/lib64/libmpi.so.40(PMPI_Comm_set_errhandler+0x43)[0x1533420be0c3]
[della-r3c4n15:633844] [ 2] {HOME}.conda/envs/pimd/lib/python3.8/site-packages/mpi4py/MPI.cpython-38-x86_64-linux-gnu.so(+0x86b20)[0x153340cd4b20] [della-r3c4n15:633844] [ 3] {HOME}/.conda/envs/pimd/lib/python3.8/site-packages/mpi4py/MPI.cpython-38-x86_64-linux-gnu.so(+0x2dee1)[0x153340c7bee1]
[della-r3c4n15:633844] [ 4] python(PyModule_ExecDef+0x48)[0x558dfc9ae118]
[della-r3c4n15:633844] [ 5] python(+0x2361b5)[0x558dfc9ae1b5]
[della-r3c4n15:633844] [ 6] python(+0x13b385)[0x558dfc8b3385]
[della-r3c4n15:633844] [ 7] python(PyVectorcall_Call+0x6f)[0x558dfc8d649f]
[della-r3c4n15:633844] [ 8] python(_PyEval_EvalFrameDefault+0x6152)[0x558dfc954af2]
[della-r3c4n15:633844] [ 9] python(_PyEval_EvalCodeWithName+0x260)[0x558dfc944600]
[della-r3c4n15:633844] [10] python(_PyFunction_Vectorcall+0x594)[0x558dfc945bc4]
[della-r3c4n15:633844] [11] python(_PyEval_EvalFrameDefault+0x4f83)[0x558dfc953923]
[della-r3c4n15:633844] [12] python(_PyFunction_Vectorcall+0x1b7)[0x558dfc9457e7]
[della-r3c4n15:633844] [13] python(_PyEval_EvalFrameDefault+0x4c0)[0x558dfc94ee60]
[della-r3c4n15:633844] [14] python(_PyFunction_Vectorcall+0x1b7)[0x558dfc9457e7]
[della-r3c4n15:633844] [15] python(_PyEval_EvalFrameDefault+0x71b)[0x558dfc94f0bb]
[della-r3c4n15:633844] [16] python(_PyFunction_Vectorcall+0x1b7)[0x558dfc9457e7]
[della-r3c4n15:633844] [17] python(_PyEval_EvalFrameDefault+0x71b)[0x558dfc94f0bb]
[della-r3c4n15:633844] [18] python(_PyFunction_Vectorcall+0x1b7)[0x558dfc9457e7]
[della-r3c4n15:633844] [19] python(+0x142714)[0x558dfc8ba714]
[della-r3c4n15:633844] [20] python(_PyObject_CallMethodIdObjArgs+0xf5)[0x558dfc8fe275]
[della-r3c4n15:633844] [21] python(PyImport_ImportModuleLevelObject+0x366)[0x558dfc89f8c6]
[della-r3c4n15:633844] [22] python(+0x1de0b8)[0x558dfc9560b8]
[della-r3c4n15:633844] [23] python(+0x13c00e)[0x558dfc8b400e]
[della-r3c4n15:633844] [24] python(_PyEval_EvalFrameDefault+0x5c58)[0x558dfc9545f8]
[della-r3c4n15:633844] [25] python(_PyEval_EvalCodeWithName+0x260)[0x558dfc944600]
[della-r3c4n15:633844] [26] python(_PyFunction_Vectorcall+0x594)[0x558dfc945bc4]
[della-r3c4n15:633844] [27] python(_PyEval_EvalFrameDefault+0x71b)[0x558dfc94f0bb]
[della-r3c4n15:633844] [28] python(_PyEval_EvalCodeWithName+0xd5f)[0x558dfc9450ff]
[della-r3c4n15:633844] [29] python(_PyFunction_Vectorcall+0x594)[0x558dfc945bc4]
[della-r3c4n15:633844] *** End of error message ***
/var/spool/slurmd/job45544893/slurm_script: line 24: 633844 Segmentation fault (core dumped) python mpi4py_lmp.py > output