Sample Header Ad - 728x90

Setting `ulimit -l unlimited` for non-root user

1 vote
1 answer
520 views
I am playing with llama.cpp on OpenBSD-current. The program has a --mlock flag to force loading the model into physical memory (i.e. disable mmap). However, running as a non-root user gives warning: failed to mlock 730202112-byte buffer (after previously locking 0 bytes): Resource temporarily unavailable despite the system having 64GiB memory installed. I suspect this is a ulimit problem, since "Maximum size that may be locked into memory" is only 87381kB, and I cannot increase it as a non-root user.
$ ulimit -a
Maximum size of core files created                         (kB, -c) unlimited
Maximum size of a process’s data segment                   (kB, -d) 4194304
Maximum size of files created by the shell                 (kB, -f) unlimited
Maximum size that may be locked into memory                (kB, -l) 87381
Maximum resident set size                                  (kB, -m) 64901696
Maximum number of open file descriptors                        (-n) 128
Maximum stack size                                         (kB, -s) 8192
Maximum amount of CPU time in seconds                 (seconds, -t) unlimited
Maximum number of processes available to current user          (-u) 1310

$ ulimit -l unlimited
ulimit: Permission denied when changing resource of type 'Maximum size that may be locked into memory'
The obvious approach is to su - and ulimit -l unlimited, but then I have to run llama.cpp as root, which is probably not a good idea. How can I increase ulimit -l for a non-root user?
Asked by nalzok (431 rep)
Aug 21, 2024, 05:19 PM
Last activity: Aug 22, 2024, 12:05 AM