green-metrics-tool icon indicating copy to clipboard operation
green-metrics-tool copied to clipboard

cgroupfs support

Open davidkopp opened this issue 8 months ago • 2 comments

I tried to get cgroup v2 running under Windows with WSL2. This issue is intended to document my experiences with it so far.

cgroup v2 can generally be activated in WSL (see below), but its use in GMT currently fails because Docker Desktop on Windows uses the cgroup driver cgroupfs, but GMT only supports cgroup v2 with the cgroup driver systemd. Helpful information about the two cgroup drivers can be found here.

I can think of three ways, how the usage of cgroups in WSL could be possible:

  • GMT supports the cgroupfs driver
  • Docker is installed directly in WSL, without Docker Desktop, and started with systemd (not tested)
  • GMT supports cgroup v1 (https://github.com/green-coding-solutions/green-metrics-tool/issues/497)

The problem is not really important to me. But I thought it would make sense to document it here quickly.


How to activate cgroup v2 in WSL?

Create the file %USERPROFILE%\.wslconfig (or edit it) and add the following content:

[wsl2]
kernelCommandLine = systemd.unified_cgroup_hierarchy=1 cgroup_no_v1=all

Source: Docker Desktop 4.17.0 Release Notes

Then restart WSL (wsl.exe --shutdown). You can check which cgroup version is activated via:

mount -l | grep cgroup

davidkopp avatar Jun 02 '24 18:06 davidkopp