"ERROR: Must not use GPU neighbor lists with hybrid pair style" when running lammps on GPU from Python

Hi LAMMPS developers and users,

I want to run a LAMMPS script on GPU from Python, just as what Pragin wanted to do in Running LAMMPS on GPU from python script - LAMMPS / LAMMPS General Discussion - Materials Science Community Discourse (matsci.org). I followed Axel’s advice and used the command args:

from lammps import lammps

lmp = lammps(cmdargs=['-sf', 'gpu', '-pk', 'gpu 1'])
lmp.file('myscript.in')

This would be OK if no hybrid pair style was specified. Otherwise, I would be given the error:

ERROR: Must not use GPU neighbor lists with hybrid pair style (src/GPU/fix_gpu.cpp:280)

I know that to bypass the error, I can specify neigh no and run on the terminal

lmp -sf gpu -pk gpu 1 neigh no -in myscript.in

But how can I specify it in Python? I tried the commands below, but none of them worked and I got the same error.

lmp = lammps(cmdargs=['-sf', 'gpu', '-pk', 'gpu 1 neigh no'])
lmp = lammps(cmdargs=['-sf', 'gpu', '-pk', 'gpu 1', 'neigh', 'no'])
lmp = lammps(cmdargs=['-sf', 'gpu', '-pk', 'gpu 1', 'neigh no'])

Any help or comment is appreciated. Thanks in advance!

This is not correct. It has to be:
lmp = lammps(cmdargs=['-sf', 'gpu', '-pk', 'gpu', '1'])
Otherwise the ‘-pk’ flag will call the equivalent of package "gpu 1" which is not correct and thus the default setting of package gpu 0 will be applied.

All of these are incorrect. Each “word” must be a separate string in the cmdargs list of strings:
lmp = lammps(cmdargs=['-sf', 'gpu', '-pk', 'gpu', '1', 'neigh', 'no'])
should do the trick.

1 Like

That works. Thank u a lot.