r/linuxquestions • u/digiphaze • Apr 25 '26
Linux 7.0 cgroups no longer allow user systemd unit files to access devices
Am I missing something? I have tried every trick in the book and every AI suggestion to get this to work. After upgrading to Linux 7.0 my llama-server user unit file no longer can see my GPU. It works if I convert it to a system level unit file but I really didn't want to do that.
Given that I can run llama-server by hand.. WTH can I not just turn it into a systemd --user unit and run it that way when I want to?
This seems like an absurd security change.
This is the user unit file. DeviceAllow statements don't work in them.
1 [Unit]
2 Description=Llama-cpp GPT
3 After=network.target
4
5 [Service]
6 Type=simple
7 WorkingDirectory=/opt/llama-cpp
8
9 Environment="DISPLAY="
10 Environment="AMD_VULKAN_ICD=RADV"
11 Environment="XDG_RUNTIME_DIR=/run/user/1000"
12 Environment="VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/radeon_icd.json"
13
14 ExecStart=/opt/llama-cpp/llama-server \
15 -m /opt/llama-cpp/models/gpt-oss-20b-F16.gguf \
16 --host 0.0.0.0 \
17 --port 9090 \
18 -c 32768 \
19 -t 0 \
20 -ngl 999 \
21 -np 4 \
22 --cont-batching \
23 --batch-size 512 \
24 --ubatch-size 512 \
25 --no-mmap \
26 --cache-type-k q8_0 \
27 --cache-type-v q8_0
28
29 LimitNOFILE=1048576
30
31 Restart=no
32
33 [Install]
34 WantedBy=multi-user.target
6
Upvotes
3
u/Existing-Tough-6517 Apr 25 '26
Just a thought is it possible to run this as its own user and still have it be possible to talk to it or does that ruin usage thereof?
6
u/g0nel Apr 25 '26
I don't know what flavor of Linux or which kernel you're coming from but it does seem like a cgroup v1 vs v2 difference.
I believe they dropped cgroup v1 entirely as of 7.0 and this might be what you are hitting.
This or this might be useful for understand why it's not working.
You might be able to utilize a user slice policy with
DeviceAllow=6
u/aioeu Apr 25 '26 edited Apr 25 '26
I've had a chance to play around with this on some of my systems now.
Are you absolutely sure you didn't update systemd at the same time? If you were previously running systemd v257 or earlier, and if you were using the "hybrid" cgroup v1+v2 setup, and if you were delegating the cgroup v1
devicescontroller to user systemd managers, then systemd would have used this in user units.Though to be fair, I have not been able to fully test this. Although I do have a machine using systemd v257, it uses the "unified" cgroup v2-only setup, and systemd v257 had an explicit check to only use BPF programs for the superuser. These two things combined means I have no way to use
DeviceAllow=in an unprivileged user unit on that system.From systemd v258 onwards, only cgroup v2 is supported. The cgroup v1 devices controller still exists in the kernel — /u/g0nel mentioned that it might be removed, but as far as I can see that has not yet happened — but systemd won't use it. The explicit check for the superuser just mentioned was also removed at this point; instead, systemd simply tests whether a BPF program can be loaded.
You need to make sure you have unprivileged BPF enabled so that test succeeds. Check the
kernel.unprivileged_bpf_disabledsysctl. If it is1or2,DeviceAllow=won't work in a user unit; it needs to be set to0to allow unprivileged users to load BPF programs. If you change this setting you will need todaemon-reexecany existing systemd processes so they can redetect whether BPF support is available... or just reboot, of course.This sysctl's default value is controlled by a kernel config option,
CONFIG_BPF_UNPRIV_DEFAULT_OFF, but your diffs in the other thread don't indicate that setting got changed. So I'm led to believe that maybe you updated systemd at the same time, and it was that that has caused this problem.1
u/RandomUser3777 Apr 25 '26
See these options:
bus.service:PrivateTmp=true
dbus.service:PrivateDevices=true
I don't know what version added these options but default makes it so that the service cannot see devices and has its own isolated /tmp directory.
1
u/aioeu Apr 25 '26
Start by looking at a diff between the old and new kernel configs.
1
u/ddyess Apr 25 '26
Definitely annoying if true, I too use it for my Ollama server, except it's on a distrobox. I don't have the new kernel yet to compare though.
1
u/[deleted] Apr 25 '26 edited Apr 25 '26
[removed] — view removed comment