Some questions regarding CPU resource limits

Hello, happy new year!

I have some questions about CPU resource constraints.

First, is there a way to limit a container to N CPUs from a given range? E.g. 2 CPUs from CPUs 2 through 7. The reason I’d like to do this is to ensure that certain CPUs are left idle for use by the LXD daemon itself.

Also, is it possible to impose two types of CPU limits, e.g. 25% AND 200ms/100ms, applied via two different profiles? Meaning use 25% of what is available, up to 2 CPUs worth?

Thank you!

Isn’t that what your are looking for ? https://lxd.readthedocs.io/en/latest/containers/#cpu-limits

No, that post explains how to assign CPUs in a range OR a number of CPUs, but I’d like to do both (e.g. 2 CPUs out of the range of CPUs 2 through 7).

It also only explains how to use one type of limit (either time slices or % of available), while I’d like to apply both (e.g. 25% of what is available, up to 2 CPUs worth).

It is more than a “post”: it is the official documentation. So what you are asking for is either undocumented, which I doubt it is, or not possible…

@stgraber or other maintainers, could you please confirm that what I’m trying to do isn’t possible?

It isn’t.

Okay, thanks.

Hello to everyone. I want to ask something relevant so i am writting here.

I have a Raspberry Pi v.4 (RPi) with a 4-core Cortex-A72 ARM processor running at 1.5GHz and 2GB of memory.

I am running yolo object detector through python3. I measured the execution time and it fluctuates about 9-10 secs.

I have also an a HP Pavilion Gaming Laptop 15-cx0xxx with a 12-core i7-8750H X84 processor at 2.20 GHz and 12 GB of memory. The same program with yolo object detector has an execution time of about 0,7 secs.

I create a container to my laptop and i set limits.cpu memory 2GB and limits.cpu 1.

I executed yolo object detector inside the container with the above configurations and the execution time was 2,1 secs. Is there any way to set a limit to something else in order to observe the execution times measured at the rpi ?

Any help ? @stgraber

You can play with the limits.cpu.allowance to reduce the amount of CPU time available to your container.