0

I have a gpu based system. Multiple users use the system, as a result, the RAM frequently gets fully utilized leaving no memory for myself. I want to put a maximum RAM limit on all the users except for myself. I have tried the following:

  1. Create a group on Ubuntu using groupadd.
    Used cgroups to create a memlimit group on ubuntu as per 3.1 point in tutorial

    Problem: Apparently, cgcreate is unable to fetch the UID of the group that I created.

  2. Followed this answer:
    Created a group groupname on Ubuntu using groupadd.
    Created a group memlimit in /etc/cgconfig.conf.
    Updated the /etc/cgrules.conf with @groupname memory memlimit/.
    Finally ran sudo cgrulesengd

    Problem: No errors but memory limit not working.

Iskustvo
  • 957

1 Answers1

0

If the unified cgroup (cgroup version 2) is acceptable and you have the administrator's password, the following steps should work on Ubuntu 18.04 (I am not sure of older versions of Ubuntu):

  1. Add systemd.unified_cgroup_hierarchy=1 to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, run update-grub.
  2. Make the following /etc/systemd/system/user.slice.d/allmemory.conf

[Slice] MemoryHigh=32G

  1. Reboot Linux. Then the memory consumption of all users, including you, is limited to 32 GB. To escape this limitation, start another shell by systemd-run --scope /bin/bash. The new bash shell belongs to another cgroup and is not controlled by the memory control.