简体   繁体   English

为什么Docker在Raspberry上将我的容器的CPU使用率限制为100%

[英]Why is Docker limiting my container's CPU usage to 100% on Raspberry

I'm running the latest docker version on Raspbian on my RaspberryPi 3. 我在RaspberryPi 3上的Raspbian上运行最新的docker版本。

I have a program that takes pictures with the camera, compresses them and sends them over the network. 我有一个程序,可以用相机拍摄照片,将其压缩并通过网络发送。

When I run the program outside of docker I can see using top that it's constantly consuming around 130% CPU (of 4cores x 100% of the raspberry). 当我在docker之外运行程序时,我可以看到使用top的过程经常消耗约130%的CPU(4核x 100%的树莓)。 The constant compression is the CPU intensive part of the program but it manages to compress around 32 fps. 恒定压缩是程序中占用大量CPU的部分,但它可以压缩约32 fps。

When I run the exact same program in a docker container I can see in top that it is only using 100% cpu (still distributed among the cores). 当我在docker容器中运行完全相同的程序时,我可以从顶部看到它仅使用100%cpu(仍分布在内核之间)。 Here the program is only able to compress at around 23 fps. 在这里,程序只能以23 fps左右的速度压缩。

I tried passing the --cpus flag but it returned an error: 我尝试传递--cpus标志,但返回错误:

docker: Error response from daemon: NanoCPUs can not be set, as your kernel does not support CPU cfs period/quota or the cgroup is not mounted.

Note: I have done many tests and networking is not the issue. 注意:我已经进行了许多测试,而联网不是问题。

I think I figured out the problem. 我想我已经解决了问题。

When creating the image via the Dockerfile it downloaded the different versions of the libraries I used in the code. 通过Dockerfile创建映像时,它下载了我在代码中使用的不同版本的库。 So technically it was running different code from what was running on the host and it was not a docker issue. 因此,从技术上讲,它运行的代码与主机上运行的代码不同,这不是docker问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM