You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The parallel code works out how many CPUs are on the system by checking the quota it has been assigned in the Linux cgroup. The existing code works under cgroups v1 but the file structure changed in cgroups v2. From [1]:
"cpu.cfs_quota_us" and "cpu.cfs_period_us" are replaced by "cpu.max"
which contains both quota and period.
This commit add support to parallel so it will read from the cgroups v2 location. v1 support is still retained.
The parallel code works out how many CPUs are on the system by checking
the quota it has been assigned in the Linux cgroup. The existing code
works under cgroups v1 but the file structure changed in cgroups v2.
From [1]:
"cpu.cfs_quota_us" and "cpu.cfs_period_us" are replaced by "cpu.max"
which contains both quota and period.
This commit add support to parallel so it will read from the cgroups v2
location. v1 support is still retained.
Resolvesopencv#25284
[1] torvalds/linux@0d59363
I've build and tested this locally on my Linux system (Fedora 38) running cgroups v2 and the opencv is now reporting the expected number of threads when running in a container with a quota.
$ mount -l | grep cgroup
cgroup2 on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot)
$ docker run --cpu-quota=300000 --cpu-period=100000 ...
$ opencv_version --threads
Parallel framework: pthreads (nthreads=3)
The reason will be displayed to describe this comment to others. Learn more.
What about cpuset? Apparently on my system with cgroups2 (Ubuntu 22.04 - based) it has changed location to /sys/fs/cgroup/cpuset.cpus or cpuset.cpus.effective (idk which is right).
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The parallel code works out how many CPUs are on the system by checking the quota it has been assigned in the Linux cgroup. The existing code works under cgroups v1 but the file structure changed in cgroups v2. From [1]:
which contains both quota and period.
This commit add support to parallel so it will read from the cgroups v2 location. v1 support is still retained.
Resolves #25284
[1] torvalds/linux@0d59363
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.